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.
Files
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.
Getting Started
Prerequisites
Python 3.x
requests library (install via pip install requests)
Setup
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
GitHub Actions
The GitHub Actions workflow is defined in .github/workflows/update_crypto_prices.yml. It is triggered every hour and performs the following steps:
Checks out the repository.
Sets up Python.
Installs the requests library.
Runs the fetch_crypto_prices.py script.
Commits and pushes the crypto_prices.json file to the repository.
If the workflow fails, it will retry after 5 minutes.
Usage
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.
Customization
If you want to fetch prices for different cryptocurrencies or use a different API, modify the fetch_crypto_prices.py script accordingly.
Crypto Prices Cache
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.
Files
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.Getting Started
Prerequisites
requestslibrary (install viapip install requests)Setup
Clone the repository:
Install the required Python packages:
Run the Python script to fetch the latest cryptocurrency prices:
GitHub Actions
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.
Usage
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.
Customization
If you want to fetch prices for different cryptocurrencies or use a different API, modify the fetch_crypto_prices.py script accordingly.