@apiddress/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +130 -0
- package/dist/client.d.ts +49 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +172 -0
- package/dist/client.js.map +1 -0
- package/dist/error.d.ts +18 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +24 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +127 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 APIddress
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# apiddress
|
|
2
|
+
|
|
3
|
+
Official Node.js SDK for the [APIddress](https://api.apiddress.com) email validation API.
|
|
4
|
+
|
|
5
|
+
- Zero runtime dependencies (built on global `fetch`)
|
|
6
|
+
- Node 18+, ESM, full TypeScript types
|
|
7
|
+
- Automatic retry with backoff on `429` and `5xx` (batch creation is never retried)
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @apiddress/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quickstart
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { APIddress } from "@apiddress/sdk";
|
|
19
|
+
|
|
20
|
+
const client = new APIddress("YOUR_API_KEY");
|
|
21
|
+
|
|
22
|
+
const result = await client.validateEmail("ada@stripe.com");
|
|
23
|
+
console.log(result.status); // "valid"
|
|
24
|
+
console.log(result.score); // 0.98
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Configuration
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
const client = new APIddress("YOUR_API_KEY", {
|
|
31
|
+
baseUrl: "https://api.apiddress.com", // default
|
|
32
|
+
timeoutMs: 10_000, // per-request timeout, default 10s
|
|
33
|
+
maxRetries: 2, // retries on 429/5xx, default 2
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Validate one email
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
const result = await client.validateEmail("john@company.com", {
|
|
43
|
+
check_smtp: false, // default
|
|
44
|
+
allow_role_based: true, // default
|
|
45
|
+
});
|
|
46
|
+
// result.status: "valid" | "invalid" | "risky" | "disposable" | "unknown"
|
|
47
|
+
// result.suggestion: "john@gmail.com" for typo-like addresses, else null
|
|
48
|
+
// result.checks: { syntax, domain_exists, mx, smtp, disposable, ... }
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
A malformed value (e.g. `"not-an-email"`) is a verdict, not an error: you get
|
|
52
|
+
`status: "invalid"` with `reason: "invalid_syntax"`.
|
|
53
|
+
|
|
54
|
+
### Validate up to 100 emails synchronously
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
const { count, results } = await client.validateEmails([
|
|
58
|
+
"a@example.com",
|
|
59
|
+
"b@example.com",
|
|
60
|
+
]);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Batch jobs (up to 5000 emails)
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
const batch = await client.createBatch(emails, {
|
|
67
|
+
callback_url: "https://yourapp.com/webhooks/apiddress", // optional
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const done = await client.waitForBatch(batch.batch_id, {
|
|
71
|
+
pollMs: 1_000, // default
|
|
72
|
+
timeoutMs: 60_000, // default
|
|
73
|
+
});
|
|
74
|
+
console.log(done.status, done.results.length);
|
|
75
|
+
|
|
76
|
+
// Or poll yourself:
|
|
77
|
+
const status = await client.getBatch(batch.batch_id);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`waitForBatch` resolves with the terminal state (`"completed"` or `"failed"`) —
|
|
81
|
+
check `status` before using `results`.
|
|
82
|
+
|
|
83
|
+
### Account
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
const profile = await client.me(); // plan, limits, usage
|
|
87
|
+
const usage = await client.usage(); // current month
|
|
88
|
+
const may = await client.usage("2026-05"); // specific month
|
|
89
|
+
const health = await client.health(); // no auth required
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Error handling
|
|
93
|
+
|
|
94
|
+
Every failed request throws an `APIddressError`:
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
import { APIddress, APIddressError } from "@apiddress/sdk";
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
await client.validateEmail("john@company.com");
|
|
101
|
+
} catch (err) {
|
|
102
|
+
if (err instanceof APIddressError) {
|
|
103
|
+
console.error(err.status, err.code, err.message, err.details);
|
|
104
|
+
// 429 quota_exceeded "Monthly request limit exceeded." { requests_used: ..., requests_limit: ... }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
| `status` | `code` |
|
|
110
|
+
| -------- | ------------------ |
|
|
111
|
+
| 400 | `invalid_request` |
|
|
112
|
+
| 401 | `unauthorized` |
|
|
113
|
+
| 404 | `not_found` |
|
|
114
|
+
| 429 | `quota_exceeded` |
|
|
115
|
+
| 500 | `internal_error` |
|
|
116
|
+
| 0 | `timeout` (request or `waitForBatch` timeout) |
|
|
117
|
+
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm install
|
|
122
|
+
npm run build # tsc -> dist/ (ESM + .d.ts)
|
|
123
|
+
|
|
124
|
+
# Integration tests need a live backend:
|
|
125
|
+
APIDDRESS_BASE_URL=http://localhost:3000 APIDDRESS_API_KEY=test_key_local_dev npm test
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ApiKeyProfileResponse, BatchAcceptedResponse, BatchStatusResponse, BulkValidateResponse, CreateBatchOptions, HealthResponse, UsageResponse, ValidateEmailOptions, ValidateEmailResponse, ValidateEmailsOptions, WaitForBatchOptions } from "./types.js";
|
|
2
|
+
/** Client configuration. */
|
|
3
|
+
export interface APIddressOptions {
|
|
4
|
+
/** API origin. Default: "https://api.apiddress.com". */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Per-request timeout in milliseconds. Default: 10000. */
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
/** Retries on 429 and 5xx responses. Default: 2. Batch creation is never retried. */
|
|
9
|
+
maxRetries?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Official APIddress client.
|
|
13
|
+
*
|
|
14
|
+
* ```js
|
|
15
|
+
* import { APIddress } from "@apiddress/sdk";
|
|
16
|
+
*
|
|
17
|
+
* const client = new APIddress("YOUR_API_KEY");
|
|
18
|
+
* const result = await client.validateEmail("ada@stripe.com");
|
|
19
|
+
* console.log(result.status); // "valid"
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class APIddress {
|
|
23
|
+
#private;
|
|
24
|
+
constructor(apiKey: string, options?: APIddressOptions);
|
|
25
|
+
/** Validate a single email address. Costs 1 request. */
|
|
26
|
+
validateEmail(email: string, options?: ValidateEmailOptions): Promise<ValidateEmailResponse>;
|
|
27
|
+
/** Validate 1-100 email addresses synchronously. Costs one request per email. */
|
|
28
|
+
validateEmails(emails: string[], options?: ValidateEmailsOptions): Promise<BulkValidateResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Create an asynchronous batch job for 1-5000 email addresses.
|
|
31
|
+
* Never retried automatically (to avoid duplicate jobs).
|
|
32
|
+
*/
|
|
33
|
+
createBatch(emails: string[], options?: CreateBatchOptions): Promise<BatchAcceptedResponse>;
|
|
34
|
+
/** Get the current state (and results, when completed) of a batch job. */
|
|
35
|
+
getBatch(batchId: string): Promise<BatchStatusResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Poll a batch job until it reaches a terminal state ("completed" or "failed")
|
|
38
|
+
* and return that final state. Throws an `APIddressError` with `code: "timeout"`
|
|
39
|
+
* if the job is still running after `timeoutMs`.
|
|
40
|
+
*/
|
|
41
|
+
waitForBatch(batchId: string, options?: WaitForBatchOptions): Promise<BatchStatusResponse>;
|
|
42
|
+
/** Get the profile (plan, limits, usage) of the authenticated API key. */
|
|
43
|
+
me(): Promise<ApiKeyProfileResponse>;
|
|
44
|
+
/** Get usage for a month ("YYYY-MM"). Defaults to the current month. */
|
|
45
|
+
usage(month?: string): Promise<UsageResponse>;
|
|
46
|
+
/** Service health check. Does not require authentication. */
|
|
47
|
+
health(): Promise<HealthResponse>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,4BAA4B;AAC5B,MAAM,WAAW,gBAAgB;IAC/B,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAkBD;;;;;;;;;;GAUG;AACH,qBAAa,SAAS;;gBAMR,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB;IAU1D,wDAAwD;IACxD,aAAa,CACX,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,qBAAqB,CAAC;IAQjC,iFAAiF;IACjF,cAAc,CACZ,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,oBAAoB,CAAC;IAQhC;;;OAGG;IACH,WAAW,CACT,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,qBAAqB,CAAC;IAajC,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAOvD;;;;OAIG;IACG,YAAY,CAChB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,mBAAmB,CAAC;IAqB/B,0EAA0E;IAC1E,EAAE,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAIpC,wEAAwE;IACxE,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ7C,6DAA6D;IAC7D,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC;CA8ClC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { APIddressError } from "./error.js";
|
|
2
|
+
const DEFAULT_BASE_URL = "https://api.apiddress.com";
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 10_000;
|
|
4
|
+
const DEFAULT_MAX_RETRIES = 2;
|
|
5
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
6
|
+
/**
|
|
7
|
+
* Official APIddress client.
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* import { APIddress } from "@apiddress/sdk";
|
|
11
|
+
*
|
|
12
|
+
* const client = new APIddress("YOUR_API_KEY");
|
|
13
|
+
* const result = await client.validateEmail("ada@stripe.com");
|
|
14
|
+
* console.log(result.status); // "valid"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export class APIddress {
|
|
18
|
+
#apiKey;
|
|
19
|
+
#baseUrl;
|
|
20
|
+
#timeoutMs;
|
|
21
|
+
#maxRetries;
|
|
22
|
+
constructor(apiKey, options = {}) {
|
|
23
|
+
if (!apiKey || typeof apiKey !== "string") {
|
|
24
|
+
throw new TypeError("APIddress: an API key string is required");
|
|
25
|
+
}
|
|
26
|
+
this.#apiKey = apiKey;
|
|
27
|
+
this.#baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
28
|
+
this.#timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
29
|
+
this.#maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
30
|
+
}
|
|
31
|
+
/** Validate a single email address. Costs 1 request. */
|
|
32
|
+
validateEmail(email, options = {}) {
|
|
33
|
+
return this.#request({
|
|
34
|
+
method: "POST",
|
|
35
|
+
path: "/api/v1/validate-email",
|
|
36
|
+
body: { email, check_smtp: options.check_smtp ?? false, ...optional("allow_role_based", options.allow_role_based) },
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** Validate 1-100 email addresses synchronously. Costs one request per email. */
|
|
40
|
+
validateEmails(emails, options = {}) {
|
|
41
|
+
return this.#request({
|
|
42
|
+
method: "POST",
|
|
43
|
+
path: "/api/v1/validate-emails",
|
|
44
|
+
body: { emails, check_smtp: options.check_smtp ?? false },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create an asynchronous batch job for 1-5000 email addresses.
|
|
49
|
+
* Never retried automatically (to avoid duplicate jobs).
|
|
50
|
+
*/
|
|
51
|
+
createBatch(emails, options = {}) {
|
|
52
|
+
return this.#request({
|
|
53
|
+
method: "POST",
|
|
54
|
+
path: "/api/v1/batches",
|
|
55
|
+
body: {
|
|
56
|
+
emails,
|
|
57
|
+
check_smtp: options.check_smtp ?? false,
|
|
58
|
+
...optional("callback_url", options.callback_url),
|
|
59
|
+
},
|
|
60
|
+
retryable: false,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Get the current state (and results, when completed) of a batch job. */
|
|
64
|
+
getBatch(batchId) {
|
|
65
|
+
return this.#request({
|
|
66
|
+
method: "GET",
|
|
67
|
+
path: `/api/v1/batches/${encodeURIComponent(batchId)}`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Poll a batch job until it reaches a terminal state ("completed" or "failed")
|
|
72
|
+
* and return that final state. Throws an `APIddressError` with `code: "timeout"`
|
|
73
|
+
* if the job is still running after `timeoutMs`.
|
|
74
|
+
*/
|
|
75
|
+
async waitForBatch(batchId, options = {}) {
|
|
76
|
+
const pollMs = options.pollMs ?? 1_000;
|
|
77
|
+
const timeoutMs = options.timeoutMs ?? 60_000;
|
|
78
|
+
const deadline = Date.now() + timeoutMs;
|
|
79
|
+
for (;;) {
|
|
80
|
+
const batch = await this.getBatch(batchId);
|
|
81
|
+
if (batch.status === "completed" || batch.status === "failed") {
|
|
82
|
+
return batch;
|
|
83
|
+
}
|
|
84
|
+
if (Date.now() + pollMs > deadline) {
|
|
85
|
+
throw new APIddressError(0, "timeout", `Batch ${batchId} did not complete within ${timeoutMs}ms (last status: ${batch.status})`);
|
|
86
|
+
}
|
|
87
|
+
await sleep(pollMs);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Get the profile (plan, limits, usage) of the authenticated API key. */
|
|
91
|
+
me() {
|
|
92
|
+
return this.#request({ method: "GET", path: "/api/v1/me" });
|
|
93
|
+
}
|
|
94
|
+
/** Get usage for a month ("YYYY-MM"). Defaults to the current month. */
|
|
95
|
+
usage(month) {
|
|
96
|
+
return this.#request({
|
|
97
|
+
method: "GET",
|
|
98
|
+
path: "/api/v1/usage",
|
|
99
|
+
query: { month },
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/** Service health check. Does not require authentication. */
|
|
103
|
+
health() {
|
|
104
|
+
return this.#request({ method: "GET", path: "/api/v1/health", auth: false });
|
|
105
|
+
}
|
|
106
|
+
async #request(options) {
|
|
107
|
+
const { method, path, body, query, auth = true, retryable = true } = options;
|
|
108
|
+
const url = new URL(this.#baseUrl + path);
|
|
109
|
+
for (const [key, value] of Object.entries(query ?? {})) {
|
|
110
|
+
if (value !== undefined)
|
|
111
|
+
url.searchParams.set(key, value);
|
|
112
|
+
}
|
|
113
|
+
const headers = { accept: "application/json" };
|
|
114
|
+
if (auth)
|
|
115
|
+
headers["x-api-key"] = this.#apiKey;
|
|
116
|
+
if (body !== undefined)
|
|
117
|
+
headers["content-type"] = "application/json";
|
|
118
|
+
const maxAttempts = retryable ? this.#maxRetries + 1 : 1;
|
|
119
|
+
for (let attempt = 0;; attempt++) {
|
|
120
|
+
let response;
|
|
121
|
+
try {
|
|
122
|
+
const init = {
|
|
123
|
+
method,
|
|
124
|
+
headers,
|
|
125
|
+
signal: AbortSignal.timeout(this.#timeoutMs),
|
|
126
|
+
};
|
|
127
|
+
if (body !== undefined)
|
|
128
|
+
init.body = JSON.stringify(body);
|
|
129
|
+
response = await fetch(url, init);
|
|
130
|
+
}
|
|
131
|
+
catch (cause) {
|
|
132
|
+
if (cause instanceof Error && (cause.name === "TimeoutError" || cause.name === "AbortError")) {
|
|
133
|
+
throw new APIddressError(0, "timeout", `Request to ${path} timed out after ${this.#timeoutMs}ms`);
|
|
134
|
+
}
|
|
135
|
+
throw cause;
|
|
136
|
+
}
|
|
137
|
+
if (response.ok) {
|
|
138
|
+
return (await response.json());
|
|
139
|
+
}
|
|
140
|
+
const error = await parseErrorEnvelope(response);
|
|
141
|
+
const shouldRetry = attempt + 1 < maxAttempts && (response.status === 429 || response.status >= 500);
|
|
142
|
+
if (!shouldRetry)
|
|
143
|
+
throw error;
|
|
144
|
+
await sleep(backoffMs(attempt));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function optional(key, value) {
|
|
149
|
+
return value === undefined ? {} : { [key]: value };
|
|
150
|
+
}
|
|
151
|
+
/** Exponential backoff with a little jitter: ~250ms, ~500ms, ~1s, capped at 4s. */
|
|
152
|
+
function backoffMs(attempt) {
|
|
153
|
+
return Math.min(250 * 2 ** attempt, 4_000) + Math.floor(Math.random() * 100);
|
|
154
|
+
}
|
|
155
|
+
async function parseErrorEnvelope(response) {
|
|
156
|
+
let code = "unknown_error";
|
|
157
|
+
let message = `HTTP ${response.status}`;
|
|
158
|
+
let details = null;
|
|
159
|
+
try {
|
|
160
|
+
const payload = (await response.json());
|
|
161
|
+
if (payload?.error) {
|
|
162
|
+
code = payload.error.code ?? code;
|
|
163
|
+
message = payload.error.message ?? message;
|
|
164
|
+
details = payload.error.details ?? null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
// Non-JSON error body; keep defaults.
|
|
169
|
+
}
|
|
170
|
+
return new APIddressError(response.status, code, message, details);
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAyB5C,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AACrD,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAY9B,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAEtF;;;;;;;;;;GAUG;AACH,MAAM,OAAO,SAAS;IACX,OAAO,CAAS;IAChB,QAAQ,CAAS;IACjB,UAAU,CAAS;IACnB,WAAW,CAAS;IAE7B,YAAY,MAAc,EAAE,UAA4B,EAAE;QACxD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,MAAM,IAAI,SAAS,CAAC,0CAA0C,CAAC,CAAC;QAClE,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,IAAI,kBAAkB,CAAC;QAC1D,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,IAAI,mBAAmB,CAAC;IAC/D,CAAC;IAED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I,OAAO,GAAmC,IAAI,CAAC;IACnD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA8F,CAAC;QACrI,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC;YAClC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,IAAI,OAAO,CAAC;YAC3C,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC;QAC1C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,sCAAsC;IACxC,CAAC;IACD,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown for any failed APIddress request.
|
|
3
|
+
*
|
|
4
|
+
* - For HTTP errors, `status` is the response status code and `code`/`message`/
|
|
5
|
+
* `details` come from the API error envelope `{error: {code, message, details}}`.
|
|
6
|
+
* - For client-side failures (request timeout, batch polling timeout), `status`
|
|
7
|
+
* is 0 and `code` is `"timeout"`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class APIddressError extends Error {
|
|
10
|
+
/** HTTP status code, or 0 for client-side failures. */
|
|
11
|
+
readonly status: number;
|
|
12
|
+
/** Machine-readable error code, e.g. "unauthorized", "quota_exceeded". */
|
|
13
|
+
readonly code: string;
|
|
14
|
+
/** Extra context from the API, or null. */
|
|
15
|
+
readonly details: Record<string, unknown> | null;
|
|
16
|
+
constructor(status: number, code: string, message: string, details?: Record<string, unknown> | null);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;gBAG/C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAW;CAQjD"}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown for any failed APIddress request.
|
|
3
|
+
*
|
|
4
|
+
* - For HTTP errors, `status` is the response status code and `code`/`message`/
|
|
5
|
+
* `details` come from the API error envelope `{error: {code, message, details}}`.
|
|
6
|
+
* - For client-side failures (request timeout, batch polling timeout), `status`
|
|
7
|
+
* is 0 and `code` is `"timeout"`.
|
|
8
|
+
*/
|
|
9
|
+
export class APIddressError extends Error {
|
|
10
|
+
/** HTTP status code, or 0 for client-side failures. */
|
|
11
|
+
status;
|
|
12
|
+
/** Machine-readable error code, e.g. "unauthorized", "quota_exceeded". */
|
|
13
|
+
code;
|
|
14
|
+
/** Extra context from the API, or null. */
|
|
15
|
+
details;
|
|
16
|
+
constructor(status, code, message, details = null) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = "APIddressError";
|
|
19
|
+
this.status = status;
|
|
20
|
+
this.code = code;
|
|
21
|
+
this.details = details;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,uDAAuD;IAC9C,MAAM,CAAS;IACxB,0EAA0E;IACjE,IAAI,CAAS;IACtB,2CAA2C;IAClC,OAAO,CAAiC;IAEjD,YACE,MAAc,EACd,IAAY,EACZ,OAAe,EACf,UAA0C,IAAI;QAE9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { APIddress } from "./client.js";
|
|
2
|
+
export type { APIddressOptions } from "./client.js";
|
|
3
|
+
export { APIddressError } from "./error.js";
|
|
4
|
+
export type { ApiKeyProfileResponse, BatchAcceptedResponse, BatchStatus, BatchStatusResponse, BulkValidateResponse, CreateBatchOptions, EmailStatus, ErrorResponse, HealthResponse, Plan, SpamTrapRisk, UsageResponse, ValidateEmailOptions, ValidateEmailResponse, ValidateEmailsOptions, ValidationChecks, WaitForBatchOptions, } from "./types.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,YAAY,EACV,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,cAAc,EACd,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request and response types for the APIddress API.
|
|
3
|
+
*
|
|
4
|
+
* Hand-mapped 1:1 from the OpenAPI 3.1 contract (`backend/openapi.yaml`).
|
|
5
|
+
* Field names match the wire format exactly.
|
|
6
|
+
*/
|
|
7
|
+
/** Verdict for a validated email address. */
|
|
8
|
+
export type EmailStatus = "valid" | "invalid" | "risky" | "disposable" | "unknown";
|
|
9
|
+
/** Lifecycle state of an asynchronous batch job. */
|
|
10
|
+
export type BatchStatus = "pending" | "processing" | "completed" | "failed";
|
|
11
|
+
/** Plan associated with an API key. */
|
|
12
|
+
export type Plan = "free" | "paid" | "enterprise";
|
|
13
|
+
/** Spam-trap risk level, or null when not assessed. */
|
|
14
|
+
export type SpamTrapRisk = "low" | "medium" | "high" | null;
|
|
15
|
+
/** Options for `validateEmail`. Field names match the API request body. */
|
|
16
|
+
export interface ValidateEmailOptions {
|
|
17
|
+
/** Attempt an SMTP-level deliverability probe. Default: false. */
|
|
18
|
+
check_smtp?: boolean;
|
|
19
|
+
/** Treat role-based addresses (support@, info@, ...) as acceptable. Default: true. */
|
|
20
|
+
allow_role_based?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Options for `validateEmails`. */
|
|
23
|
+
export interface ValidateEmailsOptions {
|
|
24
|
+
/** Attempt an SMTP-level deliverability probe. Default: false. */
|
|
25
|
+
check_smtp?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Options for `createBatch`. */
|
|
28
|
+
export interface CreateBatchOptions {
|
|
29
|
+
/** Webhook URL invoked when the batch completes. */
|
|
30
|
+
callback_url?: string | null;
|
|
31
|
+
/** Attempt an SMTP-level deliverability probe. Default: false. */
|
|
32
|
+
check_smtp?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** Options for `waitForBatch`. */
|
|
35
|
+
export interface WaitForBatchOptions {
|
|
36
|
+
/** Delay between polls, in milliseconds. Default: 1000. */
|
|
37
|
+
pollMs?: number;
|
|
38
|
+
/** Give up after this many milliseconds. Default: 60000. */
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
}
|
|
41
|
+
/** Individual checks performed on an email address. */
|
|
42
|
+
export interface ValidationChecks {
|
|
43
|
+
syntax: boolean;
|
|
44
|
+
domain_exists: boolean;
|
|
45
|
+
mx: boolean;
|
|
46
|
+
/** null when the SMTP probe was skipped or inconclusive. */
|
|
47
|
+
smtp: boolean | null;
|
|
48
|
+
disposable: boolean;
|
|
49
|
+
role_based: boolean;
|
|
50
|
+
free_provider: boolean;
|
|
51
|
+
/** null when not determined. */
|
|
52
|
+
catch_all: boolean | null;
|
|
53
|
+
typo: boolean;
|
|
54
|
+
spam_trap_risk: SpamTrapRisk;
|
|
55
|
+
}
|
|
56
|
+
/** Result of validating a single email address. */
|
|
57
|
+
export interface ValidateEmailResponse {
|
|
58
|
+
email: string;
|
|
59
|
+
normalized_email: string;
|
|
60
|
+
status: EmailStatus;
|
|
61
|
+
valid: boolean;
|
|
62
|
+
/** Confidence score between 0 and 1. */
|
|
63
|
+
score: number;
|
|
64
|
+
/** Machine-readable reason, e.g. "accepted_email", "invalid_syntax". */
|
|
65
|
+
reason: string;
|
|
66
|
+
/** Suggested correction for typo-like addresses, or null. */
|
|
67
|
+
suggestion: string | null;
|
|
68
|
+
checks: ValidationChecks;
|
|
69
|
+
provider: string | null;
|
|
70
|
+
created_at: string;
|
|
71
|
+
}
|
|
72
|
+
/** Result of a synchronous bulk validation. */
|
|
73
|
+
export interface BulkValidateResponse {
|
|
74
|
+
count: number;
|
|
75
|
+
results: ValidateEmailResponse[];
|
|
76
|
+
}
|
|
77
|
+
/** Returned when an asynchronous batch job is accepted (HTTP 202). */
|
|
78
|
+
export interface BatchAcceptedResponse {
|
|
79
|
+
batch_id: string;
|
|
80
|
+
status: "pending";
|
|
81
|
+
submitted_count: number;
|
|
82
|
+
created_at: string;
|
|
83
|
+
}
|
|
84
|
+
/** Current state of an asynchronous batch job. */
|
|
85
|
+
export interface BatchStatusResponse {
|
|
86
|
+
batch_id: string;
|
|
87
|
+
status: BatchStatus;
|
|
88
|
+
submitted_count: number;
|
|
89
|
+
processed_count: number;
|
|
90
|
+
created_at: string;
|
|
91
|
+
completed_at: string | null;
|
|
92
|
+
/** Per-email results once the batch is completed, otherwise null. */
|
|
93
|
+
results: ValidateEmailResponse[] | null;
|
|
94
|
+
}
|
|
95
|
+
/** Profile of the authenticated API key. */
|
|
96
|
+
export interface ApiKeyProfileResponse {
|
|
97
|
+
id: string;
|
|
98
|
+
email: string;
|
|
99
|
+
plan: Plan;
|
|
100
|
+
is_active: boolean;
|
|
101
|
+
requests_limit: number;
|
|
102
|
+
requests_used: number;
|
|
103
|
+
created_at: string;
|
|
104
|
+
}
|
|
105
|
+
/** Monthly usage for the authenticated API key. */
|
|
106
|
+
export interface UsageResponse {
|
|
107
|
+
/** Month in YYYY-MM format. */
|
|
108
|
+
month: string;
|
|
109
|
+
requests_used: number;
|
|
110
|
+
requests_limit: number;
|
|
111
|
+
remaining: number;
|
|
112
|
+
}
|
|
113
|
+
/** Service health payload. */
|
|
114
|
+
export interface HealthResponse {
|
|
115
|
+
status: "ok";
|
|
116
|
+
timestamp: string;
|
|
117
|
+
version: string;
|
|
118
|
+
}
|
|
119
|
+
/** Error envelope returned by the API on 4xx/5xx. */
|
|
120
|
+
export interface ErrorResponse {
|
|
121
|
+
error: {
|
|
122
|
+
code: string;
|
|
123
|
+
message: string;
|
|
124
|
+
details?: Record<string, unknown> | null;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,6CAA6C;AAC7C,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;AAEnF,oDAAoD;AACpD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE5E,uCAAuC;AACvC,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;AAElD,uDAAuD;AACvD,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC;AAE5D,2EAA2E;AAC3E,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sFAAsF;IACtF,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,oCAAoC;AACpC,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,iCAAiC;AACjC,MAAM,WAAW,kBAAkB;IACjC,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,kCAAkC;AAClC,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;I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;IAC5B,qEAAqE;IACrE,OAAO,EAAE,qBAAqB,EAAE,GAAG,IAAI,CAAC;CACzC;AAED,4CAA4C;AAC5C,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,mDAAmD;AACnD,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,8BAA8B;AAC9B,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,IAAI,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;KAC1C,CAAC;CACH"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apiddress/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official Node.js SDK for the APIddress email validation API",
|
|
5
|
+
"keywords": ["email", "validation", "email-verification", "apiddress"],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
17
|
+
"publishConfig": { "access": "public" },
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -p tsconfig.json",
|
|
23
|
+
"test": "vitest run"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^22.15.0",
|
|
27
|
+
"typescript": "^5.8.0",
|
|
28
|
+
"vitest": "^3.1.0"
|
|
29
|
+
}
|
|
30
|
+
}
|