- Overview
- Installation
- Authentication
- Market Data Methods
- CopyBot Methods
- Utility Methods
- Example Usage
The Moon Dev Market Data API (src/agents/api.py
) provides access to real-time market data. The API is designed to be easy to use while providing powerful features for market analysis and automated trading.
- Ensure you have the required dependencies:
pip install requests pandas python-dotenv termcolor
- Set up your environment variables:
# Create a .env file and add your Moon Dev API key
MOONDEV_API_KEY=your_api_key_here
The API uses an API key for authentication. This key should be stored in your .env
file and will be automatically loaded when initializing the API client.
from src.agents.api import MoonDevAPI
# Initialize the API client
api = MoonDevAPI() # Automatically loads API key from .env
# Get all liquidations
liq_data = api.get_liq_data()
# Get liquidations for specific symbol
btc_liq_data = api.get_liq_data(symbol="BTC", limit=100000)
# Get all funding rates
funding_data = api.get_funding_rate()
# Get funding rate for specific symbol
btc_funding = api.get_funding_rate(symbol="BTC")
# Get symbol-specific open interest
oi_data = api.get_open_interest(symbol="BTC")
# Get total market open interest
total_oi = api.get_open_interest(total=True)
# Get latest token launches
new_tokens = api.get_new_token_addresses()
# Get current copy trading follow list
follow_list = api.get_copybot_follow_list()
# Get recent copy trading transactions
recent_txs = api.get_recent_transactions()
# Get list of all available data files
available_files = api.list_available_files()
Here's a complete example showing how to use the API:
from src.agents.api import MoonDevAPI
import time
# Initialize API
api = MoonDevAPI()
# Get BTC data
symbol = "BTC"
# Market Data
liq_data = api.get_liq_data(symbol)
funding_data = api.get_funding_rate(symbol)
oi_data = api.get_open_interest(symbol)
# CopyBot Data
follow_list = api.get_copybot_follow_list()
recent_txs = api.get_recent_transactions()
# List available files
api.list_available_files()
By default, all data is saved to src/agents/api_data/
. The following files are created:
liq_data.csv
: Liquidation datafunding.csv
: Funding rate dataoi.csv
: Open interest dataoi_total.csv
: Total market open interestfollow_list.csv
: Copy trading follow listrecent_txs.csv
: Recent copy trading transactions
The API includes built-in error handling and will:
- Print colored error messages for easy debugging
- Return
None
if an API call fails - Create data directories automatically
- Validate API responses
- Never share or commit your API key
- Data is automatically saved to the
api_data
directory - All methods include error handling and logging
- The API uses colorful console output for better visibility
- Rate limiting is handled automatically
Built with 🌙 by Moon Dev - Making trading data accessible and beautiful