Skip to content
m4bwav edited this page Sep 29, 2026 · 1 revision

Short answers; each links the page with the detail. The repository has no issues filed yet, so these come from the README, the code and the runs behind this wiki.

Why do I get null?

There is no such post on that site, or the post came back without markdown. Check the site (the default is stackoverflow) and whether the id is an answer's: answers need isForAnswer: true, or -a on the command line. See How markdown is retrieved.

Why is there " in the markdown?

The API sends body_markdown with HTML entities in it and the package passes the text on untouched. Recipes has a small decoder.

Why is the callback (markdown, error) and not (error, markdown)?

That is the order 1.x used, and 2.0.0 kept it so old callers keep working. It also means util.promisify gets it backwards. Leave out the callback to get a Promise instead (Recipes).

How many requests can I make?

The README gives the API's anonymous quota as 300 requests a day per IP address; an API key (apiKey, or -k) raises it. The package makes one request per call, keeps no cache and does not track the quota. When the API throttles you, the call fails with a StackExchangeError whose errorName is throttle_violation (Recipes).

Can I fetch several posts in one call?

Ids joined by ; go into one request, but the call returns only the first post in the API's answer. Call it once per post (Recipes).

Does it work behind a proxy?

Yes, through the runtime: on Node 24 set NODE_USE_ENV_PROXY=1 and HTTPS_PROXY before Node starts; Node 20 ignores NODE_USE_ENV_PROXY and needs undici's EnvHttpProxyAgent preloaded; Deno and Bun read HTTPS_PROXY themselves (Recipes). Keep the timeout on, because a proxy that drops the tunnel makes fetch retry until it fires (Edge cases and errors).

Does it work in Deno, Bun or the browser?

Deno 2.9.6 (with --allow-net) and Bun 1.4.2 were run for this wiki (Getting started). Browsers and workers were not tested; the README says the library uses only web platform APIs, and in a browser the API's CORS headers decide.

Why does instanceof StackExchangeError fail?

Probably because the error came from the other build. The ES module and CommonJS builds each have their own class, so an error thrown by the CommonJS build is not an instance of the ES module's class. Compare error.name (Edge cases and errors).

Why does the command print null and exit 0?

null means the post does not exist; that is an answer, not an error. Errors print one line to stderr and exit 1 (Commands).

Does npx pass my flags on?

With npm 11.16.0, npx stack-exchange-markdown-retriever@2.0.0 -s scifi 127968 and ... -a 1010 passed -s and -a to the tool (Getting started). Other npm versions were not tested.

Which version of the API does it use?

Version 2.2, with a fixed filter, and there is no option to change it (How markdown is retrieved).

Should I still use 1.x?

No. Every 1.x version is deprecated on npm; 1.x depends on the deprecated request package, its command line tool was never installed and -a was ignored. Versions and upgrading lists what changes.

Clone this wiki locally