# v2 API Node.js Code Example

> \[!WARNING]
>
> To access all the latest features and upcoming developments, please see our [v3 API](/docs/sendgrid/api-reference). For assistance with transitioning, refer to our [migration guide](/docs/sendgrid/for-developers/migration-guides/v2-to-v3-api).

> \[!NOTE]
>
> We recommend using [v3](/docs/sendgrid/for-developers/sending-email/quickstart-nodejs) SendGrid Node.js, our client library, [available on GitHub](https://github.com/sendgrid/sendgrid-nodejs), with full documentation.

> \[!NOTE]
>
> The library does not officially support the V2 API, but you can use V2 with an older version of the library. For more information, see [Continue Using V2 in Node.js](https://github.com/sendgrid/sendgrid-nodejs/blob/main/TROUBLESHOOTING.md#v2).

## Using SendGrid's Node.js Library

```javascript
// using SendGrid's Node.js Library
// https://github.com/sendgrid/sendgrid-nodejs
const sendgrid = require("sendgrid")("SENDGRID_APIKEY");
const email = new sendgrid.Email();

email.addTo("test@sendgrid.com");
email.setFrom("you@example.com");
email.setSubject("Sending an email with SendGrid is Fun");
email.setHtml("and easy to do anywhere, even with Node.js");

sendgrid.send(email);
```
