API Key

HasData uses API keys to authenticate requests. To use the API you need to sign up for an account and include your unique API key in every request.

Make Your First API Request

Start by making a simple request to one of our APIs. Here’s an example for the Google SERP API:

Authentication: Your API key must be passed in the request headers using x-api-key. If it’s missing or incorrect, the API will respond with 401 Unauthorized.

curl --request GET \
	--url 'https://api.hasdata.com/scrape/google/serp?q=Coffee' \
	--header 'Content-Type: application/json' \
	--header 'x-api-key: <your-api-key>'

Web Scraping API Request

Web Scraping API allows you to scrape web pages without the hassle of managing proxies, headless browsers, and captchas. Simply send the URL and get the HTML response in return.

curl --request POST \
	--url https://api.hasdata.com/scrape/web \
	--header 'Content-Type: application/json' \
	--header 'x-api-key: <your-api-key>' \
	--data '{
      "url": "https://example.com",
      "outputFormat": ["html", "text", "markdown"],
      "screenshot": true
    }'

Submit Scraper Job

Scraper Jobs are used for more complex tasks like crawling websites or extracting large datasets from platforms like Google Maps, Amazon, or Zillow.

Unlike single-request APIs, Scraper Jobs run in the background and return results via webhook or polling once the data is ready.

curl --location 'https://api.hasdata.com/v1/scrapers/crawler/jobs' \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <your-api-key>' \
  --data '{
    "limit": 25,
    "urls": ["https://hasdata.com", "https://example.com"],
    "maxDepth": 5,
    "includeOnlyPaths": "(blog/.+|articles/.+)",
    "webhook": {
      "url": "https://example.com/webhook",
      "events": ["scraper.job.started", "scraper.job.finished", "scraper.data.rows_added"]
    }
  }'

Get Scraper Job Status

To get the status of an existing scraper job, make a GET request to the endpoint /v1/scrapers/jobs/:jobId:

curl --location 'https://api.hasdata.com/v1/scrapers/jobs/:jobId' \
  --header 'x-api-key: <your-api-key>'

Webhook

The webhook will notify you of events related to the scraper job. Here is an example webhook payload for the scraper.data.rows_added event:

{
  "event": "scraper.data.rows_added",
  "timestamp": "2025-04-11T14:30:00Z",
  "jobId": "dd1a8c53-2d47-4444-977d-8d653a6a3c82",
  "jobStatus": "in_progress",
  "dataRows": [
    {
      "text": "Extracted text here...",
      "statusCode": 200,
      "statusText": "OK",
      "url": "https://hasdata.com/blog",
      "depth": 1,
      "title": "Blog | HasData"
    }
  ],
  "dataRowsCount": 50,
  "creditsSpent": 50
}