Write Your Own Crypto Price Feed API in 10 Minutes with Nomics and GraphQL
Updated: Jan 14, 2019
by Ron Gierlach, Developer, TokenSoft
Today’s crypto landscape can be daunting. As exchanges and tokens proliferate, keeping up with market data becomes a Sisyphean task.
The following sections give a simple guide to building an API that provides price feed data to your crypto-enabled application.
Nomics and Market Data
Accurately knowing the market price at any given time requires pulling from potentially dozens of exchange API’s and doing a few clever calculations.
Luckily, there is already a free service that has done the legwork for you.
Nomics keeps prices extremely up-to-date, re-calculating every 10 seconds and weighting 24 hour volumes across leading exchanges. For the extra curious, check out an in-depth explanation of Nomic’s pricing methodology.
Here’s what we’ll cover:
1- Setting up the GraphQL server with Node.js and NPM
2- Obtaining a free Nomics API key
3- Pulling (USD) price data from the Nomics API and caching the results
4- Exposing a GraphQL endpoint to query price data
Full source code for this example can be referenced here.
1. Setting Up the GraphQL Server
2. Obtaining a Free Nomics API Key
Head on over to Nomics’ pricing page and select their free tier.
Fill out and submit the registration form.
You should receive an email with your API key shortly!
3. Pulling Price Data From the Nomics API
If you’ve made it this far, congratulations!
We’ve covered setting up a GraphQL server with a cached exchange rate endpoint.
Next steps could include supporting fiat pairs other than USD. Additionally, Nomics’ dashboard endpoint is a great place to expand your API to support metrics such as 24-hour volume or price movement. All source code for the above example can be found here.