Skip to content
This repository was archived by the owner on May 18, 2020. It is now read-only.

Commit 4b2ee02

Browse files
committed
initial commit
1 parent b26a0bb commit 4b2ee02

File tree

7 files changed

+1071
-2
lines changed

7 files changed

+1071
-2
lines changed

README.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,45 @@
1-
# sendinblue-nodejs-api-npm
2-
Official Sendinblue provided API V2 npm Library
1+
# SendinBlue npm Library
2+
3+
This is [SendinBlue](https://www.sendinblue.com) provided API V2 npm library. It implements the various exposed APIs that you can read more about on https://apidocs.sendinblue.com.
4+
5+
SendinBlue API's use HTTP Authentication through an api key. You can create your api key from [API Console](https://my.sendinblue.com/advanced/apikey), after you sign up for an account with SendinBlue. You must use latest version 2.0, access key, for accessing APIs.
6+
7+
8+
## Installation
9+
10+
``` npm install sendinblue-api --save ```
11+
12+
13+
## Dependencies
14+
15+
This version of the library depends on Restler 3.2.2
16+
17+
18+
## Usage
19+
20+
Assuming that you have installed this package, use below sample script to get started.
21+
22+
```javascript
23+
24+
var sendinblue = require('../sendinblue-api');
25+
var sendinObj = new sendinblue('https://api.sendinblue.com/v2.0/', 'your_api_key', 5000); //Optional parameter: Timeout in MS
26+
27+
sendinObj.get_account().on('complete', function(data) {
28+
data = JSON.parse(data);
29+
console.log(data);
30+
});
31+
```
32+
33+
34+
## Release History
35+
36+
* 1.0.0 Initial release
37+
38+
39+
## Support and Feedback
40+
41+
Be sure to visit the SendinBlue official [documentation website](https://apidocs.sendinblue.com) for additional information about our API.
42+
43+
If you find a bug, please submit the issue in [Github directly](https://github.com/mailin-api/api-node-js/issues).
44+
45+
As always, if you need additional assistance, drop us a note [here](https://apidocs.sendinblue.com/support/).

examples/create_update_user.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var sendinblue = require('../sendinblue-api');
2+
var sendinObj = new sendinblue('https://api.sendinblue.com/v2.0/', 'your_api_key', 5000);
3+
4+
var input = { 'email': 'example@example.net',
5+
'attributes': {
6+
'NAME': 'example',
7+
'SURNAME': 'example'
8+
},
9+
'blacklisted': 0,
10+
'listid': [291]
11+
};
12+
13+
sendinObj.create_update_user(input).on('complete', function(data) {
14+
data = JSON.parse(data);
15+
console.log(data);
16+
});
17+
18+
/*
19+
Output Response
20+
{
21+
code: 'success',
22+
message: 'Email was updated successfully. ',
23+
data:[]
24+
}
25+
*/

examples/delete_user.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var sendinblue = require('../sendinblue-api');
2+
var sendinObj = new sendinblue('https://api.sendinblue.com/v2.0/', 'your_api_key', 5000);
3+
4+
var input = { 'email': 'example@example.net' };
5+
6+
sendinObj.delete_user(input).on('complete', function(data) {
7+
data = JSON.parse(data);
8+
console.log(data);
9+
});
10+
11+
/*
12+
Output Response
13+
{
14+
code: 'success',
15+
message: 'Email was removed successfully from all lists',
16+
data:[]
17+
}
18+
*/

examples/get_account.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var sendinblue = require('../sendinblue-api');
2+
var sendinObj = new sendinblue('https://api.sendinblue.com/v2.0/', 'xnZCHqGbBVTXRjU0', 5000);
3+
4+
sendinObj.get_account().on('complete', function(data) {
5+
data = JSON.parse(data);
6+
console.log(data);
7+
});
8+
9+
/*
10+
Output Response
11+
{
12+
code: 'success',
13+
message: 'Data retrieved',
14+
data: [{
15+
plan_type: 'PAG',
16+
credits: 407,
17+
credit_type: 'Send Limit'
18+
}, {
19+
plan_type: 'SMS',
20+
credits: 64,
21+
credit_type: 'Send Limit'
22+
}, {
23+
first_name: 'Lorem',
24+
last_name: 'Domer',
25+
email: 'lorem@ipsum.com',
26+
company: null,
27+
address: 'D-247/32',
28+
city: 'Los Angeles',
29+
zip_code: '90001',
30+
country: 'United States'
31+
}]
32+
}
33+
34+
*/

examples/send_email.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var sendinblue = require('../sendinblue-api');
2+
var sendinObj = new sendinblue('https://api.sendinblue.com/v2.0/', 'your_api_key', 5000);
3+
4+
var input = { 'to': { 'to@example.net': 'to whom!' },
5+
'from': ['from@email.com', 'from email!'],
6+
'subject': 'Test mail form sendinblue',
7+
'html': 'This is the <h1>HTML</h1>'
8+
};
9+
10+
sendinObj.send_email(input).on('complete', function(data) {
11+
data = JSON.parse(data);
12+
console.log(data);
13+
});
14+
15+
/*
16+
Output Response
17+
18+
{
19+
code: 'success',
20+
message: 'Email sent successfully.',
21+
data:[]
22+
}
23+
*/

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "sendinblue-api",
3+
"version": "1.0.0",
4+
"description": "Official SendinBlue provided API V2 npm library",
5+
"main": "sendinblue-api.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [
10+
"sendinblue"
11+
],
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/mailin-api/sendinblue-nodejs-api-npm.git"
15+
},
16+
"author": {
17+
"name" : "SendinBlue",
18+
"email": "developers@sendinblue.com"
19+
},
20+
"license": "ISC",
21+
"bugs": {
22+
"url": "https://github.com/mailin-api/sendinblue-nodejs-api-npm/issues"
23+
},
24+
"homepage": "https://github.com/mailin-api/sendinblue-nodejs-api-npm/",
25+
"dependencies": {
26+
"restler": "^3.2.2"
27+
}
28+
}

0 commit comments

Comments
 (0)