Is this documentation a joke ?
There is only a single feature, that does not even work. Authentication is a protected key. I'm sorry, but the team is obviousely not taking seriously the project or even involved in it. We just have to compare this sh*t to the golang sdk documentation to say so.
Even worst, commits are like "update sdk". Seriously ?
Jokes are for laughs, this documentation is a shame, it makes you want to change everything on the spot
I tried that, but it's not going well so far 😅 https://github.com/getbrevo/brevo-node/pull/19
This should work - example with ContactsApi:
let apiInstance = new SibApiV3Sdk.ContactsApi();
apiInstance.setApiKey(SibApiV3Sdk.ContactsApiApiKeys.apiKey, BREVO_API_KEY);
Glad someone said that cuz in 5 minutes of signing up i had just thought the same... how is possible that the basic tutotirial they have dont work?
not to meniton what the hell was in the mind of the person who created this shit? omg i've never seen such a messes up project since i left introduction to programming
zero design patterns completelly crazy mess
This works for me:
import * as Brevo from "@getbrevo/brevo";
let apiInstance = new Brevo.ContactsApi();
apiInstance.setApiKey(
Brevo.ContactsApiApiKeys.apiKey,
process.env.BREVO_API_KEY || ""
);
let createContact = new Brevo.CreateContact();
createContact.email = email;
createContact.listIds = [41];
createContact.attributes = {
FIRSTNAME: name,
COUNTRY: country,
};
await apiInstance.createContact(createContact);
Documentation is absolutely awful it's ridiculous. Incorrect and out of date information everywhere.
Such a waste of time! Documentation sucks! Going back to Sendgrid. "Better Than Brevo"!
Totally disappointed with this documentation!
Hello! Apologies to have a bad experience with our SDK. We have not been able to keep the documentation up to date but will try to keep it on a higher priority from now on. I have updated the documentation on Readme.md: https://github.com/getbrevo/brevo-node?tab=readme-ov-file#we-have-two-options
Please take a look and hope it helps.
Yeah, this was a waste if time today
Hello! Apologies to have a bad experience with our SDK. We have not been able to keep the documentation up to date but will try to keep it on a higher priority from now on. I have updated the documentation on Readme.md: https://github.com/getbrevo/brevo-node?tab=readme-ov-file#we-have-two-options
Please take a look and hope it helps.
I think it was still wrong. How API key could be setup should be as follows:
const apiKey = apiInstance.setApiKey(
brevo.TransactionalEmailsApiApiKeys.apiKey,
"YOUR API KEY"
);
Such a joke. This one of the worst docs I've seen. How can you push new SDK with this shit of a documentation!!??
Hello! Apologies to have a bad experience with our SDK. We have not been able to keep the documentation up to date but will try to keep it on a higher priority from now on. I have updated the documentation on Readme.md: https://github.com/getbrevo/brevo-node?tab=readme-ov-file#we-have-two-options
Please take a look and hope it helps.
It takes 5 minutes to update those TS errors. Why isn't anyone doing it? Any manager seeing this should realize that this is bad for the business when dozens of developers complain that there are errors in README examples.
For anyone looking for correct ES6 imports without TS errors, you can do this:
import { TransactionalEmailsApi, SendSmtpEmail, TransactionalEmailsApiApiKeys } from '@getbrevo/brevo'
const apiInstance = new TransactionalEmailsApi()
apiInstance.setApiKey(
TransactionalEmailsApiApiKeys.apiKey,
'<your-api-key>'
)
const sendSmtpEmail = new SendSmtpEmail()
And from there the rest of the code in the README will work.
We're still maintaining a version at @groupcards/brevo for anyone interested. See #19 for more details.
Also means you don't have to create new classes for every part of the api.
import BrevoApi from "@groupcards/brevo";
const brevo = new BrevoApi({
headers: {
"api-key": "YOUR_API_KEY",
},
});
const account = await brevo.account.getAccount()
We're still maintaining a version at @groupcards/brevo for anyone interested. See #19 for more details.
Also means you don't have to create new classes for every part of the api.
import BrevoApi from "@groupcards/brevo"; const brevo = new BrevoApi({ headers: { "api-key": "YOUR_API_KEY", }, }); const account = await brevo.account.getAccount()
This doesn't seem to work either. I'm getting a "BrevoApi is not a constructor" error.
We're still maintaining a version at @groupcards/brevo for anyone interested. See #19 for more details. Also means you don't have to create new classes for every part of the api.
import BrevoApi from "@groupcards/brevo"; const brevo = new BrevoApi({ headers: { "api-key": "YOUR_API_KEY", }, }); const account = await brevo.account.getAccount()This doesn't seem to work either. I'm getting a "BrevoApi is not a constructor" error.
Ah, looks like there was an issue with the build that meant to had to add .default to the end of the import. Would you be able to try again with version 2.2.0 to see if that fixes the issue?
We're still maintaining a version at @groupcards/brevo for anyone interested. See #19 for more details. Also means you don't have to create new classes for every part of the api.
import BrevoApi from "@groupcards/brevo"; const brevo = new BrevoApi({ headers: { "api-key": "YOUR_API_KEY", }, }); const account = await brevo.account.getAccount()This doesn't seem to work either. I'm getting a "BrevoApi is not a constructor" error.
Ah, looks like there was an issue with the build that meant to had to add
.defaultto the end of the import. Would you be able to try again with version2.2.0to see if that fixes the issue?
Yes it works after updating to the new version.
Thank you.
@alexbrazier I'm still getting "This expression is not constructable."
This is what I have:
import brevo from "@getbrevo/brevo";
let brevoApi = new brevo.TransactionalEmailsApi();
const apiKey = process.env.BREVO_API_KEY;
if (!apiKey) throw new Error("Missing BREVO_API_KEY");
brevoApi.setApiKey(brevo.TransactionalEmailsApiApiKeys.apiKey, apiKey);
And this is the error I get:
TypeError: Cannot read properties of undefined (reading 'TransactionalEmailsApi')
Is anyone else getting this error?
Hi @ishaangandhi Can you please try to clean the npm cache and reinstall the dependencies?
-
npm cache clean --force -
npm install
This is not reproducible every time, but it occurred with me just once and I followed this above steps to fix it.
Documentation still has not been updated as of Jan 12 2025. Correct code for initiation:
const brevo = require('@getbrevo/brevo');
let apiInstance = new brevo.TransactionalEmailsApi();
apiInstance.setApiKey(
brevo.TransactionalEmailsApiApiKeys.apiKey,
'api-key'
);