{"id":15225219,"url":"https://github.com/httptoolkit/httpsnippet","last_synced_at":"2025-04-09T19:11:06.783Z","repository":{"id":43388728,"uuid":"455176509","full_name":"httptoolkit/httpsnippet","owner":"httptoolkit","description":"HTTP Request snippet generator for many languages \u0026 libraries","archived":false,"fork":false,"pushed_at":"2024-07-22T09:30:45.000Z","size":1340,"stargazers_count":8,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-21T01:11:11.295Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/httptoolkit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-03T13:30:41.000Z","updated_at":"2024-07-22T09:30:48.000Z","dependencies_parsed_at":"2024-06-21T17:01:52.137Z","dependency_job_id":"2c49ebf3-63d3-4bdb-8a16-4f50717813f4","html_url":"https://github.com/httptoolkit/httpsnippet","commit_stats":{"total_commits":471,"total_committers":51,"mean_commits":9.235294117647058,"dds":0.6114649681528662,"last_synced_commit":"03b377f081d53b2ebe93ba6a28e9af46b1cf5d05"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fhttpsnippet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fhttpsnippet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fhttpsnippet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fhttpsnippet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/httptoolkit","download_url":"https://codeload.github.com/httptoolkit/httpsnippet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235538025,"owners_count":19006071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-28T18:05:11.763Z","updated_at":"2025-01-25T04:28:58.646Z","avatar_url":"https://github.com/httptoolkit.png","language":"JavaScript","readme":"# @httptoolkit/HTTPSnippet [![Build Status](https://github.com/httptoolkit/httpsnippet/workflows/CI/badge.svg)](https://github.com/httptoolkit/httpsnippet/actions) [![Available on NPM](https://img.shields.io/npm/v/@httptoolkit/httpsnippet.svg)](https://npmjs.com/package/@httptoolkit/httpsnippet)\n\n\u003e _Part of [HTTP Toolkit](https://httptoolkit.tech): powerful tools for building, testing \u0026 debugging HTTP(S)_\n\nHttpsnippet is an HTTP request snippet generator for *many* languages \u0026 tools including: `cURL`, `HTTPie`, `Javascript`, `Node`, `C`, `Java`, `PHP`, `Objective-C`, `Swift`, `Python`, `Ruby`, `C#`, `Go`, `OCaml` and [more](https://github.com/httptoolkit/httpsnippet/tree/main/src/targets)!\n\nThis library relies on the popular [HAR](http://www.softwareishard.com/blog/har-12-spec/#request) format to import data and describe HTTP calls.\n\n_This is a fork of Kong's (previous Mashape's) [httpsnippet](https://github.com/Kong/httpsnippet/) library, which appears to no longer be maintained. This version is in active production use in [HTTP Toolkit](https://httptoolkit.tech)._\n\n## Install\n\n```shell\n# to use in cli\nnpm install --global @httptoolkit/httpsnippet\n\n# to use as a module\nnpm install --save @httptoolkit/httpsnippet\n```\n\n## Usage\n\n```\n\n  Usage: httpsnippet [options] \u003cfiles ...\u003e\n\n  Options:\n\n    -h, --help                output usage information\n    -V, --version             output the version number\n    -t, --target \u003ctarget\u003e     target output\n    -c, --client [client]     target client library\n    -o, --output \u003cdirectory\u003e  write output to directory\n    -x, --extra [{\"optionKey\": \"optionValue\"}]  provide extra options for the target/client\n\n```\n\n###### Example\n\nprocess single file: [`example.json`](test/fixtures/requests/full.json) in [HAR Request Object](http://www.softwareishard.com/blog/har-12-spec/#request) format, or full [HAR](http://www.softwareishard.com/blog/har-12-spec/#log) log format:\n\n```shell\nhttpsnippet example.json --target node --client unirest --output ./snippets\n```\n\n```shell\n$ tree snippets\nsnippets/\n└── example.js\n```\n\nprocess multiple files:\n\n```shell\nhttpsnippet ./*.json --target node --client request --output ./snippets\n```\n\n```shell\n$ tree snippets/\nsnippets/\n├── endpoint-1.js\n├── endpoint-2.js\n└── endpoint-3.js\n```\n\nprovide extra options:\n\n```shell\nhttpsnippet example.json --target http --output ./snippets -x '{\"autoHost\": false, \"autoContentLength\": false}'\n```\n\n\n## API\n\n### HTTPSnippet(source)\n\n#### source\n\n*Required*\nType: `object`\n\nName of [conversion target](TARGETS.md)\n\n```js\nvar HTTPSnippet = require('httpsnippet');\n\nvar snippet = new HTTPSnippet({\n  method: 'GET',\n  url: 'http://mockbin.com/request'\n});\n```\n\n### convert(target [, options])\n\n#### target\n\n*Required*\nType: `string`\n\nName of [conversion target](TARGETS.md)\n\n#### options\n\nType: `object`\n\nTarget options, *see [target docs](https://github.com/httptoolkit/httpsnippet/blob/main/TARGETS.md) for details*\n\n```js\nvar HTTPSnippet = require('httpsnippet');\n\nvar snippet = new HTTPSnippet({\n  method: 'GET',\n  url: 'http://mockbin.com/request'\n});\n\n// generate Node.js: Native output\nconsole.log(snippet.convert('node'));\n\n// generate Node.js: Native output, indent with tabs\nconsole.log(snippet.convert('node', {\n  indent: '\\t'\n}));\n```\n\n### convert(target [, client, options])\n\n#### target\n\n*Required*\nType: `string`\n\nName of [conversion target](TARGETS.md)\n\n#### client\n\nType: `string`\n\nName of conversion target [client library](TARGETS.md)\n\n#### options\n\nType: `object`\n\nTarget options, *see [target docs](https://github.com/httptoolkit/httpsnippet/blob/main/TARGETS.md) for details*\n\n```js\nvar HTTPSnippet = require('httpsnippet');\n\nvar snippet = new HTTPSnippet({\n  method: 'GET',\n  url: 'http://mockbin.com/request'\n});\n\n// generate Shell: cURL output\nconsole.log(snippet.convert('shell', 'curl', {\n  indent: '\\t'\n}));\n\n// generate Node.js: Unirest output\nconsole.log(snippet.convert('node', 'unirest'));\n```\n\n### addTarget(target)\n#### target\n\n*Required*\nType: `object`\n\nRepresentation of a [conversion target](https://github.com/httptoolkit/httpsnippet/blob/main/CONTRIBUTING.md#creating-new-conversion-targets). Can use this to use targets that are not officially supported.\n\n```js\nconst customLanguageTarget = require('httpsnippet-for-my-lang');\nHTTPSnippet.addTarget(customLanguageTarget);\n```\n\n### addTargetClient(target, client)\n### target\n\n*Required*\nType: `string`\n\nName of [conversion target](TARGETS.md)\n\n### client\n\n*Required*\nType: `object`\n\nRepresentation of a [conversion target client](https://github.com/httptoolkit/httpsnippet/blob/main/CONTRIBUTING.md#creating-new-conversion-targets). Can use this to use target clients that are not officially supported.\n\n```js\nconst customClient = require('httpsnippet-for-my-node-http-client');\nHTTPSnippet.addTargetClient('node', customClient);\n```\n\n## Documentation\n\nAt the heart of this module is the [HAR Format](http://www.softwareishard.com/blog/har-12-spec/#request) as the HTTP request description format, please review some of the sample JSON HAR Request objects in [test fixtures](/test/fixtures/requests), or read the [HAR Docs](http://www.softwareishard.com/blog/har-12-spec/#request) for more details.\n\nFor detailed information on each target, please review the [target docs](./TARGETS.md).\n\n## Bugs and feature requests\n\nHave a bug or a feature request? Please first read the [issue guidelines](CONTRIBUTING.md#using-the-issue-tracker) and search for existing and closed issues. If your problem or idea is not addressed yet, [please open a new issue](/issues).\n\n## Contributing\n\nPlease read through our [contributing guidelines](CONTRIBUTING.md). Included are directions for opening issues, coding standards, and notes on development.\n\nFor info on creating new conversion targets, please review this [guideline](https://github.com/httptoolkit/httpsnippet/blob/main/CONTRIBUTING.md#creating-new-conversion-targets)\n\nMoreover, if your pull request contains JavaScript patches or features, you must include relevant unit tests.\n\nEditor preferences are available in the [editor config](.editorconfig) for easy use in common text editors. Read more and download plugins at \u003chttp://editorconfig.org\u003e.\n\n## Versioning\n\nFor transparency into our release cycle and in striving to maintain backward compatibility, this project is maintained under the Semantic Versioning guidelines. Sometimes we screw up, but we'll adhere to these rules whenever possible.\n\nReleases will be numbered with the following format:\n\n`\u003cmajor\u003e.\u003cminor\u003e.\u003cpatch\u003e`\n\nAnd constructed with the following guidelines:\n\n- Breaking backward compatibility **bumps the major** while resetting minor and patch\n- New additions without breaking backward compatibility **bumps the minor** while resetting the patch\n- Bug fixes and misc changes **bumps only the patch**\n\nFor more information on SemVer, please visit \u003chttp://semver.org/\u003e.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttptoolkit%2Fhttpsnippet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhttptoolkit%2Fhttpsnippet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttptoolkit%2Fhttpsnippet/lists"}