{"id":21344472,"url":"https://github.com/s00d/request-templater","last_synced_at":"2026-01-06T06:40:58.776Z","repository":{"id":147015329,"uuid":"618424170","full_name":"s00d/request-templater","owner":"s00d","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-01T19:57:44.000Z","size":2255,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T13:47:57.607Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/s00d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-03-24T12:45:29.000Z","updated_at":"2024-06-01T19:57:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe4a4374-7ae7-4ce7-a824-ed849f761873","html_url":"https://github.com/s00d/request-templater","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Frequest-templater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Frequest-templater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Frequest-templater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Frequest-templater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s00d","download_url":"https://codeload.github.com/s00d/request-templater/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245735887,"owners_count":20663807,"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-11-22T01:19:11.894Z","updated_at":"2026-01-06T06:40:58.751Z","avatar_url":"https://github.com/s00d.png","language":"JavaScript","funding_links":["https://www.paypal.me/s00d"],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/request-templater.svg)](https://badge.fury.io/js/request-templater)\n[![npm downloads](https://img.shields.io/npm/dw/request-templater)](https://badge.fury.io/js/request-templater)\n[![NPM license](https://img.shields.io/npm/l/request-templater)](https://github.com/sood/request-templater/blob/master/LICENSE)\n[![npm type definitions](https://img.shields.io/npm/types/request-templater)](https://github.com/sood/request-templater)\n[![donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.me/s00d)\n[![GitHub Repo stars](https://img.shields.io/github/stars/sood/request-templater?style=social)](https://github.com/sood/request-templater)\n\n# RequestTemplater\n\nRequestTemplater is a class for generating HTTP request examples based on templates for different programming languages.\n\n# Example\n\n[Show](https://s00d.github.io/request-templater/)\n\n## Installation\nTo install RequestTemplater, run the following command:\n\n```npm install request-templater```\n\n## Usage\nTo get started with RequestTemplater, create an instance of the class:\n\n```js\nimport RequestTemplater from 'request-templater';\n\nconst requestTemplater = new RequestTemplater();\n```\n\nThen you can set the base URL and other request parameters:\n```js\nrequestTemplater.baseUrl('https://example.com/api')\n.method('GET')\n.url('users/123')\n.params([\n{ in: 'query', name: 'page', value: '1' },\n{ in: 'query', name: 'limit', value: '10' },\n{ in: 'headers', name: 'Authorization', value: 'Bearer xxxxxxxxxxxx' }\n]);\n```\nAfter that, you can generate a request example for the desired language:\n\n```js\nconst code = requestTemplater.lang('javascript').library('axios').generate();\nconsole.log(code);\nIn this example, code in the JavaScript language will be generated using the Axios library.\n```\n\n## Methods\n### baseUrl(value: string): RequestTemplater\nMethod for setting the base URL for requests.\n\n### method(value: 'GET'|'POST'|'PUT'|'DELETE'|'PATCH'|'HEAD'|'OPTIONS'): RequestTemplater\nMethod for setting the HTTP method for requests.\n\n### url(value: string): RequestTemplater\nMethod for setting the path for requests.\n\n### params(value: Array\u003cParam\u003e): RequestTemplater\nMethod for setting request parameters.\n\n### mimeType(value: \"application/x-www-form-urlencoded\"|\"application/json\"|'multipart/form-data'): RequestTemplater\nMethod for setting the MIME type for requests.\n\n### lang(value: string): RequestTemplater\nMethod for setting the programming language for which a request example will be generated.\n\n### library(value: string): RequestTemplater\nMethod for setting the library that will be used to send the request.\n\n### generate(): string\nMethod for generating a request example based on the specified parameters.\n\n### generateHighlight(): string\nMethod for generating a request example based on the specified parameters with highlight.js tags.\n\nNeed add style, for example: ```\u003clink rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/tokyo-night-dark.min.css\" integrity=\"sha512-dSQLLtgaq2iGigmy9xowRshaMzUHeiIUTvJW/SkUpb1J+ImXOPNGAI7ZC8V5/PiN/XN83B8uIk4qET7AMhdC5Q==\" crossorigin=\"anonymous\" referrerpolicy=\"no-referrer\" /\u003e```\n\n### config(): Object\nMethod for getting a list of available templates for generating request examples.\n\n\n## Language and Libraries\n\n| Language    | Libraries                            |\n|-------------|--------------------------------------|\n| Swift       | URLSession, Alamofire                |\n| Shell       | wget, httpie, curl                   |\n| Scala       | scalaj-http, http4s, akka            |\n| Rust        | surf, reqwest, hyper                 |\n| Ruby        | RestClient, http                     |\n| Python      | requests, http                       |\n| PowerShell  | WebRequest, RestMethod               |\n| PHP         | http2, http1, Guzzle, curl           |\n| Perl        | UserAgent, Tiny, Request             |\n| OCaml       | httpaf, cohttp_lwt                   |\n| Objective-C | NSURLSession, AFNetworking           |\n| Lua         | httpclient, http, curl               |\n| Kotlin      | OkHttp3, Java, Fuel                  |\n| JavaScript  | jQuery, Fetch, Axios, XMLHttpRequest |\n| Java        | Unirest, OkHttp, NetHttp, AsyncHttp  |\n| HTTP        | RFC7230                              |\n| Go          | http, fasthttp                       |\n| Dart        | http_client, http, Dio               |\n| C#          | RestSharp, HttpClient                |\n| C++         | iostream, curl, Arduino              |\n| Clojure     | Ring-Client, clj-http                |\n| C           | ghttp, curl                          |\n| Brainfuck   | Brainfuck                            |\n| R           | RCurl, httr                          |\n\n## cli\n\nInstall the request-templater package globally using npm:\n\n```bash\nnpm install -g request-templater\n```\n\nTo use Request Templater, run the request-templater command in your terminal, specifying the necessary parameters. For example:\n\nrequest-templater --url https://api.example.com/users --method POST --lang bash --library curl --params '[{in: \"query\", name: \"param\", value: 1}]'\nIn this example, we're specifying the URL, request method, programming language (javascript), and request parameters in JSON format.\n\nRequest Templater supports the following parameters:\n\n`-u, --url \u003curl\u003e`: The URL of the request (required)\n`-m, --method \u003cmethod\u003e`: The HTTP method (defaults to GET)\n`-l, --language \u003clanguage\u003e`: The programming language to generate code in (defaults to javascript)\n`-t, --mimeType \u003cmimeType\u003e`: The MIME type of the request (optional)\n`-p, --params \u003cparams\u003e`: The request parameters (optional)\n`-b, --baseUrl \u003cbaseUrl\u003e`: The base URL for the request (optional)\n`-r, --library \u003clibrary\u003e`: The HTTP library to use for making the request (defaults to xhr)\n\n\nTo get help on the command line parameters, run the request-templater -h command:\n```bash\nrequest-templater -h\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs00d%2Frequest-templater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs00d%2Frequest-templater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs00d%2Frequest-templater/lists"}