Batch requests API
  1. Docs
  2. Batch
  3. Batch requests API

Batch requests API

Up to 100 GET requests in one call; each result is a full envelope, charged as if called alone (cached repeats and failures free).

POST /v1/batch

POST /v1/batch

Up to 100 GET requests in one call; each result is a full envelope, charged as if called alone (cached repeats and failures free). Items run concurrently, each counts toward the rate limit, and a failed item never fails the others. Send an Idempotency-Key header to retry a batch safely: the first answer is replayed and nothing is charged twice.

  • Cost: The sum of each sub-request's charge
  • Cache: Not cached.
  • Timeout: A request still running after about 25 seconds answers 202 with a job to poll (Batch and jobs).

Parameters#

NameTypeRequiredDescriptionIn
requestsarrayyesList of {"path": "/v1/...", "params": {...}}.body

Example request#

Set your key in the environment first (see Authentication).

1curl -X POST "https://api.socialscrape.dev/v1/batch" \2  -H "x-api-key: $SOCIALSCRAPE_API_KEY" \3  -H "content-type: application/json" \4  -d '{"requests":[{"path":"/v1/github/user","params":{"handle":"torvalds"}},{"path":"/v1/github/user","params":{"handle":"gaearon"}}]}'

Example response#

This is a sample with illustrative values. Status 200.

200 OKSample response
1{2  "ok": true,3  "credits_charged": 2,4  "credits_remaining": 4998,5  "cached": false,6  "cached_at": null,7  "request_id": "req_48cebd0a43eb45183d397192",8  "data": {9    "object": "batch",10    "results": [11      {12        "path": "/v1/github/user",13        "status": 200,14        "response": {15          "ok": true,16          "credits_charged": 1,17          "credits_remaining": 4999,18          "cached": false,19          "cached_at": null,20          "request_id": "req_a1b2c3d4e5f6a1b2c3d4e5f6",21          "data": {22            "object": "profile",23            "platform": "github",24            "id": "1024025",25            "handle": "torvalds",26            "name": "Linus Torvalds",27            "url": "https://github.com/torvalds",28            "kind": "person"29          },30          "cursor": null,31          "has_more": null32        }33      },34      {35        "path": "/v1/github/user",36        "status": 200,37        "response": {38          "ok": true,39          "credits_charged": 1,40          "credits_remaining": 4998,41          "cached": false,42          "cached_at": null,43          "request_id": "req_f6e5d4c3b2a1f6e5d4c3b2a1",44          "data": {45            "object": "profile",46            "platform": "github",47            "id": "810438",48            "handle": "gaearon",49            "name": "Dan Abramov",50            "url": "https://github.com/gaearon",51            "kind": "person"52          },53          "cursor": null,54          "has_more": null55        }56      }57    ]58  },59  "cursor": null,60  "has_more": null61}

Response#

A BatchResult object in data.

See Data models for every field. The envelope around data is described in Responses.

Errors#

Failures are free: credits_charged is 0. Branch on error.code, never on the message.

CodeHTTPRetryMeaning
invalid_params400noA parameter is missing, unknown or has the wrong type.

Every request can also fail with the account and platform errors listed on the Errors page.