A Python application that queries the CoinGecko API to fetch daily cryptocurrency data, stores the raw data in BigQuery, and calculates metrics such as moving averages using SQL in BigQuery. The application is automatically deployed to Cloud Run and executed daily with Google Cloud Scheduler.
- Cloud Run executes the Python app daily.
- The app queries the CoinGecko API and retrieves cryptocurrency information.
- Raw data is inserted into BigQuery (
crypto_raw.market_history) - Metrics such as moving averages are calculated in BigQuery using SQL.
- Final metric tables are stored in the dataset
crypto_analytics.market_history_analytics. - Google Cloud Scheduler triggers the daily execution.
- API keys and project ID are securely stored in Secret Manager.
- Python 3.x
- Google Cloud Platform:
- BigQuery
- Cloud Run
- Cloud Scheduler
- Secret Manager
- Python Libraries:
requestsFlaskgoogle-cloud-bigquerygoogle-auth
- Clone the repository:
git clone https://github.com/username/crypto-data-pipeline.git
cd crypto-data-pipeline
## Environment variables
API_KEY=xxx
PROJECT_ID=xxx
## Local Development with Docker
This project is designed to run inside a Docker container. To run it locally:
1. Build the Docker image:
```bash
docker build -t crypto-data-pipeline .
docker run -e API_KEY="your_api_key" -e PROJECT_ID="your_project_id" crypto-data-pipeline