Calls Covalent API to get token quotes for a list of crypto wallet addresses
Project description
Token Quotes
Token Quotes is a Python package for fetching and processing cryptocurrency token balances and quotes for a list of wallet addresses that you provide. It interacts with the Covalent API to retrieve token data, process it, and save it in a structured format.
Features
- Fetch token balances for specified wallet addresses across different blockchains
- Process and structure token balance data
- Save processed data in csv format
- Command-line interface for easy data retrieval and processing
Installation
Using pip
pip install token-quotes
Using poetry
poetry add token-quotes
Docker
docker build -t token-quotes .
Usage
As a Python package
import os
from report_builder import fetch_token_balances, save_to_jsonlines, extract_data, save_to_csv
COVALENT_API_KEY = os.getenv("COVALENT_API_KEY", default="")
wallets = [{"address": "0x123", "chain_id": "eth-mainnet"}]
raw_token_balances = fetch_token_balances(wallets, COVALENT_API_KEY, "usd")
save_to_jsonlines(raw_token_balances, "/tmp/raw_token_balances.jsonl")
data = extract_data("/tmp/raw_token_balances.jsonl")
save_to_csv(data, "output_file.csv")
Command-line interface
Using json formatted string
token-quotes '{"wallets": [{"address": "0x123", "chain_id": "eth-mainnet"}]}' -o output.csv --currency usd --api-key $COVALENT_API_KEY
Using YAML input
token-quotes input.yml -o output.csv --currency usd --api-key $COVALENT_API_KEY
Example input YAML (also accepts csv and json)
wallets:
- address: "0x04692B7Df6128b5704750D21416c5fb90Df3fFfd"
chain_id: "eth-mainnet"
nickname: "DEFAULT"
provider: "metamask"
Using Docker
docker run -v /path/to/your/local/directory:/app/data token-quotes:latest input.yml -o output.csv --currency usd --api-key $COVALENT_API_KEY
This command mounts your local directory to the /app/data directory in the container. Adjust the paths as necessary.
Example
docker run -v $HOME/Dropbox:/app/data token-quotes:latest input.yml -o output.csv --currency usd --api-key $COVALENT_API_KEY
To run the help message
docker run token-quotes:latest --help
Development
To set up the development environment:
Clone the repository:
git clone https://github.com/zaxier/token-quotes.git
cd token-quotes
Install dependencies:
poetry install
Run tests:
poetry run pytest
Configuration
Set your Covalent API key as an environment variable:
export COVALENT_API_KEY=your_api_key_here
Logging
Logs are saved in the /app/logs directory. When running the Docker container, mount this directory to persist logs:
docker run -v /path/to/your/logs:/app/logs ...
References
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for token_quotes-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af9fc34ecc23a330376e1fdf2b0e4c8ced34b7bf4a8b234aca7ac0faec007d17 |
|
MD5 | bae0b5a03c28c886407f2b5464515404 |
|
BLAKE2b-256 | a183ce54542d4dea6c8e6b6cef68a163cca72da53908978cbb565ad35990493f |