{"id":19494798,"url":"https://github.com/ceejbot/chainable-request","last_synced_at":"2026-06-15T19:31:24.157Z","repository":{"id":2274019,"uuid":"3230779","full_name":"ceejbot/chainable-request","owner":"ceejbot","description":"Simple wrapper for node.js http requests with a chainable API. For when I don't need to achieve machine sentience with Request.","archived":false,"fork":false,"pushed_at":"2017-05-02T18:08:15.000Z","size":43,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-30T18:28:12.997Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/ceejbot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-20T23:21:26.000Z","updated_at":"2014-04-03T08:50:07.000Z","dependencies_parsed_at":"2022-08-26T21:40:30.674Z","dependency_job_id":null,"html_url":"https://github.com/ceejbot/chainable-request","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ceejbot/chainable-request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fchainable-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fchainable-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fchainable-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fchainable-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ceejbot","download_url":"https://codeload.github.com/ceejbot/chainable-request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fchainable-request/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34377872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10T21:33:22.566Z","updated_at":"2026-06-15T19:31:24.131Z","avatar_url":"https://github.com/ceejbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Inspired by [api-request](https://github.com/adaburrows/api_request), but handles chunked tranfers and binary data. Notably, also takes the output of `url.parse()` as ideal input for its constructor.\n\nI wrote this because I needed it but there's no guarantee it's suitable for general use yet. My test cases were sort of ad-hoc.\n\nBrief example:\n\n```javascript\nvar requester = require('chainable-request').chainableRequest;\n\nnew requester({ hostname: 'localhost', port: 3000 }).\n\tcontent_type('application/x-www-form-urlencoded').\n\tbody({'why': 'because I said so'}).\n\tpost('/reasons').\n\ton('reply', function(response, body)\n{\n\tconsole.log(body);\n};\n```\n\nOr a chunked get:\n\n```javascript\nnew requester({host: 'www.google.com' }).\n\theaders({ 'user-agent': 'Pretend To Be Mozilla 4.0' }).\n\tget('/').\n\ton('reply', function(response, body)\n{\n\tconsole.log(response.headers['transfer-encoding']);\n\tconsole.log(body.toString());\n});\n```\n\n## Creating a new request.\n\n`var requester = new chainableRequest(options);`\n\nCreates a new requester object modified by the requested options. The default request is to http://localhost:80/ using method GET.\n\nThe output of `url.parse()` is perfect input for `options`. Options is a hash containing one or any of:\n\nhostname\n: String with hostname or dotted quad. `localhost` by default.\n\nhost\n: Synonym for *host*.\n\nport\n: Integer port number. `80` by default.\n\npath\n: String with path to request. `/` by default.\n\nprotocol\n: String with desired protocol; must be `http` or `https`. `http` by default.\n\n\n## Setting up the request.\n\n`requester.host(hostname)`\n\nSets the host to the passed-in string name or dotted quad. Returns the requester object.\n\n`requester.port(portnum)`\n\nSets the port number to the passed-in integer. Returns the requester object.\n\n`requester.protocol(proto)`\n\nSets the protocol to the passed-in string. Returns the requester object.\n\n`requester.headers(params)`\n\nA hash of header name/value pairs. Returns the requester object.\n\n`requester.content_type(type)`\n\nSpecial case handling for the popular __Content-Type__ header. *Type* is a string containing the content-type to advertise. Returns the requester object.\n\n`requester.query(params)`\n\n*Params* must be a hash, which is turned into a query string using querystring.stringify. Used only in GETs. Returns the requester object.\n\n`requester.body(data)`\n\nIf *data* is a hash, stringifies it using querystring. Otherwise, sets the request payload without further processing. Returns the requester object.\n\n## Executing the request\n\nExecute a request by calling one of the gang of four methods:\n\n```\nrequester.get(path);\nrequester.post(path);\nrequester.put(path);\nrequester.delete(path);\n```\n\n*path* can be omitted to use a previously-configured path.\n\n## Receiving the response\n\nHandle the 'reply' and 'error' events.\n\n```javascript\nrequester\n\t.get()\n\t.on('reply', function(response, body)\n{\n\t// process successful request\n})\n\t.on('error', function(err)\n{\n\t// process error\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Fchainable-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceejbot%2Fchainable-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Fchainable-request/lists"}