Authentication
How to authenticate with the webscraperapi.ai API.
Authentication
For direct HTTP API calls, pass your API key as a Bearer token in the Authorization header. If you use MCP, authentication is handled via OAuth automatically.
Get your API key
- Sign up at webscraperapi.ai.
- Go to Settings.
- Copy your API key.
Keep your API key secret. Do not commit it to version control or expose it in client-side code.
Make a request
curl -G "https://api.webscraperapi.ai/v1/scrape" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "url=https://news.ycombinator.com" \
--data-urlencode "output=markdown"import requests
response = requests.get(
"https://api.webscraperapi.ai/v1/scrape",
params={
"url": "https://news.ycombinator.com",
"output": "markdown",
},
headers={"Authorization": "Bearer YOUR_API_KEY"},
)const params = new URLSearchParams({
url: 'https://news.ycombinator.com',
output: 'markdown',
});
const response = await fetch(
`https://api.webscraperapi.ai/v1/scrape?${params}`,
{
headers: { Authorization: 'Bearer YOUR_API_KEY' },
}
);A successful response returns 200 with JSON data. An invalid key returns 401.
Credits and usage
Every API response includes headers showing your credit usage:
| Header | Description |
|---|---|
X-Credits-Used | Credits consumed by this request |
X-Credits-Remaining | Credits left in your account |
X-Credits-Limit | Total credits in your plan |
Rate limits
API requests are rate-limited per API key. If you exceed the limit, you'll receive a 429 Too Many Requests response. Back off and retry with exponential backoff.
Rate limits vary by plan. Contact us if you need higher throughput.
MCP OAuth
If you use webscraperapi via MCP, authentication is handled via OAuth:
- Add the MCP server to your client.
- Make your first tool call.
- Complete sign-in in the browser window that opens.
After that, your MCP client handles auth automatically — no API key needed.