If you would like to access a large number of searches, places, or reviews, batch processing can significantly speed up the process. Instead of sending individual requests, a batch request allows for up to 1,000 queries in a single request.
In the following examples, we'll demonstrate real-world use cases, and show how to use batch requests most efficiently to achieve the intended goal.
Example one - searching for multiple queries at one location
In the first example, we'll search for three different types of places located around the same coordinates.
Nimble APIs requires that a base64 encoded credential string be sent with every request to authenticate your account. For detailed examples, see Web API Authentication.
Parameters that are placed outside the requests object, such as coordinates, search_engine, storage_type, storage_url, and callback_url , are automatically applied as defaults to all defined requests.
If a parameter is set both inside and outside the requests object, the value inside the request overrides the one outside.
Example two - searching for one query at multiple locations
In the next example, we'll search for one type of place at multiple coordinates:
By placing the query parameter outside of the requests object, we apply it as a default on all the defined requests. Thus, this bulk request would trigger four individual searches for "Restaurants" located around four unique coordinates.
Example three - combining queries and locations
Next, we combine the previously highlighted features in order to search for a different type of place at unique coordinates for each request:
Notice that for the last request, we search for "Bars" without explicitly defining the coordinates where this search should be performed. In this case, the default coordinates defined outside the requests object would be used instead.
Request options
Batch requests use the same parameters as asynchronous requests, with the exception of the requests object.
Parameter
Required
Type
Description
requests
Optional
Object array
Allows for defining custom parameters for each request within the bulk. Any of the parameters below can be used in an individual request.
Required
Applicable only when search_engine = google_maps_place or
google_maps_reviews
Array[string]
Strings used by Google to identify a particular place. place_id and data_id cannot both be used in a single batch.
domain
Optional
String
Search through a custom top-level domain of Google. eg: "co.uk"
country
Optional (default = all)
String
Country used to access the target URL, use ISO Alpha-2 Country Codes i.e. US, DE, GB
locale
Optional (default = en)
String
String | LCID standard locale used for the URL request. Alternatively, user can use auto for automatic locale based on country targeting.
location
Optional
String
Search Google through a custom geolocation, regardless of country or proxy location. eg: "London,Ohio,United States".
parse
Optional (default = true)
Enum: true | false
Instructs Nimble whether to structure the results into a JSON format or return the raw HTML.
storage_type
Optional
Leave blank to enable Push/Pull delivery.
ENUM: s3 | gs
Use s3 for Amazon S3 and gs for Google Cloud Platform
storage_url
Optional
Leave blank to enable Push/Pull delivery.
String
Repository URL: s3://Your.Bucket.Name/your/object/name/prefix/ | Output will be saved to TASK_ID.json
callback_url
Optional
String
A url to callback once the data is delivered. Nimble APIs will send a POST request to the callback_url with the task details once the task is complete (this “notification” will not include the requested data).
Setting GCS/AWS access permissions
GCS Repository Configuration
In order to use Google Cloud Storage as your destination repository, please add Nimble’s system user as a principal to the relevant bucket. To do so, navigate to the “bucket details” page in your GCP console, and click on “Permission” in the submenu.
Next, past our system user [email protected] into the “New Principals” box, select Storage Object Creator as the role, and click save.
That’s all! At this point, Nimble will be able to upload files to your chosen GCS bucket.
S3 repository configuration
In order to use S3 as your destination repository, please give Nimble’s service user permission to upload files to the relevant S3 bucket. Paste the following JSON into the “Bucket Policy” (found under “Permissions”) in the AWS console.
Follow these steps:
1. Go to the “Permissions” tab on the bucket’s dashboard:
2. Scroll down to “Bucket policy” and press edit:
3. Paste the following bucket policy configuration into your bucket:
Important: Remember to replace “YOUR_BUCKET_NAME” with your actual bucket name.
Here is what the bucket policy should look like:
4. Scroll down and press “Save changes”
S3 Encrypted Buckets
If your S3 bucket is encrypted using an AWS Key Management Service (KMS) key, additional permissions to those outlined above are also needed. Specifically, Nimble's service user will need to be given permission to encrypt and decrypt objects using a KMS key. To do this, follow the steps below:
Sign in to the AWS Management Console and open the AWS Key Management Service (KMS) console.
In the navigation pane, choose "Customer managed keys".
Select the KMS key you want to modify.
Choose the "Key policy" tab, then "Switch to policy view".
Click "Edit".
Add the following statement to the existing policy JSON, ensuring it's inside the Statement array:
That's it! You've now given Nimble APIs permission to encrypt and decrypt objects, enabling access to encrypted buckets.
Please add Nimble's system/service user to your GCS or S3 bucket to ensure that data can be delivered successfully.
Response
Initial Response
Batch requests operate asynchronously, and treat each request as a separate task. The result of each task is stored in a file, and a notification is sent to the provided callback any time an individual task is completed.