Submitting a batch request
The Batch Geocoder API provides the resource jobs
, which allows you to submit batch geocoding and reverse geocoding requests. Your initial submission must conform with the following Input Data guidelines. You can use the optional input fields to provide additional information to control how the job is run. The Batch Geocoder API handles the geocoding and reverse geocoding asynchronously. For more information on the lifecycle of a request, see Request lifecycles and jobs. For an example of how to request the results of a job, see Get job results.
To retrieve the output of a successful batch request, you must follow the steps below:
- Upload your data with a POST request to the resource
jobs
. - Using the
RequestId
value contained in the response to your data upload request, check the status of the job with a GET request. You can only download the results when the job status iscompleted
- Using the
RequestId
value contained in the response to your data upload request, download the results by sending a GET request.
When you submit a request with wget
or cURL
, check the field names (for example &outCols=recId,…
) and the field delimiter in the request for both the input and the output. wget
and cURL
return the response "400 Bad Request" if there is a issue or when the delimiter does not match the delimiter in the input file. Both wget
and cURL
need a content type to be specified in the header. Uploading compressed address data is currently not supported.
wget
wget
use the header Content-Type: text/plain
Example of a geocoding request:
wget --header="Content-Type: text/plain; charset=UTF-8" --post-file=addresses.txt
"https://batch.geocoder.ls.hereapi.com
/6.2/jobs?
&apiKey={YOUR_API_KEY}
&action=run
&header=true
&inDelim=;
&outDelim=,
&outCols=recId,latitude,longitude,locationLabel
&outputcombined=true
&language=de-DE"
Note that to submit a batch reverse geocoding request, the input file needs to contain a set of locations defined in terms of geographic coordinates and the request must include the parameter mode
set to retrieveAddresses
:
wget --header="Content-Type: text/plain; charset=UTF-8" --post-file=locations.txt
"https://batch.geocoder.ls.hereapi.com
/6.2/jobs?
&apiKey={YOUR_API_KEY}
&action=run
&header=true
&inDelim=;
&outDelim=,
&outCols=recId,latitude,longitude,locationLabel
&outputcombined=true
&language=de-DE
&mode=retrieveAddresses"
cURL
cURL
, be sure to add the following header Content-Type: text/plain
and submit the payload using the --data-binary
parameter. Example of a geocoding request:
curl -X POST -H "Content-Type: text/plain" --data-binary @addresses.txt
"https://batch.geocoder.ls.hereapi.com
/6.2/jobs?
&apiKey={YOUR_API_KEY}
&action=run
&header=true
&inDelim=;
&outDelim=,
&outCols=recId,latitude,longitude,locationLabel
&outputcombined=true
&language=de-DE"
Note that to submit a batch reverse geocoding request, the input file needs to contain a set of locations defined in terms of geocgraphic coordinates and the request must include the parameter mode
set to retrieveAddresses
:
curl -X POST -H "Content-Type: text/plain" --data-binary @locations.txt
"https://batch.geocoder.ls.hereapi.com
/6.2/jobs?
&apiKey={YOUR_API_KEY}
&action=run
&header=true
&inDelim=;
&outDelim=,
&outCols=recId,latitude,longitude,locationLabel
&outputcombined=true
&language=de-DE
&mode=retrieveAddresses"