httpsnippet is a JavaScript/TypeScript library that generates code snippets for HTTP requests across a wide array of programming languages and libraries from an HTTP Archive (HAR) object. It supports numerous targets, including cURL, JavaScript (Fetch, XMLHttpRequest, Axios), Node.js (request, Axios), Python (Requests), Java (OkHttp, Unirest), C#, Go, PHP, and more. The current stable version is 3.0.10, and the project maintains an active release cadence, frequently addressing dependency vulnerabilities, fixing bugs, and expanding support for new languages and clients. It is primarily used for developer tools, API documentation, and code generation, allowing users to easily translate network requests into runnable code examples.
npm install httpsnippetVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to instantiate HTTPSnippet with a HAR request object and generate code snippets for JavaScript (fetch), cURL, and Python (Requests).
Ensure your Node.js environment is at least version 10 or higher. For current versions, use Node.js >=20.
Upgrade your Node.js runtime to version 20 or newer to ensure compatibility.
Upgrade to `httpsnippet` version 3.0.9 or newer to resolve `window` object access errors in SSR contexts.
Keep `httpsnippet` updated to the latest stable release (e.g., `npm update httpsnippet` or `yarn upgrade httpsnippet`).
Consult the official documentation or source code for a list of supported targets and clients to ensure correct usage.
Update `httpsnippet` to version 3.0.9 or newer to fix SSR compatibility issues.
Use ESM `import` syntax: `import { HTTPSnippet } from 'httpsnippet';`.Ensure you are using the named export `HTTPSnippet`: `import { HTTPSnippet } from 'httpsnippet'; const snippet = new HTTPSnippet(har);`Upgrade your Node.js environment to version 20 or higher (e.g., using `nvm install 20` and `nvm use 20`).
No dependency data recorded yet.