Several endpoints permit batch requests, allowing you to submit numerous searches or calculations in a single HTTPS exchange. This is an efficient way to carry out large tasks because most of the latency on a request arises from the transport of the packets between client and server.

According to your subscription tier, you can use the /footprint-<tier>/batch POST endpoint to submit multiple requests.

A maximum of 50 requests can be processed in a single batch: If you submit a larger batch, only the first 50 will be processed, and the rest will be ignored.

The request body must be an array. Each entry must be an otherwise well-formed request for the base endpoint, plus an id parameter that is unique among the entries in the batch. Requests without an id will not be processed.

The body of the return request will also be an array with the results in the same order as the incomi batch. If a single member of the batch of requests fails for some reason, the respective response entry will contain an error message, but the overall response will still return a 200 (OK) status code. It is advised to validate each response to a batch query.

Example

In the following example, the first two requests are well-formed, but the last is missing the required ID field.

# this would be passed in the request body
[{'id': 'req1',
  'activityID': 'wheat',
  'impactCategory': ['Water_stress_Agriculture_water_stress',
   'Land_use_Extensive_forestry'],
  'country': 'India'},
 {'id': 'req2',
  'activityID': 'rice',
  'country': ['China', 'India'],
  'scope': 'Scope_3_BP',
  'year': 2021},
 {**'id': None,**
  **'activityID': 'wheat',
  'impactCategory': ['Water_stress_Agriculture_water_stress',
   'Land_use_Extensive_forestry'],
  'country': 'India'}]**

The response to the batch request will include a status code of 200 but highlight the error in the returned body:

[{'id': 'req1', 'num_records': N1, 'records': [...]},
 {'id': 'req2', 'num_records': N2, 'records': [...]},
 {'id': None,
  'error': 'BadRequestError',
  'description': 'Requests in a batch need an ID'}]