Authorization
Important: API tokens are sensitive and must be kept secret. Do not share or expose your token in frontend code or public code repositories.
Some Random API provides a wide variety of endpoints, many of which do not require an API token. However, certain endpoints—especially those with higher rate limits or more powerful functionality—require authentication using an API token.
To access these endpoints:
- You must include an
Authorization
header in your HTTP request. - The value should be only the API token you generate from the SRA Dashboard (opens in a new tab).
- Do not prepend the token with
"Bearer "
or any other prefix.
If you're using a legacy token, it will stop working in July 2026. Please generate a new one from the dashboard to ensure compatibility.
HTTP Request Code Examples
Note: The following code examples demonstrate how to make authenticated requests to SRA using various programming languages. If you are using a wrapper, you may not need to handle the authorization header manually.
const fetch = require("node-fetch");
fetch("https://some-random-api.com/animal/dog", {
headers: {
Authorization: "your-api-token-here"
}
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error("Error:", err));