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
Pull from DockerHub
docker pull zaxier/token-quotes:latest
Or clone and build locally
docker build -t token-quotes .
Configuration
Set your Covalent API key as an environment variable:
export COVALENT_API_KEY=your_api_key_here
Usage
Input file
Example input YAML
wallets:
- name: "MetaMask"
metadata:
details: "A MetaMask wallet with multiple addresses secured by a single seed phrase. MetaMask wallet can secure addresses multiple blockchains."
provider: "MetaMask - https://metamask.io/"
access: "Get metamask browser extension. Input the seed phrase to access the wallet."
addresses:
- address: "0x123"
chain_ids: ["eth-mainnet", "arbitrum-mainnet"]
owner: "me"
purpose: "personal"
- address: "0x456"
chain_ids: ["eth-mainnet", "matic-mainnet"]
owner: "someone else"
purpose: "personal"
- name: "wallet 2"
metadata: ...
addresses: ...
Command-line interface
token-quotes input.yml -o output.csv --currency usd --api-key $COVALENT_API_KEY
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")
wallets = [
{
"name": "Main Wallet",
"metadata": {"key": "value"},
"addresses": [
{
"address": "0x1234",
"owner": "me",
"purpose": "personal",
"chain_ids": ["eth-mainnet", "arbitrum-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")
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
# Set vars
# LOGS_DIR=''
# ...
docker run \
-v $LOGS_DIR:$LOGS_DIR -v $INPUT_FILE_DIR:$INPUT_FILE_DIR -v $OUTPUT_FILE_DIR:$OUTPUT_FILE_DIR \
zaxier/token-quotes:latest $INPUT_FILEPATH \
-o $OUTPUT_FILEPATH \
--api-key $COVALENT_API_KEY \
--log-dir $LOGS_DIR \
--debug
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
Logging
(Optional) 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
Metadata
Release files for token-quotes 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| token_quotes-0.4.0.tar.gz | 10.4 kB | Without provenance | Details for token_quotes-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| token_quotes-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for token_quotes-0.4.0-py3-none-any.whl |
Total release size: 21.8 kB
Release files / token_quotes-0.4.0.tar.gz
| Download URL | token_quotes-0.4.0.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e24702637552153f65380e46362b886b85b25d8765ca73a15ac6fdf33a186b12
|
|
BLAKE2b-256 checksum How to use checksums |
122b1043236f45de71b62f899c3638fa00c6286a51961e7db999109b9921b100
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.6 Linux/6.8.0-1014-azure
|
Release files / token_quotes-0.4.0-py3-none-any.whl
| Download URL | token_quotes-0.4.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
739947071763ea350b0c4d8ca632bd62be9fb3c80eb34f4116d82a00f39ce44b
|
|
BLAKE2b-256 checksum How to use checksums |
d9ae2de9ba85d098fc8b743aea3d469d840e4889b09c20b81ea8934faf60d6cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.6 Linux/6.8.0-1014-azure
|
Security for token-quotes 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.