目录

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

  • Python 3.x
  • requests library (install via pip install requests)

Setup

  1. Clone the repository:

    git clone git@github.com:fantomstarterio/crypto-prices-cache.git
    cd crypto-prices-cache
  2. Install the required Python packages:

    pip install requests
  3. 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:

  1. Checks out the repository.
  2. Sets up Python.
  3. Installs the requests library.
  4. Runs the fetch_crypto_prices.py script.
  5. 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.

关于
7.4 MB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号