Authentication
Overview
Scrape Loop API uses API keys for authentication. You can provide your API key in one of two ways:
- As a header (recommended)
- As a query parameter
API Key Methods
- Header Method
- Query Parameter
Implementation Examples
- Node.js
- Python
const apiKey = process.env.SCRAPE_LOOP_API_KEY;
// Using header authentication
async function fetchRecipes() {
const response = await fetch('https://api.scrapeloop.com/v1/recipes', {
headers: {
'x-api-key': apiKey
}
});
return await response.json();
}
import os
import requests
api_key = os.environ.get('SCRAPE_LOOP_API_KEY')
# Using header authentication
def fetch_recipes():
headers = {'x-api-key': api_key}
response = requests.get(
'https://api.scrapeloop.com/v1/recipes',
headers=headers
)
return response.json()
Error Handling
Common Authentication Errors
Error Code | Description | Solution |
---|---|---|
401 | Missing API key | Include API key in header or query parameter |
401 | Invalid API key | Check if the API key is correct and active |
403 | Insufficient permissions | Verify API key has required permissions |
Error Response Example
{
"success": false,
"message": "Invalid API key provided",
"statusCode": 401
}