Getting started overview

Integrating with the ScrapingDog API involves a sequence of steps designed to get you from account creation to a successful API call. This guide focuses on the initial setup, including obtaining your API key and making a basic request. The process is similar across programming languages, primarily involving an HTTP GET request to the ScrapingDog endpoint with your target URL and API key as parameters.

ScrapingDog provides a free tier that includes 1,000 API calls per month, allowing developers to test the service without an initial financial commitment. Paid plans begin at $20 per month for 200,000 API calls, with higher tiers offering increased call volumes and additional features. The API is designed to handle tasks such as bypassing anti-bot measures, rotating proxies, and rendering JavaScript-heavy web pages, which can be critical for modern web scraping operations.

Here's a quick reference for the getting started process:

Step What to do Where
1. Sign Up Create a new ScrapingDog account. ScrapingDog homepage
2. Get API Key Locate your unique API key in the dashboard. ScrapingDog dashboard
3. Construct Request Build an HTTP GET request with your target URL and API key. Your code editor/terminal
4. Execute Request Send the request to the ScrapingDog API endpoint. Your code editor/terminal
5. Process Response Handle the returned HTML content or JSON data. Your code editor

Create an account and get keys

To begin using ScrapingDog, you must first create an account. This process typically involves providing an email address and setting a password. Upon successful registration, you will gain access to the ScrapingDog dashboard, where your unique API key is automatically generated and displayed.

  1. Visit the ScrapingDog website: Navigate to the ScrapingDog homepage.
  2. Sign up: Look for a "Sign Up" or "Get Started Free" button. Click it to initiate the registration process.
  3. Complete registration: Provide the required information, usually an email address and a password. You might need to verify your email address through a confirmation link sent to your inbox.
  4. Access your dashboard: After logging in, you will be redirected to your personal dashboard.
  5. Locate your API key: Your API key should be prominently displayed on the dashboard. It is a long alphanumeric string that authenticates your requests to the ScrapingDog API. Keep this key secure, as it grants access to your account's API call quota. The ScrapingDog documentation provides further details on managing API keys.

Your API key is a critical component for all API requests. It must be included as a query parameter in every call to the ScrapingDog API. Without it, requests will fail with an authentication error.

Your first request

Once you have your API key, you can make your first request. The core ScrapingDog API endpoint is used for fetching web page content. You will typically send an HTTP GET request to https://api.scrapingdog.com/scrape, including your API key and the URL of the page you wish to scrape.

Here’s how to construct a basic request using cURL, a common command-line tool for making HTTP requests:

curl -X GET "https://api.scrapingdog.com/scrape?api_key=YOUR_API_KEY&url=https://www.example.com"

Replace YOUR_API_KEY with the actual API key from your dashboard and https://www.example.com with the URL of the webpage you intend to scrape.

Python Example

For Python developers, the requests library is commonly used for making HTTP requests:

import requests

api_key = "YOUR_API_KEY"
target_url = "https://www.example.com"

# Construct the API URL
scrapingdog_url = f"https://api.scrapingdog.com/scrape?api_key={api_key}&url={target_url}"

try:
    response = requests.get(scrapingdog_url)
    response.raise_for_status()  # Raise an HTTPError for bad responses (4xx or 5xx)
    print(response.text)
except requests.exceptions.HTTPError as err:
    print(f"HTTP error occurred: {err}")
except Exception as err:
    print(f"An error occurred: {err}")

This Python script sends a GET request to ScrapingDog and prints the HTML content of the target URL. The requests.get() method handles the HTTP communication, and response.raise_for_status() checks for HTTP error codes.

Node.js Example

In Node.js, you can use the built-in https module or a library like axios:

const axios = require('axios'); // npm install axios

const apiKey = "YOUR_API_KEY";
const targetUrl = "https://www.example.com";

const scrapingDogUrl = `https://api.scrapingdog.com/scrape?api_key=${apiKey}&url=${targetUrl}`;

axios.get(scrapingDogUrl)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error(`Error scraping URL: ${error.message}`);
  });

This Node.js example uses the axios library to perform the GET request and then logs the returned data (the HTML content). The .catch() block handles any potential errors during the request.

Common next steps

After successfully performing your first request, you can explore more advanced features and integrations offered by ScrapingDog. Many web scraping tasks require more than just fetching raw HTML.

  • Parsing HTML: Once you retrieve the HTML content, you'll likely need to parse it to extract specific data. Libraries like Beautiful Soup for Python or Cheerio for Node.js are commonly used for this purpose. The W3C's HTML standards provide a foundational understanding of the document structure you'll be parsing.
  • JavaScript Rendering: For websites that heavily rely on JavaScript to load content, you will need to enable JavaScript rendering in your ScrapingDog request. This is typically done by adding a parameter like &render=true to your API call. Refer to the ScrapingDog API documentation for specific parameter details.
  • Proxy API: If you need direct access to a proxy network for specific use cases not covered by the main Scraping API, ScrapingDog offers a separate Proxy API. This allows for fine-grained control over proxy selection and rotation.
  • SERP API: For extracting search engine results page (SERP) data, ScrapingDog provides a dedicated SERP API. This API is optimized for querying search engines and returning structured data.
  • Error Handling: Implement robust error handling in your application to manage network issues, API rate limits, and other potential problems. Review HTTP status codes (e.g., 400 for bad request, 401 for unauthorized, 429 for too many requests, 500 for internal server error) to gracefully handle different API responses. The MDN Web Docs on HTTP status codes offer a comprehensive reference.
  • Rate Limits and Usage: Monitor your API usage to stay within your plan's limits. The ScrapingDog dashboard typically provides tools to track your API call consumption. Understanding ScrapingDog's pricing structure is essential for scaling your usage.

Troubleshooting the first call

When making your initial API call to ScrapingDog, you might encounter issues. Here are common problems and their solutions:

  • Invalid API Key (401 Unauthorized):
    • Symptom: The API returns a 401 HTTP status code or an "Unauthorized" message.
    • Solution: Double-check that you have copied your API key correctly from your ScrapingDog dashboard. Ensure there are no leading or trailing spaces, and that it is correctly passed as the api_key query parameter.
  • Missing URL Parameter (400 Bad Request):
    • Symptom: The API returns a 400 HTTP status code or indicates a missing URL parameter.
    • Solution: Verify that the url query parameter is present and correctly encoded in your request. The target URL must be a complete and valid URL (e.g., https://www.example.com).
  • Incorrect Endpoint:
    • Symptom: The request fails with a connection error or a 404 Not Found.
    • Solution: Ensure you are sending requests to the correct ScrapingDog API endpoint: https://api.scrapingdog.com/scrape.
  • Network Issues:
    • Symptom: The request times out or a connection cannot be established.
    • Solution: Check your internet connection. If you are behind a corporate firewall or proxy, ensure it allows outgoing connections to api.scrapingdog.com.
  • Rate Limit Exceeded (429 Too Many Requests):
    • Symptom: The API returns a 429 HTTP status code.
    • Solution: You may have exceeded your free tier or paid plan's API call limit. Check your ScrapingDog dashboard for your current usage. Implement delays between requests or upgrade your plan if necessary.
  • Target Website Blocking:
    • Symptom: ScrapingDog returns a page indicating the target website blocked the request (e.g., a CAPTCHA page or an access denied message).
    • Solution: While ScrapingDog is designed to bypass many anti-bot measures, some advanced protections might still pose challenges. Try enabling JavaScript rendering (&render=true) if the site is JavaScript-heavy. For persistent issues, consult the ScrapingDog documentation or support.