{"id":22635673,"url":"https://github.com/ethan7g/centra","last_synced_at":"2025-04-10T01:15:45.564Z","repository":{"id":45016595,"uuid":"149045266","full_name":"ethan7g/centra","owner":"ethan7g","description":"Core Node.js HTTP client","archived":false,"fork":false,"pushed_at":"2024-10-19T10:25:24.000Z","size":1627,"stargazers_count":54,"open_issues_count":10,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T01:15:37.131Z","etag":null,"topics":["http","http-client","http-library","http-request","http-requests","javascript","node","nodejs","request"],"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/ethan7g.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-16T23:38:01.000Z","updated_at":"2023-11-07T12:49:42.000Z","dependencies_parsed_at":"2024-12-07T20:34:44.032Z","dependency_job_id":"56296c66-7644-48c8-88ea-cde5533a5775","html_url":"https://github.com/ethan7g/centra","commit_stats":{"total_commits":52,"total_committers":6,"mean_commits":8.666666666666666,"dds":"0.15384615384615385","last_synced_commit":"359112a3d20e29c441a230084c37a17eaf1f9532"},"previous_names":["ethan7g/centra","ethanent/centra"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan7g%2Fcentra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan7g%2Fcentra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan7g%2Fcentra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan7g%2Fcentra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethan7g","download_url":"https://codeload.github.com/ethan7g/centra/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137891,"owners_count":21053775,"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":["http","http-client","http-library","http-request","http-requests","javascript","node","nodejs","request"],"created_at":"2024-12-09T03:07:25.572Z","updated_at":"2025-04-10T01:15:45.541Z","avatar_url":"https://github.com/ethan7g.png","language":"JavaScript","readme":"\u003cp align=\"center\" style=\"text-align: center;\"\u003e\u003cimg src=\"https://github.com/ethanent/centra/blob/master/media/centraLogo.png?raw=true\" width=\"400\"/\u003e\u003c/p\u003e\n\n\u003e The core lightweight HTTP client for Node\n\n[GitHub](https://github.com/ethanent/centra) | [NPM](https://npmjs.com/package/centra)\n\n## Install\n\n```shell\nnpm i centra\n```\n\n## Why centra?\n\ncentra is the best request library for developers; it provides a number of extremely useful features while still being one of the most lightweight Node.js HTTP client libraries available.\n\n## Use centra!\n\nFirst, require the library.\n\n```js\nconst c = require('centra')\n```\n\nThen let's make a request in an async function!\n\n```js\n;(async () =\u003e {\n\tconst res = await c('https://example.com').send()\n\n\tconsole.log(await res.text())\n})()\n```\n\n## More advanced usage\n\n### Send data in a JSON body\n\n```js\nc('https://example.com/nonexistentJSONAPI', 'POST').body({\n\t'name': 'Ethan'\n}, 'json').send().then((res) =\u003e {\n\t/*...*/\n})\n```\n\n### Send data in a form body\n\n```js\nc('https://example.com/nonexistentJSONAPI', 'POST').body({\n\t'name': 'Ethan'\n}, 'form').send().then((res) =\u003e {\n\t/*...*/\n})\n```\n\n### Set query string parameters\n\nOne at a time:\n\n```js\nc('https://example.com/user').query('id', 'u1817760').send().then((res) =\u003e {\n\t/*...*/\n})\n```\n\nMany at a time:\n\n```js\nc('https://example.com/user').query({\n\t'id', 'u1817760',\n\t'name': 'Ethan'\n}).send().then((res) =\u003e {\n\t/*...*/\n})\n```\n\n### Set a request timeout\n\n```js\nc('https://example.com').timeout(2000).send().then((res) =\u003e {\n\t// Success!\n}).catch((err) =\u003e {\n\t// Has the request timed out?\n})\n```\n\n### Stream a request's response\n\nIn this example, the [stream](https://nodejs.org/api/stream.html) is piped to a file:\n\n```js\n// require the fs module beforehand\n\nc('https://example.com').stream().send().then((stream) =\u003e stream.pipe(fs.createWriteStream(path.join(__dirname, 'logo.png'))))\n```\n\n### Follow redirects\n\n```js\nc('https://example.com/').followRedirects(5).send()\n```\n\n### Switch paths on the fly\n\n```js\nc('https://example.com/test').path('/hello').send()\n\n// This will make a request to https://example.com/test/hello\n```\n\n### Specify request headers\n\nOne at a time:\n\n```js\nc('https://example.com').header('Content-Type', 'application/json').send()\n```\n\nMany at a time:\n\n```js\nc('https://example.com').header({\n\t'Content-Type': 'application/json',\n\t'X-Connecting-With': 'centra'\n}).send()\n```\n\n### Modify core HTTP request options\n\nSee [http.request](https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_http_request_url_options_callback)'s options for more information about core HTTP request options.\nLet's change our localAddress as an example.\n\n```js\nc('https://example.com').option('localAddress', '127.0.0.2').send()\n```\n\n### Accept compressed responses\n\n```js\nc('https://example.com').compress().send()\n\n// This will cause centra to accept compressed content from the server. (gzip and deflate are currently supported)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethan7g%2Fcentra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethan7g%2Fcentra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethan7g%2Fcentra/lists"}