Platform / Capabilities

Web scraping API for HTTP, browser, and structured results

Submit a URL, track the asynchronous job, and retrieve HTML, text, or typed data. RunHarvester keeps acquisition, extraction, and request diagnostics connected.

By · Updated

Submit a request from your backend

Keep credentials in a server-side secret store. The key needs scrape:write to submit and requests:read to poll and read results. Generate a unique idempotency key for each new logical request and retain it with the exact body. The following example submits work; it does not immediately return the finished page.

Request / responseExample
curl --request POST "https://api.runharvester.com/api/v1/data/requests" \
  --header "X-API-Key: YOUR_API_KEY" \
  --header "Idempotency-Key: YOUR_UNIQUE_REQUEST_KEY" \
  --header "Content-Type: application/json" \
  --data '{"url":"https://example.com/catalog","mode":"auto"}'

Poll the state, then retrieve the result

Save the returned id. Poll the status endpoint with backoff and jitter until status is completed, failed, or cancelled; pending, queued, waiting_for_page, running, and solving_captcha are not complete states.

The POST response returns the request id, status, and billing metadata. A raw result contains id, html, text, result_meta, and expires_at; an extraction result also contains data and extraction state. The runnable example prints the JSON returned for your request; values depend on the target page, so no fixed result is invented.

Set RUNHARVESTER_API_KEY and RUNHARVESTER_IDEMPOTENCY_KEY in your server environment. Keep the same key and exact body for an uncertain retry; use a new key for a new observation. API errors use the documented error, code, message, and requestId fields. A result requested before completion returns 409 RESULT_NOT_READY; an expired result returns 410 RESULT_EXPIRED.

Request / responseExample
import json
import os
import random
import time
from urllib.error import HTTPError
from urllib.request import Request, urlopen

API = "https://api.runharvester.com/api/v1/data"
API_KEY = os.environ["RUNHARVESTER_API_KEY"]
IDEMPOTENCY_KEY = os.environ["RUNHARVESTER_IDEMPOTENCY_KEY"]
HTTP_TIMEOUT_SECONDS = 30
CLIENT_WAIT_LIMIT_SECONDS = 240
INITIAL_POLL_DELAY_SECONDS = 1
MAX_POLL_DELAY_SECONDS = 10
POLL_JITTER_RATIO = 0.2

def call(method, path, payload=None):
    body = None if payload is None else json.dumps(payload).encode()
    headers = {"X-API-Key": API_KEY}
    if payload is not None:
        headers["Idempotency-Key"] = IDEMPOTENCY_KEY
        headers["Content-Type"] = "application/json"
    request = Request(
        API + path,
        data=body,
        method=method,
        headers=headers,
    )
    try:
        with urlopen(request, timeout=HTTP_TIMEOUT_SECONDS) as response:
            return response.status, json.load(response)
    except HTTPError as error:
        response_body = error.read().decode("utf-8")
        raise RuntimeError(
            "HTTP " + str(error.code) + " " + path + ": " + response_body
        ) from error

status_code, submission = call(
    "POST", "/requests", {"url": "https://example.com/", "mode": "auto"}
)
if status_code != 202:
    raise RuntimeError("Unexpected submission status: " + str(status_code))
request_id = submission["id"]
print("202 submission:", json.dumps(submission, indent=2))

deadline = time.monotonic() + CLIENT_WAIT_LIMIT_SECONDS
delay = INITIAL_POLL_DELAY_SECONDS
while time.monotonic() < deadline:
    status_code, state = call("GET", "/requests/" + request_id)
    if status_code != 200:
        raise RuntimeError("Unexpected polling status: " + str(status_code))
    print("200 status:", json.dumps(state, indent=2))
    if state["status"] == "completed":
        break
    if state["status"] in {"failed", "cancelled"}:
        raise RuntimeError("Request ended without a result: " + json.dumps(state))
    time.sleep(delay + random.random() * delay * POLL_JITTER_RATIO)
    delay = min(delay * 2, MAX_POLL_DELAY_SECONDS)
else:
    raise TimeoutError("Request did not complete before the client deadline")

status_code, result = call("GET", "/requests/" + request_id + "/result")
if status_code != 200:
    raise RuntimeError("Unexpected result status: " + str(status_code))
print("200 result:", json.dumps(result, indent=2))

Choose acquisition and output independently

Select HTTP if the initial response holds the required data, switch to browser mode for JavaScript execution, or choose auto to let the system handle route selection. Residential modes indicate an egress requirement. Availability depends on account status and deployment details.

To produce typed output, include extraction.fields or reference an active recipe you own. Structured extraction is limited to individual requests; Data API batches process only raw scrape jobs.

Handle failures without hiding them

RESULT_NOT_READY means the result was requested before completion; continue polling instead of submitting duplicate work. Results are retained for seven days; RESULT_EXPIRED means that window has passed. The example surfaces the HTTP status and response body for API errors. Inspect public error fields and request events before deciding whether to retry.

Resubmit the interrupted request using its original idempotency key and payload. Each retry of a failed job generates a new request ID. For bounded retries, retrieve outcomes before expiration and apply the returned billing metadata for cost reconciliation.

Integrate in your existing runtime

Use the documented HTTP interface from your backend. Keep Data API credentials server-side. The existing MCP server provides a documented Streamable HTTP connection for agents, with Data API tools.

A few useful answers

Common questions

Does submitting a request return the finished result?

No. Keep the request ID, check its status, and get the result once finished. States like Pending, running, and solving_captcha mean it's not done yet. Fetching a result prematurely yields RESULT_NOT_READY; check for errors rather than assuming every response is scraped data.

Read the documentation
Can I submit structured extraction in a Data API batch?

Data API batches accept raw scrape jobs only. Submit structured extraction as individual requests.

Read the documentation
How long can I retrieve a result?

Data retention is governed by your specific service and plan settings. Make sure to review the expiry details provided and fetch any necessary results prior to expiration. If a Data API result expires, it will return RESULT_EXPIRED. Ensure you export necessary data to your personal storage instead of relying on retained results as a permanent archive.

Read the documentation
How do I retry without creating duplicate work?

Generate an Idempotency-Key before submission and store it with the exact request body. Reuse it when retrying the same submission after a network interruption. A new logical request requires a new key. Retrying a failed request creates a new request ID; preserve the original for diagnosis.

Read the documentation
Where should I keep API keys?

Store API keys securely in a server-side secret manager and assign only the necessary scopes for the integration. Avoid placing credentials in public frontend code, documentation examples, or logs.

Read the documentation
What determines the cost of a request?

Request cost depends on the active route and caching behavior. Auto serves as a routing policy, not a fixed price. Rely on response billing metadata and the current pricing version as the definitive source; plan prices and allowances are sourced from the live catalog.

Read the documentation

Put it to work

Start with one real request.

Inspect the result. Refine your workflow. Choose a plan for your workload.