request-api
Sugar API for @request/interface consumers
A JavaScript wrapper that adds a friendlier basic or chainable API on top of any HTTP client, so you can make requests without repetitive boilerplate.
What is @request/api?
This is a JavaScript library that gives you a nicer way to make HTTP requests in your code. Instead of writing out long, repetitive HTTP request calls, you get to choose between two friendly interfaces: a simple straightforward style or a more fluent, chainable style. It's a wrapper that sits on top of a lower-level HTTP client and makes it easier to work with.
How it works
The library doesn't do the actual HTTP work itself—instead, it takes whatever HTTP client you give it and wraps it with convenient methods. You pass in your HTTP client when you set up the library, then call methods like .get(), .post(), or .put() to make requests. With the basic API, you call everything in one go: request.get(url, options, callback). With the chain API, you build up your request step by step, adding options like query strings or headers one method at a time before finally sending it. You can also customize what methods are available or give them aliases so they match your project's naming style.
Who would use it and why
If you're building a Node.js application or service that needs to talk to other APIs or servers over HTTP, this library saves you from repeating yourself. For example, a startup building a backend service might use the chain API to make code more readable: instead of nesting options inside an object, you write request.get(url).header('Authorization', token).callback(handleResponse). It also supports promises out of the box, so if your codebase uses async/await or promise-based patterns, you can wire it up to work that way too.
The main flexibility here is that you're not locked into one particular HTTP client—you can swap in whichever one your team prefers, and get the same clean interface regardless. It's useful when you want the convenience of a friendly API without rewriting how you handle HTTP under the hood.
Where it fits
- Wrap an existing HTTP client to get a cleaner basic or chainable request API.
- Build readable request chains like setting headers and query strings step by step before sending.
- Swap the underlying HTTP client without changing how the rest of your code makes requests.
- Use promise-based or async/await request calls in a Node.js backend service.