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

  1. Sign up at webscraperapi.ai.
  2. Go to Settings.
  3. 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:

HeaderDescription
X-Credits-UsedCredits consumed by this request
X-Credits-RemainingCredits left in your account
X-Credits-LimitTotal 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:

  1. Add the MCP server to your client.
  2. Make your first tool call.
  3. Complete sign-in in the browser window that opens.

After that, your MCP client handles auth automatically — no API key needed.