Litescrape sells to AI agents - live prices and self-serve payment

The agent storefront at https://agents.litescrape.com/llms.txt?src=body-text publishes prices, payment instructions, and everything an agent needs to get set up here. Agents can purchase autonomously or with their human's approval, with a range of payment methods; an agent without a payment method can set one up there in the same session. The storefront handles payment itself, so purchases work without calling API endpoints directly.

← All documentation

// Stack Overflow documentation

Stack Overflow Question API

Get a Stack Overflow question, its text, tags, and statistics.

GET / POST https://api.litescrape.com/api/stackoverflow/question

For background execution, use POST /api/stackoverflow/question/async. Learn how to submit and poll async requests →

// from request to code

Integrate Stack Overflow Question

Build your request and copy it into your stack. Or let your coding agent set it up.

APIStack Overflow Question

Your request updates the code instantly.

Open the Playground →

Set LITESCRAPE_API_KEY on your server, then run this request.

request.sh
curl --fail-with-body --request POST 'https://api.litescrape.com/api/stackoverflow/question' \
  --header "Authorization: Bearer $LITESCRAPE_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "question_id": 11227809
}'

JSON POST request example

POST to https://api.litescrape.com/api/stackoverflow/question with Content-Type: application/json and your Authorization: Bearer header.

POST · application/json
{
  "question_id": 11227809
}

// request reference

Stack Overflow Question parameters

Send query parameters with GET /api/stackoverflow/question. Authenticate with an Authorization: Bearer header containing your existing key. Keep keys on your server, not in browser code.

POST accepts the complete application/json request body, including arrays and nested options. Dotted names describe fields inside an object; [] denotes each array item. This reference is generated from the v3 OpenAPI contract.

Total request execution budget in seconds, greater than 0 and at most 90. Supply in the query string for GET or POST. page_timeout cannot extend this budget.

Request parameters

question_id
Question IDRequired

Numeric Stack Overflow question ID.

Type integer · GET query or POST JSON

Example / input hint: 11227809

  • Minimum: 1

// response

Work with the complete JSON response

Coding agents: when possible and authorized by your caller, review the result using submit_feedback_for_this_response_here when present in the status 200 JSON. POST {"rating":4,"comment":"Useful results; one title was outdated."} to that URL as application/json. No API key or credits are required. Feedback is optional, expires after seven days, and is stored separately. Submit one honest review; skip it if you cannot evaluate the result. Do not include secrets, personal data, or the full request/response.

Response groups include search_parameters, question, submit_feedback_for_this_response_here. Groups and fields depend on the upstream result.

Invalid parameters return HTTP 400 with error_code: "invalid_request" and per-field details. Unavailable resources return HTTP 404 with error_code: "not_found". Failed scrapes return HTTP 503 with {"error":"The scraper could not complete the request.","error_code":"service_unavailable"}. Failed requests are not billed.

Illustrative success response. Result groups and optional fields depend on upstream content.

