Avoltech's Website
Crypto Price API
The following is an API that takes get the crypto price data from Yahoo Finance.
The api takes 3 things as input:
- Name of the crypto currency
- Start Date (mm-dd-yyyy)
- 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 users2. 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 financeAPI 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.
Date | Open | High | Low | Close | Adj Close | Volume |
---|---|---|---|---|---|---|
30-08-2021 | 3227.19 | 3346.58 | 3151.44 | 3224.37 | 3224.37 | 19306924485 |
29-08-2021 | 3246.77 | 3283.24 | 3158.84 | 3227 | 3227 | 13296586731 |
28-08-2021 | 3275.1 | 3284.85 | 3217.4 | 3244.4 | 3244.4 | 13709633698 |
27-08-2021 | 3096.41 | 3281.84 | 3064.49 | 3270.6 | 3270.6 | 18489602004 |
26-08-2021 | 3228.75 | 3249.66 | 3060.23 | 3100.33 | 3100.33 | 17405668117 |
25-08-2021 | 3174.27 | 3248.73 | 3086.11 | 3224.92 | 3224.92 | 18902728235 |
24-08-2021 | 3324.86 | 3358.69 | 3154.12 | 3172.46 | 3172.46 | 20131028906 |
23-08-2021 | 3241.36 | 3373.38 | 3235.85 | 3319.26 | 3319.26 | 20511110509 |
22-08-2021 | 3226.23 | 3272.73 | 3142.01 | 3242.12 | 3242.12 | 15983278460 |
21-08-2021 | 3286.93 | 3307.35 | 3209.87 | 3226.08 | 3226.08 | 18113977628 |
20-08-2021 | 3182.16 | 3298.25 | 3178.1 | 3286.94 | 3286.94 | 20885619828 |
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