Product Update: Spot Price API Endpoint and Instrument Selection Tool

April 23, 2019

Product Update: Spot Price API Endpoint and Instrument Selection Tool

The Kaiko team is pleased to introduce our new ‘Spot Price’ API endpointpowered by our intuitive instrument selection tool. Instrument selectionutilizes glob patterns, which can be used across multiple Kaiko data products, including our websocket, to efficiently select and filter data. This product update will explain how to use glob patterns to retrieve data from our ‘Spot Price’ endpoint and subscribe to our websocket data feeds.

Our ‘Spot Price’ endpoint is perfect for capturing real-time price snapshots of the entire cryptocurrency market, specific instruments across all exchanges, or specific exchanges. This endpoint retrieves the most recent price of all requested instruments that have actively traded within 24 hours. This endpoint is ideal for price display, real-time portfolio valuations, price analysis across exchanges, and more.

‘Spot Price’ functions through the use of glob patterns to filter and select data. Glob patterns are constructed from a set of parameters to form a single string, which can be passed in an API call to retrieve a highly specific group of instruments. Instruments can be selected and filtered by exchange, instrument class (spot vs. future), and instrument. The general format for passing a glob pattern is as follows:

pattern = <exchange>:<instrument_class>:<instrument>

For example, to retrieve the spot price of btc-usd from Coinbase, you would pass the pattern:

Cbse:spot:btc-usd

Kaiko’s instrument globbing allows for the use of wildcards, denoted by a *, to replace any parameter in the pattern. The use of a * will return all available instruments that encompass that parameter. For example, to retrieve all spot markets for Kraken, you would pass the pattern:

krkn:spot:*

To retrieve all spot btc-usd instruments trading on all exchanges covered by Kaiko, you would pass the pattern:

*:spot:btc-usd

To retrieve all instruments covered by Kaiko, you can use all three wildcards:

*:*:*

Wildcards can also be used inside a parameter within a pattern. For example, to retrieve all spot btc pairs trading on all exchanges, you would pass the pattern:

*:*:btc-*

You can also include more than one exchange or instrument in the pattern, upon which a cartesian product of patterns will be returned containing each element in the list. For example, the pattern:

Exchange1,exchange2:instrument_class:instrument1,instrument2

Will be equivalent to the union of 4 patterns:

pattern1=exchange1:instrument_class:instrument1
pattern2=exchange1:instrument_class:instrument2
pattern3=exchange2:instrument_class:instrument1
pattern4=exchange2:instrument_class:instrument2

Finally, multiple patterns can be combined with the ‘+’ operator:

Pattern = pattern1+pattern2

To return:

pattern1 = <exchange1>:<instrument_class1>:<instrument1>
pattern2 = <exchange2>:<instrument_class2>:<instrument2>

In addition to our ‘Spot Price’ API endpoint, glob patterns can be used to subscribe to our websocket data feeds for all instruments covered by Kaiko. Our websocket subscription endpoint allows the client to subscribe directly through the URL, using a glob pattern in the call. For example, if you wanted to subscribe to all btc-usd instruments on all exchanges covered by Kaiko, you would include the pattern: *:spot:btc-usd directly in the subscription call. The subscribed Data Feeds would be the intersection between the instruments specified in the glob pattern and the instruments that you have authorization for.

Glob patterns are a powerful tool to efficiently and quickly select specific instruments to return. Currently, glob patterns can be used in our ‘Spot Price’ API endpoint and to subscribe to our websocket data feeds. We also plan to implement glob patterns across a number of other data products in the near future.

To learn more about Kaiko’s ‘Spot Price’ endpoint, websocket, and glob patterns, browse our documentation. For information on our full instrument coverage, browse our public instrument explorer.

If you are interested in learning more about our data, please reach out at hello@kaiko.com.


Subscribe to our newsletter