Prices API Quickstart
This guide will help you fetch token prices via the Prices API.
Whether you’re building a DeFi protocol, portfolio tracker, or analytics tool, the Prices API provides simple endpoints for current and historical prices.
Endpoints
The Prices API includes the following REST endpoints:
Getting Started
Via HTTP Requests
Modern web development uses fetch for HTTP requests. The Prices API can be easily accessed using native fetch or any HTTP client library.
No Additional Installation Required
The fetch API is available in all modern browsers and Node.js (18+). For older Node.js versions, you can install node-fetch
:
Usage
Create a new JavaScript file (e.g., prices-fetch-script.js
) and add one of the following snippets depending on which endpoint you want to call.
Running the Script
Execute the script from your command line:
Expected Output:
Via Node Fetch
node-fetch
is a lightweight option for making HTTP requests with Javascript.
Installation
Install the node-fetch
package using npm
or yarn
:
Usage
Create a new JavaScript file (e.g., prices-fetch-script.js
) and add the following code.
Running the Script
Execute the script from your command line:
Expected Output: