batchrun

Batches and batch runs

Some datasets are published in batches. A Batch represents a recurring publication, identified by its id. A BatchRun is one occurrence of a batch: for a daily batch a new batch run is created each day. A BatchRun has an id that identifies the run, a batch field that refers to its Batch and an asOf date.

Batches and batch runs are entities that you can read with the latest service:

https://consumer.qa.data.spglobal.com/namespace/Batch/latest
https://consumer.qa.data.spglobal.com/namespace/BatchRun/latest

To find recent batch runs, filter on asOf:

https://consumer.qa.data.spglobal.com/namespace/BatchRun/latest?asOf>=2017-03-04Z

Reading the records of a batch run

https://consumer.qa.data.spglobal.com/namespace/Entity/BATCH_RUN_ID/batchrun?limit=1000

returns the records of Entity that were published in the batch run with the given id. The response is always an envelope:

{
  "batchrun": [...],
  "requestId": "A011.1598447117.14",
  "timeToFirstWrite": 2,
  "after": "19101427"
}
FieldDescription
batchrunThe records of the batch run.
requestIdAdd it to your logs to correlate your requests with the server logs.
timeToFirstWriteThe time in milliseconds the server needed before it started to send the response.
afterThe value for the after parameter of the request for the next page.

Use limit and after to page through the records. Without a limit up to 100,000 records are returned. Stop when the response contains no records or no after value.

To retrieve batches as they are published, poll the BatchRun entity for new runs. When a new BatchRun id appears, request the data of that run with the URL above.

Listing the batch runs of an entity

https://consumer.qa.data.spglobal.com/namespace/Entity/batchruns?limit=10&descending=true

lists the batch runs that contain data for the entity. Results are in ascending order of asOf, so use descending=true to get the most recent first. Each batch run has the fields id, batch, publicationMode, asOf, count, publishTime and incrementFrom.

You can restrict the list with batch, mode and id (a list of batch run ids), and with from and to, which are bounds on asOf. limit and after page through the list, and with envelope=true the response is an envelope that contains after.

batchrun compared to timeseries

Both services give access to historical data, with important differences:

  1. The data of the timeseries service can be available slightly later than that of the batchrun service.
  2. Data can be downloaded faster from the batchrun service.
  3. When a batch run is republished for the same asOf, its records overwrite the matching records of the first run in the time series. The timeseries service therefore only provides the full results of the most recent run for an asOf, while the batchrun service provides the full results of every run.

Important: The data of a batch run is immutable. It is not updated for later corrections or enhancements. The timeseries service shows the most correct and most enhanced record available for each point in time.

For a batch run that is an increment of earlier runs, aggregateIncrementFrom=true returns the combined records of the whole chain.

The statusIdentifier field of the BatchRun entity must not be used in application logic.