संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
यूरोपियन इकनॉमिक एरिया (ईईए) के डेवलपर
Route Optimization API में दो तरीके उपलब्ध हैं:
OptimizeTours एक सिंक्रोनस तरीका है. यह OptimizeToursRequest के जवाब में, ऑप्टिमाइज़ किया गया रूट दिखाता है. क्लाइंट को Route Optimization API से कनेक्शन खुला रखना होगा. ऐसा तब तक करना होगा, जब तक अनुरोध प्रोसेस नहीं हो जाता और OptimizeToursResponse या गड़बड़ी का मैसेज नहीं मिल जाता.
BatchOptimizeTours एक एसिंक्रोनस तरीका है. यह एक या उससे ज़्यादा OptimizeToursRequest और उनसे जुड़े OptimizeToursResponse मैसेज के लिए यूआरआई स्वीकार करता है. साथ ही, यह लंबे समय तक चलने वाली कार्रवाई (एलआरओ) (REST, gRPC) का संसाधन नाम दिखाता है. इसका इस्तेमाल बैच पूरा होने की स्थिति की जांच करने के लिए किया जाता है. OptimizeToursRequest को बैकग्राउंड में प्रोसेस किया जाता है. इसलिए, क्लाइंट Route Optimization API से सिर्फ़ तब तक कनेक्ट रहते हैं, जब तक उन्हें BatchOptimizeToursRequest सबमिट करना होता है या एलआरओ की स्थिति की जांच करने के लिए GetOperation को कॉल करना होता है. BatchOptimizeTours, Google Cloud Storage से अनुरोध पढ़ता है और जवाब लिखता है.
उपयोग के उदाहरण
OptimizeTours का इस्तेमाल, छोटे और आसान अनुरोधों को हल करने के लिए किया जा सकता है. इसके अलावा, इसका इस्तेमाल उन अनुरोधों को हल करने के लिए भी किया जा सकता है जिनमें कुछ मिनट या उससे कम समय लगता है. रूट ऑप्टिमाइज़ेशन एपीआई से लंबे समय तक कनेक्शन बनाए रखने से, समाधान मिलने से पहले रुकावट आने का खतरा बढ़ जाता है.
BatchOptimizeTours बड़े अनुरोधों और ज़्यादा समय लेने वाले अनुरोधों को हैंडल कर सकता है. ऐसा इसलिए, क्योंकि इसे Route Optimization API से लंबे समय तक कनेक्ट रहने की ज़रूरत नहीं होती.
ज़्यादा समय तक चलने वाली कार्रवाइयां
बैच के पूरा होने की स्थिति की जांच करने के लिए, GetOperation तरीके का इस्तेमाल करके, Route Optimization API से LRO पढ़े जाते हैं. एलआरओ में एक done प्रॉपर्टी होती है. इससे पता चलता है कि पूरे बैच को प्रोसेस किया गया है या नहीं. साथ ही, इसमें एक error फ़ील्ड होता है. इससे प्रोसेस करने के दौरान हुई गड़बड़ियों की जानकारी मिलती है. अगर done सही है और error मौजूद नहीं है, तो इसका मतलब है कि बैच पूरा हो गया है. error का मतलब है कि बैच के कुछ या सभी आइटम प्रोसेस नहीं किए जा सके.
BatchOptimizeTours अनुरोध का सामान्य लाइफ़साइकल इस तरह होता है:
Route Optimization API को BatchOptimizeToursRequest सबमिट करें. यह LRO का संसाधन नाम दिखाता है.
GetOperation या error प्रॉपर्टी, एलआरओ रिस्पॉन्स में दिखने तक, एलआरओ के लौटाए गए संसाधन के नाम के साथ पोल GetOperation.done
अगर done सही है और कोई गड़बड़ी नहीं है, तो BatchOptimizeTours
अनुरोध में दिए गए Google Cloud Storage यूआरआई से OptimizeToursResponses
पढ़ें. अगर error मौजूद है, तो गड़बड़ी की जांच करें. इसके बाद, Google Cloud Storage में OptimizeToursRequest को अपडेट करें. इसके बाद, गड़बड़ी के हिसाब से फिर से कोशिश करें.
OptimizeTours और BatchOptimizeTours अनुरोध कई तरीकों से भेजे जा सकते हैं. जैसे, कमांड लाइन से या क्लाइंट लाइब्रेरी का इस्तेमाल करके.
[null,null,["आखिरी बार 2025-09-04 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThe Route Optimization API offers two methods: \u003ccode\u003eOptimizeTours\u003c/code\u003e for synchronous processing of smaller, simpler requests and \u003ccode\u003eBatchOptimizeTours\u003c/code\u003e for asynchronous handling of larger, more complex requests.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOptimizeTours\u003c/code\u003e requires an open connection until a response is received, while \u003ccode\u003eBatchOptimizeTours\u003c/code\u003e utilizes Google Cloud Storage for requests and responses, enabling background processing.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eBatchOptimizeTours\u003c/code\u003e relies on Long Running Operations (LROs) to track batch progress, which can be monitored via the \u003ccode\u003eGetOperation\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eWhen using \u003ccode\u003eBatchOptimizeTours\u003c/code\u003e, users should submit the request, poll for completion using the LRO, and retrieve results or address errors as indicated by the LRO status.\u003c/p\u003e\n"]]],[],null,["# Synchronous and asynchronous endpoints\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nThe Route Optimization API exposes two methods:\n\n- `OptimizeTours` is a *synchronous* method that returns an optimized route in response to an `OptimizeToursRequest`. Clients must maintain an open connection to the Route Optimization API until the request is processed and an `OptimizeToursResponse` or error is returned.\n- `BatchOptimizeTours` is an *asynchronous* method that accepts URIs for one or more `OptimizeToursRequest` and corresponding `OptimizeToursResponse` messages, returning the resource name of a *Long Running Operation* (LRO) ([REST](/maps/documentation/route-optimization/reference/rest/v1/projects.locations.operations#Operation), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.longrunning#google.longrunning.Operations))) that is used to check for batch completion. `OptimizeToursRequest`s are processed in the background, so clients maintain an open connections to the Route Optimization API only long enough to submit the `BatchOptimizeToursRequest` or to call `GetOperation` to check LRO status. `BatchOptimizeTours` reads requests from and writes responses to [Google Cloud Storage](https://cloud.google.com/storage).\n\nUse cases\n---------\n\n`OptimizeTours` is convenient for solving small and simple requests, or for\nrequests with solving times of a few minutes or less. Maintaining long-lived\nconnections to the Route Optimization API increases risk of interruption before\na solution can be returned.\n\n`BatchOptimizeTours` can handle larger requests and requests with longer solving\ntime because it does not require a long-lived connection to the Route\nOptimization API.\n\nLong running operations\n-----------------------\n\nLROs are read from the Route Optimization API using the `GetOperation` method to\ncheck the completion status of a batch. LROs include a `done` property that\nindicates whether processing of the entire batch is complete and an `error`\nfield that reports errors encountered during processing. If `done` is true and\nno `error` is present, the batch completed successfully. The presence of an\n`error` indicates that some or all of the batch failed processing.\n| **Note:** REST `GetOperation` responses omit the `done` property if its value is false and the `error` property if no errors occurred.\n\nThe typical lifecycle of a `BatchOptimizeTours` request is as follows:\n\n1. Submit a `BatchOptimizeToursRequest` to the Route Optimization API, which returns the resource name of an LRO.\n2. Poll `GetOperation` with the returned LRO resource name until the `done` or `error` properties appear in the LRO response.\n3. If `done` is true and no error is present, read `OptimizeToursResponses` from the Google Cloud Storage URIs specified in the `BatchOptimizeTours` request. If `error` is present, inspect the error, update the `OptimizeToursRequest`s accordingly in Google Cloud Storage, and retry as appropriate depending on the observed error.\n\nYou can send `OptimizeTours` and `BatchOptimizeTours` requests in a variety of\nways, either from the command line or using a client library.\n\n[Next: Make an API Request](/maps/documentation/route-optimization/make-request)"]]