API versions

The API is available in two versions, 1 and 2. Both versions are available on every host. Each host has a default version that applies when a request does not select one.

Recommended: use API version 2 for all new applications, and migrate existing applications to it. Version 2 pages through large results more efficiently and needs fewer requests. See Migrating from version 1.

This page was requested using API version 1.

Selecting a version

Select the version with a /v1 or /v2 prefix in the path, for example:

https://consumer.qa.data.spglobal.com/v2/namespace/Entity/latest

Recommended: always use the /v1 or /v2 path prefix to select the version.

When no version is specified in the path, the default version of the host applies. The version can also be selected with the hidden v query parameter (1 or 2), though the path prefix takes precedence and is recommended.

Any other version is rejected with an error. Specify the version explicitly, because your application depends on version-specific behaviour.

Why version 2

Version 2 is designed around efficient paging through large results.

  • The server chooses the order. Sorting a large result page by page, in an order other than the internal order of the database, is slow. Reading the data in the internal order of the database is much faster. If your application needs the records in a particular order, sort them in your application after you have received them.
  • You do not have to choose the best order. The best order for a request depends on the entity, the filters and how the data is stored. Version 1 introduced sortBy=auto to let the server choose. In version 2 this is the only behaviour on the latest service, so sortBy is not needed there.
  • The position of the next page is given explicitly. Because the order is chosen by the server, the position of the next page cannot be derived from the last record of a response. The server returns it as the after value instead. To make that value easy to find, the envelope that carries it is on by default. The value is opaque, so that applications use it exactly as returned and do not depend on its content.
  • One request less per result. In version 1 the last page of a result is usually followed by a request that returns no records. In version 2 after is only returned when more records can follow, so the absence of after tells you that you have everything, without an extra request.

Differences between versions

BehaviourVersion 1Version 2
envelopeOff unless envelope=true.On unless envelope=false.
after returned for latest, timeseries and batchrunWith every response that contains records. The next response can be empty.Only when the page is full, that is when more data can follow.
Format of afterReadable.Opaque. Use the value exactly as returned.
sortBy on latestSupported, including auto.Not supported: the order is always chosen automatically. Use rankBy to return top results sorted by a field.
sortBy on timeseriesSupported, including auto.A named sort order is supported; auto is not, because the order is chosen automatically when sortBy is absent.
Filter of a timeseries on the latest value of a fieldPlain field name.Prefix the field with latest..
stream message typesBATCH_RUN_EVENT and EMPTY.The underlying event names, for example BATCHRUN_START, BATCHRUN_COMPLETE and BATCHRUN_CANCEL.
Default dateFormatISO8601 (dates include Z, for example YYYY-MM-DDZ).ISO8601-2 (dates have no time zone, for example YYYY-MM-DD).

Migrating from version 1

  1. Select version 2 explicitly with the /v2 path prefix, so that a change of the host default does not affect your application.
  2. Remove sortBy from latest requests, including sortBy=auto; version 2 refuses it. Use rankBy if you need the top results sorted by a field. On timeseries requests, remove sortBy=auto and keep a named sort order only if S&P Global advised it.
  3. Sort in your application if you depend on the order of the records. Do not rely on the order in which the server returns them.
  4. Read the envelope. Read the data from the field named after the service (for example latest) and the after value from the envelope. If you parsed a plain JSON array, either adapt the parser or set envelope=false, but then you cannot page.
  5. Treat after as opaque. Pass it back exactly as returned. Do not store it beyond the paging of one result, construct it, or compare it.
  6. Stop paging when after is absent. Do not request another page after a response without after.
  7. Prefix latest filters on timeseries requests with latest., for example latest.country=NL. See timeseries.
  8. On the stream, handle the version 2 message types, such as BATCHRUN_START and BATCHRUN_COMPLETE, instead of BATCH_RUN_EVENT.
  9. Check date parsing. Version 2 defaults dateFormat to ISO8601-2 (YYYY-MM-DD), without the trailing Z that version 1 includes (ISO8601, YYYY-MM-DDZ). Set dateFormat=ISO8601 if your application expects the version 1 format.

A client that always sets envelope=true, always follows after, and stops when after is absent or the page is empty works with both versions. That makes it possible to migrate step by step.