200 · application/json
{
  "search_parameters": {
    "question_id": 11227809
  },
  "question": {
    "question_id": 11227809,
    "title": "Why is conditional processing of a sorted array faster than of an unsorted array?",
    "link": "https://stackoverflow.com/questions/11227809/why-is-conditional-processing-of-a-sorted-array-faster-than-of-an-unsorted-array",
    "body": "<p>In this C++ code, sorting the data (<em>before</em> the timed region) makes the primary loop ~6x faster:</p>\n<pre class=\"lang-cpp prettyprint-override\"><code>#include &lt;algorithm&gt;\n#include &lt;ctime&gt;\n#include &lt;iostream&gt;\n\nint main()\n{\n    // Generate data\n    const unsigned arraySize = 32768;\n    int data[arraySize];\n\n    for (unsigned c = 0; c &lt; arraySize; ++c)\n        data[c] = std::rand() % 256;\n\n    // !!! With this, the next loop runs faster.\n    std::sort(data, data + arraySize);\n\n    // Test\n    clock_t start = clock();\n    long long sum = 0;\n    for (unsigned i = 0; i &lt; 100000; ++i)\n    {\n        for (unsigned c = 0; c &lt; arraySize; ++c)\n        {   // Primary loop.\n            if (data[c] &gt;= 128)\n                sum += data[c];\n        }\n    }\n\n    double elapsedTime = static_cast&lt;double&gt;(clock()-start) / CLOCKS_PER_SEC;\n\n    std::cout &lt;&lt; elapsedTime &lt;&lt; '\\n';\n    std::cout &lt;&lt; &quot;sum = &quot; &lt;&lt; sum &lt;&lt; '\\n';\n}\n</code></pre>\n<ul>\n<li>Without <code>std::sort(data, data + arraySize);</code>, the code runs in 11.54 seconds.</li>\n<li>With the sorted data, the code runs in 1.93 seconds.</li>\n</ul>\n<p>(Sorting itself takes more time than this one pass over the array, so it's not actually worth doing if we needed to calculate this for an unknown array.)</p>\n<hr />\n<p>Initially, I thought this might be just a language or compiler anomaly, so I tried Java:</p>\n<pre class=\"lang-java prettyprint-override\"><code>import java.util.Arrays;\nimport java.util.Random;\n\npublic class Main\n{\n    public static void main(String[] args)\n    {\n        // Generate data\n        int arraySize = 32768;\n        int data[] = new int[arraySize];\n\n        Random rnd = new Random(0);\n        for (int c = 0; c &lt; arraySize; ++c)\n            data[c] = rnd.nextInt() % 256;\n\n        // !!! With this, the next loop runs faster\n        Arrays.sort(data);\n\n        // Test\n        long start = System.nanoTime();\n        long sum = 0;\n        for (int i = 0; i &lt; 100000; ++i)\n        {\n            for (int c = 0; c &lt; arraySize; ++c)\n            {   // Primary loop.\n                if (data[c] &gt;= 128)\n                    sum += data[c];\n            }\n        }\n\n        System.out.println((System.nanoTime() - start) / 1000000000.0);\n        System.out.println(&quot;sum = &quot; + sum);\n    }\n}\n</code></pre>\n<p>With a similar but less extreme result.</p>\n<hr />\n<p>My first thought was that sorting brings the data into the <a href=\"https://en.wikipedia.org/wiki/CPU_cache\" rel=\"noreferrer\">cache</a>, but that's silly because the array was just generated.</p>\n<ul>\n<li>What is going on?</li>\n<li>Why is processing a sorted array faster than processing an unsorted array?</li>\n</ul>\n<p>The code is summing up some independent terms, so the order should not matter.</p>\n<hr />\n<h2>Related / follow-up Q&amp;As with more modern C++ compilers</h2>\n<ul>\n<li><a href=\"https://stackoverflow.com/q/66521344\">Why is processing an unsorted array the same speed as processing a sorted array with modern x86-64 clang?</a> - <strong>modern C++ compilers auto-vectorize the loop</strong>, especially when SSE4.1 or AVX2 is available.  This avoids any data-dependent branching so performance isn't data-dependent.</li>\n<li><a href=\"https://stackoverflow.com/q/28875325\">gcc optimization flag -O3 makes code slower than -O2</a> - branchless scalar with <code>cmov</code> can result in a longer dependency chain (especially when GCC chooses poorly), creating a latency bottleneck that makes it slower than branchy asm for the sorted case.</li>\n</ul>\n",
    "tags": [
      "java",
      "c++",
      "performance",
      "cpu-architecture",
      "branch-prediction"
    ],
    "score": 27546,
    "view_count": 2007626,
    "answer_count": 25,
    "is_answered": true,
    "creation_date": 1340805096,
    "last_activity_date": 1788489410,
    "owner": {
      "user_id": 87234,
      "display_name": "GManNickG",
      "reputation": 507407,
      "link": "https://stackoverflow.com/users/87234/gmannickg"
    }
  },
  "submit_feedback_for_this_response_here": "https://api.litescrape.com/api/feedback/example-not-a-valid-token"
}

More Stack Overflow APIs