Mailjet web API
Mailjet unique algorithm boosts your deliverability and the platform provides in-depth insight so you can optimize more than ever.
More info on Mailjet.com
Info on the API can be found here
To install maljet run
npm install mailjet
In order to use mailjet you need to require it and instantiate it first:
var Mailjet = ;var instance = 'APIKEY' 'SECRETKEY'secure : true // When true uses https when false it uses http, default is trueoutput : 'json' // The output type you prefer, default is json, you can choose between php, json, xml, serialize, html, csv;
The options object can be skiped so you can simply get an instance like this:
var instance = new Mailjet('APIKEY', 'SECRETKEY'); of course you replace APIKEY with your API key and SECRETKEY with your Secret key
To call a method from API you use
sendRequest method. This method gets 4 optional parameters:
method(String) / Required: Is the method you need to call.
params(Object) / Optional: The params you want to send.
request(String) / Optional: The type of request you want to make, it's either
POST, by default is
cb(Function) / Optional: This is the callback method that will be triggered when the API request is done. Callback returns 4 params as well:
err: Error object in case of failure
status: The request status code
data: The returned data object (WARNING: In case of API error (like internal errors) this may also be html instead of object)
headers: The returned headers
In this example all the params are used.
In this example the
request param is omited.
In this example the
request params are omited as we don't need them.
In case callback function is not provided then a promise is returned.
var promise = instance;promise;
result in case of failure is an error object, otherwise it's an object with
headers properties which are same as in callback method.
make in mailjet root directory.
# make* Project Tasksmake deps Install Dependenciesmake deps-clean Removes the node_modules directorymake lint Run Code Analysis tool (scans entire project)* Test Suitesmake tests Run All testsmake test-basic Run Basic tests (module specific tests)make test-api Run API Methods tests (test fixtures required)make test-user Run User Methods tests (test fixtures required)make test-contact Run Contact Methods tests (test fixtures required)make test-lists Run Lists Methods tests (test fixtures required)make test-message Run Message Methods tests (test fixtures required)make test-report Run Report Methods tests (test fixtures required)make test-cleanup Run Cleanup Methods tests (test fixtures required)