Authentication
The Market Data PHP SDK requires an API token to authenticate requests. You can obtain a token from the Market Data Dashboard.
Token Configuration
The SDK supports multiple methods for providing your API token, with the following priority order (highest to lowest):
- Explicit token parameter - Passed directly to the Client constructor
- Environment variable -
MARKETDATA_TOKEN - .env file - Using phpdotenv
- Empty string - For accessing free endpoints only
Setting the Environment Variable
- Mac/Linux
- Windows
Add to your shell profile (.bashrc, .zshrc, etc.):
export MARKETDATA_TOKEN="your_api_token_here"
Then reload your shell:
source ~/.bashrc # or source ~/.zshrc
Using Command Prompt:
setx MARKETDATA_TOKEN "your_api_token_here"
Using PowerShell:
[Environment]::SetEnvironmentVariable("MARKETDATA_TOKEN", "your_api_token_here", "User")
Using a .env File
Create a .env file in your project root:
MARKETDATA_TOKEN=your_api_token_here
The SDK automatically loads .env files using phpdotenv.