Prices API Quickstart
A new developer’s guide to fetching current and historical token prices via the Prices API.
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 Alchemy SDK
The Alchemy SDK provides a convenient and fully featured way to interact with Alchemy’s APIs, including the Prices API.
Installation
Install the alchemy-sdk
package using npm
or yarn
:
Usage
Create a new JavaScript file (e.g., prices-alchemy-sdk-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:
API Reference
For more details on the available Prices API methods, check out the docs: