Overview
API key trading allows you to execute trades on behalf of your main wallet using a separate API key wallet. This keeps your main wallet’s private key secure while enabling programmatic trading with bots and automated systems.Security
Your main wallet’s private key stays offline and secure. Only the API key is exposed to your trading bot.
Multiple Keys
Create multiple API keys for different bots or trading strategies while keeping your main wallet secure.
Easy Rotation
If an API key is compromised, simply revoke it and create a new one without affecting your main wallet.
Team Collaboration
Share API keys with team members or services without sharing your main wallet credentials.
How API Keys Work
Key Concepts:- Main Wallet: Holds your funds and positions (private key stays secure)
- API Key Wallet: Signs transactions on behalf of main wallet
- Authenticator: On-chain permission that links API key to main wallet
- Subaccount: The trading account where positions are held
Setting Up API Key Trading
1
Create API Key in Web Interface
Go to the LFG web interface to create your API key:
- Visit https://lfg.land
- Connect your main wallet
- Navigate to Settings → API Keys
- Click Create New API Key
- Download and save the private key - it will only be shown once
- Note the authenticator ID displayed
API keys have trading permissions only - they can place and cancel orders but cannot withdraw funds from your account.
2
Configure Your Bot
Use the private key from the website in your trading bot:
3
Get Authenticator ID
The authenticator ID is shown in the web interface when you create the API key. You can also retrieve it programmatically:
Configure Your Trading Bot
Set up your bot with the API key configuration:Placing Orders with API Keys
Complete Example
Here’s a complete example of placing an order using an API key:Key Differences from Regular Trading
The main difference when using API keys is creating the subaccount:- With API Key
- Without API Key
Security Best Practices
Secure Storage
Secure Storage
Never hardcode API keys:Use
.env files (add to .gitignore):Key Rotation
Key Rotation
Regularly rotate your API keys:
- Generate new API key
- Register new key in web interface
- Update bot configuration
- Test with small orders
- Revoke old key
- High-value accounts: Monthly
- Production bots: Quarterly
- Development: After major changes
Limit Exposure
Limit Exposure
API keys have trading-only permissions by design:
- Can do: Place and cancel orders
- Cannot do: Withdraw funds from your account
- Best practice: Create separate API keys for different bots or strategies
Monitor Activity
Monitor Activity
Regularly audit API key usage:
Environment Configuration
Production Setup
.env.production
Development Setup
.env.development
API keys only have trading permissions. For withdrawals or other sensitive operations, you must use your main wallet directly.
Troubleshooting
Authenticator not found
Authenticator not found
Problem: Error finding authenticator for API keySolutions:
- Verify API key is registered in web interface
- Check authenticator ID is correct
- Ensure API key wallet matches registered public key
- Wait a few blocks after registration
Permission denied
Permission denied
Problem: Transaction rejected due to insufficient permissionsSolutions:
- Verify the API key is properly registered
- Ensure authenticator is active (not revoked)
- Check that you’re using the correct authenticator ID
- Re-register API key if needed
API keys only have trading permissions. If you need to withdraw funds, use your main wallet directly.
Wrong subaccount
Wrong subaccount
Problem: Order placed in wrong subaccountSolution: Verify subaccount number in
SubaccountInfo:Advanced: Finding the Correct Authenticator
If you have multiple API keys, you need to find the right authenticator:Next Steps
Order Management
Learn more about placing and managing orders
Security Guide
Comprehensive security best practices
Wallet Management
Understand subaccounts and permissions
Error Handling
Handle common errors and edge cases