Stack Exchange

Search questions on Stack Overflow and other Stack Exchange sites, and fetch up to 100 questions with their bodies by id, as typed JSON.

Embed
Preview of the card
<a href="https://scrapelyserp.com/docs/stackexchange"><img src="https://scrapelyserp.com/docs/_api/public/orgs/affc5b0f-d3c2-423a-8143-9d10db5736ae/spaces/981e6275-da3f-446c-82de-889f59c83b6f/pages/91d37951-1ccf-4e14-b25d-72baced9d18c/social-card.svg?v=3e7ae33eec8b" alt="Stack Exchange" width="600" height="315"></a>

Search questions on Stack Overflow and other Stack Exchange sites, and fetch up to 100 questions with their bodies by id, as typed JSON.

At a glance

Two GET endpoints under /v1/structured/stackexchange/. Each answers { endpoint, url, credits, duration_ms, data }. Each call is charged for the data it moves; a request we could not read is 502 TARGET_FAILED and costs nothing. Public data under the network's API terms; show attribution to the authors where you publish it, as the content is licensed CC BY-SA.

Endpoint

What

Typical (estimate)

GET /v1/structured/stackexchange/search

Questions matching a query and/or tags

about 5 million results per credit, up to 100 per call

GET /v1/structured/stackexchange/questions

Questions by id, with their bodies

about 2.5 million questions per credit, up to 100 per call

curl -G "https://api.scrapelyserp.com/v1/structured/stackexchange/search" \
  -H "Authorization: Bearer $SCRAPELY_API_KEY" \
  -d site=stackoverflow \
  --data-urlencode "query=web scraping" \
  -d sort=votes

How much you can pull

The network limits how much one address may read in a day, so requests are spread across many exits and the limit rarely shows. When an exit is used up, or asks readers to slow down, the call moves to another exit straight away (up to four tries, no waiting), and that exit rests until its allowance returns. Only if every try is throttled does a call fail: it is 502 TARGET_FAILED, uncharged, and can be sent again. A retry adds a second or two to a call.

Searching reaches pages 1 to 25 (up to 2,500 questions at 100 per page). Fetching by id is far cheaper per question: one call takes up to 100 ids.

Parameter

Type

Default

Description

site

enum

stackoverflow

Which Stack Exchange site.

query

string

—

The search terms. Send this, tagged, or both.

tagged

string

—

Only questions with all of these tags, up to 5, comma-separated, e.g. python,web-scraping.

sort

relevance, votes, creation, activity

relevance

Result order.

order

desc, asc

desc

The direction.

limit

integer

30

Results per page, 1–100.

page

integer

1

Page number, 1–25.

Each question has id, title, url, score, answers, views, is_answered, accepted_answer_id, tags, author, author_id, author_reputation, created_at and last_activity_at. next_page is the page to send next, or null at the end. A query that matches nothing returns an empty list.

Full reference → GET /v1/structured/stackexchange/search

Questions by id

Parameter

Type

Default

Description

site

enum

stackoverflow

Which Stack Exchange site.

ids (required)

string

—

Question ids, comma-separated, up to 100. A question link is accepted.

The same fields as search plus body_html, the question's body. Results come in the order the ids were sent; ids that do not exist are listed in missing.

Full reference → GET /v1/structured/stackexchange/questions

Updated