Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is the official node wrapper for the Emailable API.

## Documentation

See the [Node API docs](https://emailable.com/docs/api/?javascript).
See the [Node API docs](https://emailable.com/docs/api/emails/?code_language=javascript).

## Installation

Expand All @@ -33,49 +33,49 @@ authentication. API keys can be created and managed in the
An API key can be set globally for the Emailable client:

```javascript
// require with API key
var emailable = require('emailable')('your_api_key')
// Global: Common JS import
Comment thread
n-older marked this conversation as resolved.
Outdated
const emailable = require('emailable')('YOUR_API_KEY');

// ES6 import
// Global: ES6 import
import Emailable from 'emailable';
const emailable = Emailable('your_api_key');
const emailable = Emailable('YOUR_API_KEY');
Comment thread
n-older marked this conversation as resolved.
Outdated
```

Or, you can specify an `apiKey` or an `accessToken` with each request:

```javascript
// set api_key at request time
emailable.verify({ apiKey: 'your_api_key' })
emailable.verify({ apiKey: 'YOUR_API_KEY' })

// set access_token at request time
emailable.verify({ accessToken: 'your_api_key' })
emailable.verify({ accessToken: 'YOUR_API_KEY' })
```

### Verification

```javascript
// verify an email address
emailable.verify('jarrett@emailable.com')
.then(function (response) {
.then((response) => {
console.log(response);
})
.catch(function (error) {
.catch((error) => {
console.log(error);
});
```

#### Additional options

You can also pass any of the additional
[options](https://emailable.com/docs/api?javascript#verify-an-email)
[options](https://emailable.com/docs/api/emails/?code_language=javascript#verify-an-email)
as a second parameter to `verify`.

```javascript
emailable.verify('jarrett@emailable.com', { timeout: 10 })
.then(function (response) {
.then((response) => {
console.log(response);
})
.catch(function (error) {
.catch((error) => {
console.log(error);
});
```
Expand All @@ -100,22 +100,23 @@ allocation within a 5 minute window.
#### Start a batch

```javascript
var emails = ['jarrett@emailable.com', 'support@emailable.com', ...]
const emails = ['jarrett@emailable.com', 'support@emailable.com', ...];

emailable.batches.verify(emails)
.then(function (response) {
.then((response) => {
console.log(response.id);
});
```

##### Additional options

You can also pass any of the additional
[options](https://emailable.com/docs/api?javascript#verify-a-batch-of-emails)
[options](https://emailable.com/docs/api/emails/?code_language=javascript#verify-a-batch-of-emails)
as a second parameter to `verify`.

```javascript
emailable.batches.verify(emails, { url: 'https://emailable.com/' }).
then(function (response) {
emailable.batches.verify(emails, { url: 'https://emailable.com/' })
.then((response) => {
console.log(response.id);
});
```
Expand All @@ -126,9 +127,10 @@ Calling `batches.status` with the batch id will return the batch's status.
This will also return the results once the batch is complete.

```javascript
var id = '5cfcbfdeede34200693c4319'
const id = '5cfcbfdeede34200693c4319';

emailable.batches.status(id)
.then(function (response) {
.then((response) => {
console.log(response);
});
```
Expand Down