Description
Wrap Restful API endpoints as callable functions.
Call HTTP based APIs like ordinary JavaScript functions.
wrapi alternatives and similar modules
Based on the "Web Frameworks" category.
Alternatively, view wrapi alternatives based on common mentions on social networks and blogs.
-
Nest
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications on top of TypeScript & JavaScript (ES6, ES7, ES8) π -
Nuxt.js
Nuxt is an intuitive and extendable way to create type-safe, performant and production-grade full-stack web apps and websites with Vue 3. [Moved to: https://github.com/nuxt/nuxt] -
egg
π₯ Born to build better enterprise frameworks and apps with Node.js & Koa -
AdonisJs Framework
π The Node.js Framework highly focused on developer ergonomics, stability and confidence -
TypeGraphQL
Create GraphQL schema and resolvers with TypeScript, using classes and decorators! -
Quick Start
π A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Alibaba Cloud, Tencent Cloud and traditional VM/Container. Super easy integrate with React and Vue. π -
ThinkJS
Use full ES2015+ features to develop Node.js applications, Support TypeScript. -
LoopBack
LoopBack makes it easy to build modern API applications that require complex integrations. -
Derby
MVC framework making it easy to write realtime, collaborative applications that run in both Node.js and browsers -
ActionHero
Actionhero is a realtime multi-transport nodejs API Server with integrated cluster capabilities and delayed tasks -
tinyhttp
π¦ 0-legacy, tiny & fast web framework as a replacement of Express -
Lad
Node.js framework made by a former @expressjs TC and @koajs team member. Built for @forwardemail, @spamscanner, @breejs, @cabinjs, and @lassjs. -
Marble.js
Marble.js - functional reactive Node.js framework for building server-side applications, based on TypeScript and RxJS. -
sqs-consumer
Build Amazon Simple Queue Service (SQS) based applications without the boilerplate -
FoalTS
Full-featured Node.js framework, with no complexity. π Simple and easy to use, TypeScript-based and well-documented. -
lychee.js
:seedling: Next-Gen AI-Assisted Isomorphic Application Engine for Embedded, Console, Mobile, Server and Desktop -
Hemera
π¬ Writing reliable & fault-tolerant microservices in Node.js https://hemerajs.github.io/hemera/ -
NestJS REST API boilerplate
NestJS boilerplate. Auth, TypeORM, Postgres, Mailing, I18N, Docker. -
Catberry
Catberry is an isomorphic framework for building universal front-end apps using components, Flux architecture and progressive rendering. -
dawson-cli
A serverless web framework for Node.js on AWS (CloudFormation, CloudFront, API Gateway, Lambda) -
AdonisJs Application
This repo is the pre-configured project structure to be used for creating ambitious web servers using AdonisJs. -
sqs-producer
Simple scaffolding for applications that produce SQS messages -
QueryQL
Easily add filtering, sorting, and pagination to your Node.js REST API through your old friend: the query string! -
express-version-route
A Node.js express middleware that implements API versioning for route controllers -
FortJs
Component based MVC web framework for nodejs targeting good code structures & modularity. -
khalis
Grab Blogger & Google Photos, mp4upload.com,cloudvideo.tv, etc streaming link -
Coher3nTS Project
Cross-platform project template using Electron and Angular with the Phaser game engine. Project has Flexbox integrated for easy and responsive organization of components around the Phaser canvas.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of wrapi or a related project?
README
wrapi
Wrap Restful API endpoints as callable functions.
Create a Rest API SDK under 3 minutes.
With wrapi
you make calls to HTTP based APIs just like ordinary JavaScript functions.
Installation
$ npm install wrapi --save
Or
$ yarn add wrapi
Easy Start
- Create a JSON file listing all API endpoints you want to work with.
- Wrap endpoints with
wrapi
. - Call individual endpoints as functions.
See [Sample Code](examples/github/sample1.js)
JSON File
Declare each endpoint in a json file as per the following specifications.
"function_name": {
"method": "HTTP_METHOD", // 'GET', 'POST', 'PUT', 'PATCH' or 'DELETE'
"path": "relative/path/to/:api/endpoint" // Use `express` style path params
}
E.g. a small set of github.com API:
{
"repo": {
"method" : "GET",
"path" : "repos/:owner/:repo"
},
"contributors": {
"method" : "GET",
"path" : "repos/:owner/:repo/contributors"
},
"languages": {
"method" : "GET",
"path" : "repos/:owner/:repo/languages"
},
"tags": {
"method" : "GET",
"path" : "repos/:owner/:repo/tags"
},
"branches": {
"method" : "GET",
"path" : "repos/:owner/:repo/branches"
}
}
Wrap endpoints
Create a API client object from wrapi
. Provide the base url for the API and the JSON object.
wrapi
will create a client object with all the necessary functions.
const endpoints = require('./github.api.json');
const wrapi = require('wrapi');
const client = new wrapi('https://api.github.com/', // base url for the API
endpoints // your json object
);
// client object contains functions to call the API
Register
Register additional API endpoints with the client object with a function name.
client.register('zen',
{
method : 'GET',
path: 'zen'
}
);
Make the call
Call API function with arguments and a callback.
// This will make GET request to 'https://api.github.com/repos/nodejs/node/contributors'
client.contributors('nodejs', 'node', function(err, contributors) {
if (!err) {
console.log(contributors);
}
});
client.zen(function(err, response) {
if (!err) {
console.log('Chris says "' + response + '"');
}
});
API
wrapi
is an open ended framework. It is not restricted any specific or a set of APIs.
All APIs providing HTTP interface to access the endpoints can be wrapped by wrapi,
so that you can quickly build your client application.
Endpoint Definition
Note: method
& path
/url
are required.
method
- Any one of the HTTP methods (default:"GET"
)path
- route path to API Endpoint. Supportsexpress
style path paramsquery
- an object consists of name-value pairs. This is optional. This is useful where resources are identified via query string parametersoptions
- options to override or to add specific to the API endpoint. E.g.{encoding:null}
returns the response data asBuffer
url
- fully qualified uri string to override. This is useful in cases where an API call connects to a different endpoint
Client object
The wrapi
object conveniently provides the client interface to the API. Create the object by calling new
wrapi()
.
The constructor takes the following arguments:
baseURL
- The base url for the API. E.g.https://api.github.com/
endpoints
- The JSON object listing the API endpoints. Provide{}
- empty object or a partial list and thenregister
(additional) endpoints lateroptions
- Optional parameter.wrapi
uses request module to connect to API server. Theoptions
parameter is the sameoptions
parameter used inrequest
Custom options
catchHTTP4xx5xx
- Set this option totrue
to treat HTTP status 4xx & 5xx as errors. Default value isfalse
. If set, theerr
argument in your callback function will contain the response body for 4xx & 5xx errors.
Register function
Add endpoints to client object.
register(functionName, endpointDefinition)
functionName
- Alias for the endpoint, also the name of the function to call.endpointDefinition
- JSON object defining the endpoint.
Function calls
Call API endpoints via the function in the client object. Arguments to the function depend on the API declaration in the JSON.
Provide the arguments in the following order:
- named
params
in the url path of the endpoint. eg.client.contributors('nodejs', 'node', // nodejs & node are path params
query string
as an object with name-value pairs. eg.client.repositories({since:364} // ?since=364
body
- JSON content forPOST
orPUT
methods. Skip this argument if not required for the call.- To POST
multipart/form-data
, set this argument as{"formData" : multipartContent }
- To POST
callback(err, data)
- a callback function for the results to be returned. The callback is called when the response is fetched or if there is an error. This callback function gets the results of the response.To
pipe
the results, pass a writable stream as the callback. Listen toerror
events on outputstream to catch streaming errors. See [example](examples/google/chartasstream.js).
Examples
In [examples](examples) folder.
Implementations
- Slack Web API
- Square Connect API
- Medium
- Twitter REST APIs
- Instagram API
- Genius API
- GIPHY API
- Riffsy's API
- PokΓ©mon API
License
[MIT](LICENSE)
*Note that all licence references and agreements mentioned in the wrapi README section above
are relevant to that project's source code only.