AltSportsData

Authentication

Learn how to authenticate with the AltSportsData API

Authentication

All API requests require authentication. The AltSportsData API uses API keys delivered via HTTP headers.

Getting Your API Key

Contact the AltSportsData team to obtain production API credentials:

For testing, use a demo key matching the pattern demo-xxxx (e.g., demo-test123). Demo keys provide access to a curated subset of ~50 verified leagues with rate limits applied.

Authentication Methods

Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

2. X-API-Key Header

Alternatively, use the X-API-Key header:

X-API-Key: YOUR_API_KEY

Both methods are equivalent. Choose whichever fits your HTTP client best.

Example Requests

import { AltSportsData } from 'altsportsdata';

// SDK handles authentication automatically
const client = new AltSportsData({
  apiKey: process.env.ASD_API_KEY,
});

const health = await client.health();
console.log(health.data.status); // "healthy"
from altsportsdata import AltSportsData

# SDK handles authentication automatically
client = AltSportsData(api_key="YOUR_API_KEY")

health = client.health()
print(health.data["status"])  # "healthy"
# Using Bearer token
curl -X GET "https://api.altsportsdata.com/v1/health" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Or using X-API-Key header
curl -X GET "https://api.altsportsdata.com/v1/health" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch("https://api.altsportsdata.com/v1/health", {
  headers: {
    "Authorization": "Bearer YOUR_API_KEY"
  }
});

const data = await response.json();
console.log(data);
require 'net/http'
require 'json'

uri = URI('https://api.altsportsdata.com/v1/health')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'

response = http.request(request)
puts JSON.parse(response.body)
<?php
$ch = curl_init('https://api.altsportsdata.com/v1/health');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_KEY'
]);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);

print_r($data);
?>
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");

var response = await client.GetStringAsync("https://api.altsportsdata.com/v1/health");
Console.WriteLine(response);
req, _ := http.NewRequest("GET", "https://api.altsportsdata.com/v1/health", nil)
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")

resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()

body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
URL url = new URL("https://api.altsportsdata.com/v1/health");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Authorization", "Bearer YOUR_API_KEY");

BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = in.readLine()) != null) response.append(line);
in.close();

System.out.println(response.toString());

Error Responses

Status CodeDescription
401 UnauthorizedMissing or invalid API key
403 ForbiddenAPI key does not have access to the requested resource
429 Too Many RequestsRate limit exceeded

Security Best Practices

  • Never expose API keys in client-side code or public repositories
  • Use environment variables to store API keys (ASD_API_KEY)
  • Rotate keys regularly for enhanced security
  • Use HTTPS only — all API requests are served over TLS (enforced)
  • Restrict key scope — use demo keys for development, production keys for live traffic

Demo vs Production Keys

FeatureDemo Key (demo-xxxx)Production Key
Access~50 curated leaguesAll leagues
Rate LimitRestrictedBased on plan
Real-time DataNoYes
WebSocket AccessNoYes
SupportCommunityDedicated

Need Help?

For API access, technical support, or partnership inquiries, contact connect@altsportsdata.com.

On this page