Authentication
Authenticate every request with your Trendtracker Connect API key.
The Connect API supports API-key authentication using the x-api-key header.
If you do not have an API key yet, ask the Trendtracker team for access.
Required Header
x-api-key: YOUR_API_KEYSet Your API Key Locally
Use an environment variable so you do not hardcode secrets in scripts or source files.
export TT_API_KEY="your_api_key_here"To persist it in zsh, add the same line to your ~/.zshrc and restart your shell.
Security best practices:
- Store API keys in environment variables or a secret manager.
- Never commit API keys to git repositories.
- Never include API keys in URL query parameters.
Verify Authentication
Run a simple authenticated request:
curl -s "https://connect-api.trendtracker.ai/topics?query=aviation&take=1" \
-H "x-api-key: $TT_API_KEY"If authentication is configured correctly, the API returns a 200 OK response with JSON content.
JavaScript Example
const response = await fetch(
"https://connect-api.trendtracker.ai/topics?query=aviation&take=10",
{
headers: {
"x-api-key": process.env.TT_API_KEY,
},
}
);
const data = await response.json();
console.log(data);Common Mistakes
- Missing
x-api-keyheader -> request is rejected. - Typo in header name (
x_api_key,api-key, etc.) -> request is rejected. - Sending key in query params -> unsupported and insecure.
- Exposing your API key in frontend code -> insecure. Keep requests server-side.