Avoltech's Website
Avoltech's Website

Avoltech's Website

Crypto Price API




image
Image Credit: https://pixelz.cc/

The following is an API that takes get the crypto price data from Yahoo Finance.
The api takes 3 things as input:

  1. Name of the crypto currency
  2. Start Date (mm-dd-yyyy)
  3. End Date (mm-dd-yyyy)

Technologies used:
  • Flask (Python Framework)
  • Heroku (Cloud Deployment)
  • Beautiful Soup (Web Scraping Library)


How does the API work?

1. The API takes the inputs from users
2. Converts the dates into unix format
3. Uses these newly converted dates as arguments to Yahoo Finance url
4. Scrape the price data using Beatuiful Soup
5. Converts and returns the prices in JSON format

API 1:

/getNames

Usage:
https://crypto-api-yf.herokuapp.com/getNames
==> Returns a list of crypto supported by yahoo finance


API 2:
/getData?name=<insert_crypto_name_here>&start=<insert_start_date_here>&end=<insert_end_date_here>

Example:
https://crypto-api-yf.herokuapp.com/getData?name=ETH&start=08-20-2021&end=08-30-2021
==> Returns daily crypto data'


Call API 1 to get the list of cryptos before calling API 2.

Here, is what the output can be if the JSON output is turned into a table.

DateOpenHighLowCloseAdj CloseVolume
30-08-20213227.193346.583151.443224.373224.3719306924485
29-08-20213246.773283.243158.843227322713296586731
28-08-20213275.13284.853217.43244.43244.413709633698
27-08-20213096.413281.843064.493270.63270.618489602004
26-08-20213228.753249.663060.233100.333100.3317405668117
25-08-20213174.273248.733086.113224.923224.9218902728235
24-08-20213324.863358.693154.123172.463172.4620131028906
23-08-20213241.363373.383235.853319.263319.2620511110509
22-08-20213226.233272.733142.013242.123242.1215983278460
21-08-20213286.933307.353209.873226.083226.0818113977628
20-08-20213182.163298.253178.13286.943286.9420885619828


You can find the call the api from here:
Sample Link:
https://crypto-api-yf.herokuapp.com/getData?name=BTC&start=08-20-2021&end=09-01-2021
(gets daily time frame Bitcoin price data: open, low, high, close, adjusted close, volume) (between 20/08/2021 to 1/09/2021)


Note: This is hosted on free version of Heroku Cloud, hence may take longer to run inital (about 10-20 seconds)

GitHub Link: https://github.com/Avoltech/CryptoPriceApi