API Keys¶
To use the PyTally SDK, you need a Tally API key. This guide explains how to obtain and use your API key securely.
Getting Your API Key¶
- Log in to Tally: Go to tally.so and sign in to your account
- Navigate to Settings: Click on your profile and select Settings
- Access API Keys: Go to the API Keys section
- Create New Key: Click "Create API key"
- Name Your Key: Give your key a descriptive name (e.g., "Production App", "Development")
- Copy the Key: Copy the generated API key immediately - you won't be able to see it again!
Keep Your API Key Secure
Your API key provides access to your Tally account and data. Never commit it to version control or share it publicly.
Using Your API Key¶
Basic Usage¶
Pass your API key when initializing the client:
Environment Variables (Recommended)¶
Store your API key in environment variables for better security:
Create a .env file in your project root:
Then load it using python-dotenv:
Troubleshooting¶
Invalid API Key Error¶
If you receive an UnauthorizedError:
Solutions:
- Verify the API key is correct (copy-paste from Tally dashboard)
- Check that you haven't accidentally included spaces or newlines
- Ensure the environment variable is properly loaded
- Verify the key hasn't been revoked in the Tally dashboard
Environment Variable Not Loading¶
# Debug environment variables
import os
print(f"TALLY_API_KEY exists: {bool(os.getenv('TALLY_API_KEY'))}")
print(f"TALLY_API_KEY value: {os.getenv('TALLY_API_KEY', 'NOT SET')}")
API Key Format¶
Tally API keys follow this format:
Example: tly_abc123def456ghi789
Next Steps¶
- 📖 API Reference - Explore available endpoints
- ⚠️ Error Handling - Handle authentication errors
- 🏠 Home - Return to documentation home