Learn how to authenticate with the TPMJS API to access protected endpoints.
Understanding TPMJS authentication
TPMJS uses API keys for authentication. Some endpoints are public and don't require authentication, while others require a valid API key to access.
GET /api/tools - List and search toolsGET /api/tools/:id - Get tool detailsGET /api/tools/trending - Get trending toolsGET /api/collections - List public collectionsGET /api/collections/:uid - Get collection detailsPOST /api/tools/:id/rate - Rate a toolPOST /api/tools/:id/reviews - Write a reviewPOST /api/collections - Create a collectionPOST /api/agents - Create an agentGET /api/agents - List your agentsHow to obtain your API key
To get an API key, you need to create a TPMJS account and generate a key from your dashboard.
Important
Your API key is displayed only once when created. Make sure to copy and store it securely. If you lose it, you'll need to generate a new one.
How to authenticate requests
Include your API key in the Authorization header using the Bearer scheme.
Authorization: Bearer YOUR_API_KEYcurl -H "Authorization: Bearer YOUR_API_KEY" \
"https://tpmjs.com/api/agents"const API_KEY = process.env.TPMJS_API_KEY;
const response = await fetch('https://tpmjs.com/api/agents', {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
}
});
const data = await response.json();import os
import requests
API_KEY = os.environ.get('TPMJS_API_KEY')
response = requests.get(
'https://tpmjs.com/api/agents',
headers={
'Authorization': f'Bearer {API_KEY}',
'Content-Type': 'application/json'
}
)
data = response.json()Common authentication error responses
Returned when no API key is provided or the key is invalid.
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required. Please provide a valid API key."
}
}Returned when the API key is valid but lacks permission for the requested action.
{
"success": false,
"error": {
"code": "FORBIDDEN",
"message": "You don't have permission to access this resource."
}
}Returned when you've exceeded the rate limit for your API key.
{
"success": false,
"error": {
"code": "RATE_LIMITED",
"message": "Too many requests. Please try again in 60 seconds."
}
}API request limits
TPMJS enforces rate limits to ensure fair usage and protect the API from abuse.
| Tier | Requests/min | Requests/day |
|---|---|---|
| Free | 60 | 1,000 |
| Pro | 300 | 10,000 |
| Enterprise | Custom | Custom |
Every response includes rate limit information in headers:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1704067200Keep your API key secure
# .env.local (add to .gitignore)
TPMJS_API_KEY=your_api_key_here
# In your code
const apiKey = process.env.TPMJS_API_KEY;