Authentication
Learn how to authenticate your API requests with Time4Boost.
API Keys
Time4Boost uses API keys to allow access to the API. You can obtain an API key by creating a free account on our website.
Request Headers
We expect the API key to be included in all API requests to the server in a header that looks like this:
X-API-Key: YOUR_API_KEY
Code Example
To authorize, use this code:
import { Time4BoostAPI } from "@time4boost/sdk";
// Initialize the SDK with your credentials
const api = new Time4BoostAPI({
apiKey: "YOUR_API_KEY",
authToken: "YOUR_AUTH_TOKEN"
});
// The SDK will automatically handle authentication
const teams = await api.nba.getTeams();
Make sure to replace YOUR_API_KEY and YOUR_AUTH_TOKEN with your credentials. You can obtain both by logging into your account.
Manual Request Example
If you're not using our SDK, you'll need to include the authentication headers manually:
const response = await fetch("https://api.time4boost.com/v1/teams", {
headers: {
"X-API-Key": "YOUR_API_KEY",
"Authorization": "Bearer YOUR_AUTH_TOKEN"
}
});
Authentication Requirements
All API requests require two forms of authentication:
- An API key (passed in the X-API-Key header)
- An authentication token (passed in the Authorization header as a Bearer token)
Example Headers
X-API-Key: YOUR_API_KEY
Authorization: Bearer YOUR_AUTH_TOKEN
Error Responses
If authentication fails, you will receive one of these error responses:
- Missing Authentication: Both the X-API-Key and Authorization headers are required
- Invalid API Key: The provided API key is not valid or has been revoked
- Invalid Auth Token: The provided authentication token is invalid or has expired