CLI
Fetch live pages from your terminal or your agent's shell: one command, the same API, no code.
Install
npx @contextretrieval-net/cli login # paste your API key (not echoed)
npx @contextretrieval-net/cli fetch https://example.com -o text # the page as Markdownnpm install -g @contextretrieval-net/cli
contextretrieval --helpNode.js 18 or later, no other dependencies. Open source (MIT): https://github.com/contextretrieval-net/cli on GitHub, @contextretrieval-net/cli on npm.
Fetch pages
contextretrieval fetch https://example.com/a https://example.com/b # up to 10 URLs; JSON with results[] and statuses[]
contextretrieval fetch https://example.com -o text # just the content (Markdown, else text, else HTML)
contextretrieval fetch https://example.com -o html --html # the page HTML
contextretrieval fetch https://example.com --country-code de --render # from Germany, rendered in a real browser
contextretrieval fetch --data @request.json # the whole request body from a file (- for stdin)
contextretrieval account # plan, credits and rate limit
contextretrieval fetch --help # every option, with the API's own descriptionsA fetch is the same request as POST https://contextretrieval.net/api/v1/contents (API reference), charged the same
way. One that is still running after about 100 seconds is collected automatically with the same Idempotency-Key,
so it is charged once.
API key
contextretrieval login saves the key in ~/.config/contextretrieval/config.json (mode 0600). In CI or an agent's
environment, set CONTEXTRETRIEVAL_API_KEY or pass --api-key instead. The key is only ever sent to the API base URL
(https://contextretrieval.net/api, or --base-url).
Always current
The commands and options come from the API's OpenAPI document, which the CLI downloads again after
an hour. When the API gains a field or an endpoint, the option is there on your next run, without updating the CLI.
Offline, it uses the last copy it downloaded, then the copy bundled with the package (contextretrieval spec shows which).
New versions are published to npm automatically whenever the API changes.
Output and exit codes
| Option | Prints |
|---|---|
-o json (default) | The API's JSON response |
-o text | The content of each page: Markdown, else text, else HTML |
-o <field> | One field of each result, e.g. -o title |
| Exit code | Meaning |
|---|---|
| 0 | OK |
| 1 | The API answered with an error (JSON on stderr, with its requestId), or every URL failed with -o text |
| 2 | Usage: unknown command or option, or a value the API does not accept |
| 3 | Network: no answer. The error carries the Idempotency-Key to collect the result without a new charge |