This project fetches cryptocurrency prices (Bitcoin, Ethereum, and DAI) from a public crypto prices API every hour and commits the data to this repository. It uses GitHub Actions to automate the process.
fetch_crypto_prices.py
: A Python script that fetches the latest cryptocurrency prices and saves them to a JSON file..github/workflows/update_crypto_prices.yml
: A GitHub Actions workflow that runs the Python script every hour and commits the changes.requests
library (install via pip install requests
)Clone the repository:
git clone git@github.com:fantomstarterio/crypto-prices-cache.git
cd crypto-prices-cache
Install the required Python packages:
pip install requests
Run the Python script to fetch the latest cryptocurrency prices:
python fetch_crypto_prices.py
The GitHub Actions workflow is defined in .github/workflows/update_crypto_prices.yml. It is triggered every hour and performs the following steps:
If the workflow fails, it will retry after 5 minutes.
You can use the raw crypto_prices.json file in your application to get the latest cryptocurrency prices without hitting the public API directly. This helps to avoid rate limiting issues.
If you want to fetch prices for different cryptocurrencies or use a different API, modify the fetch_crypto_prices.py script accordingly.