Quickly and easily access any RESTful or RESTful-like API.
If you are looking for the SendGrid API client library, please see this repo.
Announcements
All updates to this library are documented in our CHANGELOG.
Table of Contents
Installation
Prerequisites
- Node.js version 0.10, 0.12 or 4
You need to have a API key to use the app. To configure the API key in the environment variables follow these steps.
- create .env file in the root directory of the project.
- Copy the contents of .env_sample file in to the .env file
- Once you have obtained the API key, find the environment variable SENDGRID_API_KEY and assign your API key as it's value. As an example it should look like this
SENDGRID_API_KEY='<YOUR_API_KEY>';
Install Package
npm install sendgrid-rest
Quick Start
GET /your/api/{param}/call
var Client = Clientvar client = var request = clientvar param = 'myparam'requesthost = 'api.example.com'requestmethod = 'GET'requestpath = '/your/api/' + param + '/call'client
POST /your/api/{param}/call
with headers, query parameters and a request body.
var Client = Clientvar client = var request = clientrequesthost = 'api.example.com'requestheaders'Authorization' = 'Bearer XXXXXX'requestqueryParams'limit' = 100requestqueryParams'offset' = 0requestmethod = 'POST'var param = 'myparam'requestpath = '/your/api/' + param + '/call'requestBody = 'some': 0 'awesome': 1 'data': 3requestbody = requestBodyclient
Usage
Following is an example using SendGrid. You can get your free account here.
First, update your environment with your SENDGRID_API_KEY.
You can copy the .env_example file located in the "examples" folder to .env
in your project's root.
cp examples/.env_sample .env
Once you have edited the file and added your API Key, you can add the variable to your environment:
source .env
Here is the full working code.
To run the example:
node examples/example
======= Library Usage Documentation
Tests
Tests can be run through a Docker container which is defined in the docker-compose.yml file.
To run the tests, simply run docker-compose up
.
Roadmap
If you are interested in the future direction of this project, please take a look at our milestones. We would love to hear your feedback.
How to Contribute
We encourage contribution to our libraries, please see our CONTRIBUTING guide for details.
About
nodejs-http-client is guided and supported by the SendGrid Developer Experience Team.
nodejs-http-client is maintained and funded by SendGrid, Inc. The names and logos for nodejs-http-client are trademarks of SendGrid, Inc.