Socket
Socket
Sign inDemoInstall

@sendgrid/client

Package Overview
Dependencies
5
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.0-beta.5 to 6.0.0

USAGE.md

4

package.json
{
"name": "@sendgrid/client",
"description": "SendGrid NodeJS API client",
"version": "6.0.0-beta.5",
"version": "6.0.0",
"author": "SendGrid <dx@sendgrid.com> (sendgrid.com)",

@@ -30,3 +30,3 @@ "contributors": [

"dependencies": {
"@sendgrid/helpers": "^6.0.0-beta.5",
"@sendgrid/helpers": "^6.0.0",
"request": "^2.81.0"

@@ -33,0 +33,0 @@ },

@@ -1,20 +0,69 @@

## Client for the Sendgrid API
This client library is used by the other service packages to make requests to the Sendgrid API. You can however use it independently to make custom requests to the API as well.
**This package is part of a monorepo, please see [this README](https://github.com/sendgrid/sendgrid-nodejs/blob/master/README.md) for details.**
### Usage
# Client for the Sendgrid v3 Web API
This client library is used by the other [SendGrid service packages](https://www.npmjs.com/org/sendgrid) to make requests to the [Sendgrid v3 Web API](https://sendgrid.com/docs/API_Reference/api_v3.html). You can also use it independently to make custom requests to the SendGrid v3 Web API and other HTTP APIs.
To be notified when this package is updated, please subscribe to email [notifications](https://dx.sendgrid.com/newsletter/nodejs) for releases and breaking changes.
# Installation
## Prerequisites
- Node.js version 6, 7 or 8
- The SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-nodejs)
## Setup Environment Variables
Update the development environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys), for example:
```bash
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env
```
## Install Package
The following recommended installation requires [npm](https://npmjs.org/). If you are unfamiliar with npm, see the [npm docs](https://npmjs.org/doc/). Npm comes installed with Node.js since node version 0.8.x therefore you likely already have it.
```sh
npm install --save @sendgrid/client
```
You may also use [yarn](https://yarnpkg.com/en/) to install.
```sh
yarn add @sendgrid/client
```
<a name="general"></a>
## General v3 Web API Usage Example
Please see [USAGE.md](https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/client/USAGE.md) for all endpoint examples for the [SendGrid v3 Web API](https://sendgrid.com/docs/API_Reference/api_v3.html).
```js
//Load client
const sgClient = require('@sendgrid/client');
const client = require('@sendgrid/client');
client.setApiKey(process.env.SENDGRID_API_KEY);
const request = {
method: 'GET',
url: '/v3/api_keys'
};
client.request(request)
.then(([response, body]) => {
console.log(response.statusCode);
console.log(response.body);
})
```
//Set API key
sgClient.setApiKey(process.env.SENDGRID_API_KEY);
//Add a custom default header
## Add a Custom Default Header
```js
sgClient.setDefaultHeader('User-Agent', 'Some user agent string');
```
//Change request defaults (e.g. baseUrl)
## Change Request Defaults
```js
sgClient.setDefaultRequest('baseUrl', 'https://api.sendgrid.com/');
```
### Overwrite Promise implementation
## Overwrite Promise Implementation
You can overwrite the promise implementation you want the client to use. Defaults to the ES6 `Promise`:

@@ -25,1 +74,34 @@

```
<a name="announcements"></a>
# Announcements
All updates to this library are documented in our [CHANGELOG](https://github.com/sendgrid/sendgrid-nodejs/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-nodejs/releases). You may also subscribe to email [release notifications](https://dx.sendgrid.com/newsletter/nodejs) for releases and breaking changes.
<a name="roadmap"></a>
# Roadmap
If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/sendgrid/sendgrid-nodejs/issues) and [pull requests](https://github.com/sendgrid/sendgrid-nodejs/pulls). We would love to hear your feedback.
<a name="contribute"></a>
# How to Contribute
We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/sendgrid/sendgrid-nodejs/blob/master/CONTRIBUTING.md) guide for details.
* [Feature Request](https://github.com/sendgrid/sendgrid-nodejs/tree/master/CONTRIBUTING.md#feature_request)
* [Bug Reports](https://github.com/sendgrid/sendgrid-nodejs/tree/master/CONTRIBUTING.md#submit_a_bug_report)
* [Improvements to the Codebase](https://github.com/sendgrid/sendgrid-nodejs/tree/master/CONTRIBUTING.md#improvements_to_the_codebase)
<a name="troubleshooting"></a>
# Troubleshooting
Please see our [troubleshooting guide](https://github.com/sendgrid/sendgrid-nodejs/blob/master/TROUBLESHOOTING.md) for common library issues.
<a name="about"></a>
# About
@sendgrid/client is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com).
@sendgrid/client is maintained and funded by SendGrid, Inc. The names and logos for @sendgrid/client are trademarks of SendGrid, Inc.
![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)

@@ -40,3 +40,3 @@ 'use strict';

baseUrl: 'https://api.sendgrid.com/',
uri: '',
url: '',
method: 'GET',

@@ -92,2 +92,8 @@ headers: {},

//Keep URL parameter consistent
if (data.uri) {
data.url = data.uri;
delete data.uri;
}
//Merge data with empty request

@@ -94,0 +100,0 @@ const request = mergeData(this.defaultRequest, data);

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc