@playt/brevo
v2.4.0
Published
NodeJS client for @getbrevo/brevo
Downloads
4,133
Readme
Brevo typescript
Brevo's API v3 TypeScript-Node Library
Brevo's API exposes the entire Brevo features via a standardized programmatic interface. Please refer to the full documentation to learn more.
This is the wrapper for the API. It implements all the features of the API v3. It supports promises.
Brevo's API matches the OpenAPI v2 definition. The specification can be downloaded here.
Installation
For Node.js
npm
The following recommended installation requires npm. If you are unfamiliar with npm, see the npm docs.
Then install it via:
npm i @getbrevo/brevo --save
# or
yarn add @getbrevo/brevo
Getting Started
Once you have installed the node module in your project, you can execute the following sample code JS code :
import BrevoApi from "@getbrevo/brevo";
const brevo = new BrevoApi({
headers: {
"api-key": "YOUR_API_KEY",
},
});
brevo.account
.getAccount()
.then((data) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error) => {
console.error(error);
});
import BrevoApi from "@getbrevo/brevo";
const brevo = new BrevoApi({
headers: {
"api-key": "YOUR_API_KEY",
},
});
brevo.smtp
.sendTransacEmail({
subject: "My {{params.subject}}",
htmlContent:
"<html><body><h1>This is my first transactional email {{params.parameter}}</h1></body></html>",
sender: {
name: "John Doe",
email: "[email protected]",
},
to: [{ email: "[email protected]", name: "Jane Doe" }],
cc: [{ email: "[email protected]", name: "Janice Doe" }],
bcc: [{ email: "[email protected]", name: "John Doe" }],
replyTo: { email: "[email protected]", name: "John Doe" },
headers: { "Some-Custom-Name": "unique-id-1234" },
params: { parameter: "My param value", subject: "New Subject" },
})
.then((data) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error) => {
console.error(error);
});
For more examples, refer the Endpoints Guide
Contributing
Please refer to the CONTRIBUTING file.