A Simple Use Case
To demonstrate the usage of the API, let us show how to retrieve the latest price of the AAVE token.
curl \
-H 'Authorization: Bearer <API KEY>' \
https://gateway.credmark.com/v1/tokens/1/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9/price
We only need to pass one value in the request header, our API Key.
The request URL construction is straightforward. These are the path segments, in order, and their meaning:
Segment | Meaning |
---|---|
v1 | The API version |
tokens | The API name |
1 | The Chain ID, in this case, Ethereum mainnet |
0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9 | The address of the AAVE token contract |
price | The requested resource, in this case, the price |
The price endpoint of the Token API will give you a response like this:
{
"chainId": 1,
"blockNumber": 15409335,
"blockTimestamp": 1661434010,
"tokenAddress": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9",
"quoteAddress": "0x0000000000000000000000000000000000000348",
"price": 89.52673237,
"protocol": "cex",
"src": "price.quote:cached"
}
Our response body includes the full context of the data we requested, i.e., the price:
Field | Value | Meaning |
---|---|---|
chainID | 1 | The Chain ID, in this case, Ethereum mainnet |
blockNumber | 15409335 | This is the block number for which the price is valid. By not requesting the price for a specific block number, we implicitly asked for the latest available. For technical reasons our data is always a few blocks behind real time. |
blockTimestamp | 1661434010 | This is the timestamp (number of seconds since January 1st, 1970) associated with the block above. |
tokenAddress | 0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9 | The address of the AAVE token contract |
quoteAddress | 0x0000000000000000000000000000000000000348 | The address of the token or pseudo-token in which the price is quoted. In this case, the value represents the fiat currency USD. |
price | 89.52673237 | 1 AAVE token was worth 89.52673237 USDs at block 15409335 |
protocol | cex | For this request, the price source was Chainlink. The other possible value, "dex", would mean that the price was derived from onchain data, specifically DEX liquidity pools and transactions. |
src | price.quote:cached | This tells us that the result was pulled from cache. This value is only useful to someone doing performance analysis. |
Last modified 10mo ago