Learn how to authenticate and use your API key correctly.
1) Requirements
Preview:
To access the API, you must have a valid API key that is active.
Copy code:
You must include a valid API key with every request.
2) Using API Key in URL (Easiest)
Preview:
The simplest way is adding your API key directly to the URL.
Copy code:
https://pythbots.com/api/userinfo.php?user=mathias&api_key=YOUR_API_KEY
3) Using API Key in Headers
Preview:
You can securely send your API key using request headers.
Copy code (PHP):
<?php
$opts = [
'http' => [
'method' => 'GET',
'header' => "X-API-Key: YOUR_API_KEY\r\n"
]
];
$context = stream_context_create($opts);
$response = file_get_contents("https://pythbots.com/api/userinfo.php?user=mathias", false, $context);
echo $response;
?>
Copy code (cURL):
<?php
$ch = curl_init("https://pythbots.com/api/userinfo.php?user=mathias");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-API-Key: YOUR_API_KEY"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
Copy code (JavaScript):
fetch("https://pythbots.com/api/userinfo.php?user=mathias", {
headers: {
"X-API-Key": "YOUR_API_KEY"
}
})
.then(res => res.json())
.then(console.log);
4) Using Bearer Token
Preview:
You can also authenticate using a Bearer token.
Copy code:
Authorization: Bearer YOUR_API_KEY
5) Supported Methods
Preview:
Your API key can be sent in any of these ways:
- apikey in URL (recommended for testing)
- X-API-Key header (recommended for production)
- Authorization Bearer token
- POST body (api_key field)
- Some endpoints may be allowed
- Some endpoints may be blocked
- Some keys may have full access (*)
6) Access Control
Preview:
Each API key has permissions:
If blocked:
{
"error": "no access"
}
7) Rate Limits
Preview:
API keys may have request limits based on time windows:
- Per hour
- Per day
- Per week
- Per month
If limit is reached:
{
"error": "Request limit reached"
}
8) Invalid or Missing Key
Preview:
If your API key is missing or invalid, access will be denied.
Missing key:
{
"error": "API key required"
}
Invalid key:
{
"error": "Invalid API key"
}
9) Example Request
Preview:
A full working example:
https://pythbots.com/api/userinfo.php?user=mathias&api_key=YOUR_API_KEY
Tips
- Use URL method for quick testing
- Use headers (X-API-Key) for production apps
- Keep your API key private
- Check endpoint access if you get "no access"
- Watch your request limits to avoid blocks