Overview
The Axion SDK uses API key authentication to secure access to financial data endpoints. This guide covers how to obtain, configure, and manage your API keys.Getting Your API Key
Generate an API key
Navigate to your account dashboard and generate a new API key for your application.
Basic Authentication
Initialize the Axion client with your API key:- Adds an
Authorizationheader to all requests - Uses the format:
Bearer your-api-key-here - Validates authentication before making requests
Environment Variables
The recommended approach is to store your API key in environment variables:Authentication Flow
Here’s how the SDK handles authentication internally:Authentication Requirements
The SDK automatically determines whether authentication is required for each endpoint:Most endpoints require authentication. When an API key is required but not provided, the SDK throws an error:
"Authentication required but no API key provided to client."Error Handling
The SDK provides clear error messages for authentication issues:Common Authentication Errors
Cause: Trying to access an authenticated endpoint without providing an API key.Solution: Initialize the client with your API key:
new Axion('your-api-key')Cause: Invalid or expired API key.Solution: Verify your API key is correct and hasn’t been revoked. Generate a new key if needed.
Cause: Valid API key but insufficient permissions for the requested resource.Solution: Check your account permissions or upgrade your plan.
Security Best Practices
Use Environment Variables
Use Environment Variables
Always store API keys in environment variables, never hardcode them:
Separate Keys for Development and Production
Separate Keys for Development and Production
Use different API keys for development, staging, and production environments:
Rotate Keys Regularly
Rotate Keys Regularly
Periodically rotate your API keys to maintain security:
- Generate a new API key
- Update your application’s environment variables
- Deploy the changes
- Revoke the old API key
Monitor API Key Usage
Monitor API Key Usage
Keep track of:
- Request volume per API key
- Unusual access patterns
- Failed authentication attempts
- Geographic origin of requests
Restrict Key Permissions
Restrict Key Permissions
If the platform supports it, create API keys with limited scopes:
- Read-only keys for data retrieval
- Separate keys for different services
- Time-limited keys for temporary access
Advanced Configuration
Custom Headers
The SDK automatically manages the Authorization header, but you can access the underlying axios client for advanced configuration:Multiple Clients
You can create multiple client instances with different API keys:Testing Without Authentication
For development and testing with a local server that doesn’t require authentication:Authentication Source Code
Here’s how authentication is implemented in the SDK (from src/index.ts:389-400, 422-435):Next Steps
Quick Start Guide
Start building with authenticated API requests
API Reference
Explore all available endpoints
Error Handling
Learn how to handle authentication errors
FAQ
Common questions about API usage