@parseapi/sdk 1.7.0 → 1.8.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/README.md +67 -12
- package/dist/index.cjs +49 -22
- package/dist/index.d.cts +253 -37
- package/dist/index.d.ts +253 -37
- package/dist/index.js +49 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -87,9 +87,9 @@ await parse.ip('8.8.8.8');
|
|
|
87
87
|
await parse.ip.self();
|
|
88
88
|
await parse.email('hello@gmail.com');
|
|
89
89
|
await parse.vat('DE136695976');
|
|
90
|
-
await parse.
|
|
91
|
-
await parse.
|
|
92
|
-
await parse.
|
|
90
|
+
await parse.bank('DE89370400440532013000');
|
|
91
|
+
await parse.card('424242');
|
|
92
|
+
await parse.provider('1881018208');
|
|
93
93
|
await parse.phone('+14155552671');
|
|
94
94
|
await parse.carrier('+14155552671');
|
|
95
95
|
await parse.caller('+14155552671');
|
|
@@ -143,16 +143,18 @@ await parse.mx('example.com');
|
|
|
143
143
|
await parse.dns('example.com');
|
|
144
144
|
await parse.dns('_dmarc.example.com', { type: 'TXT' });
|
|
145
145
|
await parse.useragent(uaString);
|
|
146
|
-
await parse.
|
|
147
|
-
await parse.
|
|
148
|
-
await parse.
|
|
146
|
+
await parse.vehicle('1HGCM82633A004352');
|
|
147
|
+
await parse.industry('541511');
|
|
148
|
+
await parse.industry.search('coffee shop', { limit: 5 });
|
|
149
149
|
await parse.tariff('8471.30.01.00');
|
|
150
150
|
await parse.tariff.search('sunglasses');
|
|
151
151
|
await parse.emoji('rocket');
|
|
152
152
|
await parse.emoji.search('fire');
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
The existing NAICS lookup and search methods remain available as compatibility names for Industry.
|
|
156
|
+
|
|
157
|
+
Industry paid deep records include classification `deep.exclusions`, each with a description and linked codes. Generic exclusions can have no linked codes. Omitted or null exclusions in older responses remain unknown. Search results also include `match`: the matched `field` (`name`, `term` or `naics`) and `text`, plus `corrections` with `from` and `to` tokens for typo fallback. Corrections are empty for exact, plural and prefix matches. Direct code lookups omit `match`. Older responses may omit it.
|
|
156
158
|
|
|
157
159
|
Responses are typed, plain JSON data. `country.states('US')` requests the states directly; it does not fetch a country first. Optional arguments go in the final options object, so new options can be added without changing your existing calls.
|
|
158
160
|
|
|
@@ -262,6 +264,32 @@ Address search uses context from the form: prefer postal, or city and state. An
|
|
|
262
264
|
|
|
263
265
|
HLR reports status at the last check. `live` means assigned and `connected` means reachable at that check. Cached results may be returned. Null means unconfirmed. Deep diagnostics stay within the same metered lookup.
|
|
264
266
|
|
|
267
|
+
Bank returns core `checks` for input, country, length, structure, checksum and national rules, plus an `issues` list. States are `passed`, `failed`, `not_checked` or `not_supported`. Unsupported national checking is not a failure. `valid` covers the implemented format and checksum rules, not account existence, ownership or payment reachability. Directory names and BICs may be null independently. Older responses may omit `checks` and `issues`, and future states and issue codes remain strings. Pass the original input unchanged so the API can report invalid characters. Deep `account` remains the BBAN remainder.
|
|
268
|
+
|
|
269
|
+
Bank inputs use `POST /bank` JSON bodies, keeping IBAN and account values out of request URLs. Pass original strings; the server owns normalization and validation. Avoid logging request bodies. IBAN deep can include `directory` with the immutable `edition`, resolved `country` and actual `match` grain (`bank`, `branch`, `prefix` or `none`); it is absent if no directory lookup ran. A match does not prove complete country coverage or payment reachability.
|
|
270
|
+
|
|
271
|
+
Use country requirements to build supported input fields. US ACH has an explicit helper with no deep option. It checks the routing format/ABA checksum and account-field syntax; `account_checksum` is `not_supported`. It preserves account characters and leading zeros. A nullable bank name is routing-directory identity, not account existence, ownership or ACH eligibility. The examples below are synthetic test inputs, not payment instructions.
|
|
272
|
+
|
|
273
|
+
```ts
|
|
274
|
+
await parse.bankRequirements('US', { format: 'us_ach' });
|
|
275
|
+
await parse.bankUsAch({ routing: '011000015', account: '0001234567' });
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Provider lookup
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
const provider = await parse.provider('1881018208');
|
|
282
|
+
const profile = await parse.provider('1881018208', { deep: true });
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Pass the original NPI as a string. `valid` checks its format and checksum; `registered` means a match in the stored NPPES snapshot. `active` reflects recorded NPI deactivation, not licensure. `excluded` is an NPI-only OIG LEIE match; `false` is not a complete exclusion clearance. These directory facts do not verify credentials, current practice contact or payment eligibility.
|
|
286
|
+
|
|
287
|
+
Invalid input returns `valid: false` with unknown provider fields. A checksum-valid number missing from the snapshot returns `registered: false`; unavailable storage remains an API error. Preserve `null` as unknown.
|
|
288
|
+
|
|
289
|
+
The default pooled lookup includes provider identity, specialty and practice contact where held. Paid `deep` adds `deactivated_at`, `medicare`, `opt_out` and `enrollments` from stored source files, with no separate check meter or live verification. `enrollments: null` means unavailable; `[]` means no enrollment rows are returned. The API omits unrequested `deep` and returns `{}` when requested on Free.
|
|
290
|
+
|
|
291
|
+
Paid Deep also returns `taxonomies` in published order, with taxonomy code, specialty label, primary flag and provider-reported license number/state, plus `enumerated_at`, `updated_at` and `reactivated_at` record dates. Reported licenses are not verified licenses. Null lists mean unavailable; empty lists mean the edition contains no entries. Core `sources` is available on every plan: NPPES, LEIE, PECOS and opt-out each have nullable edition metadata (`edition`, `published_at`, `through`, `imported_at`). Provider record dates are separate from source publication and completed import dates. Older responses may omit these additions. Edition details remain null until a verified source is served.
|
|
292
|
+
|
|
265
293
|
## Deep
|
|
266
294
|
|
|
267
295
|
Choose enrichment for the question you need answered.
|
|
@@ -272,10 +300,11 @@ Choose enrichment for the question you need answered.
|
|
|
272
300
|
| Domain | Registration dates, registrar, status and DNSSEC, included with a paid plan. Use `dns` for DNS records and `mx` for mail routing. |
|
|
273
301
|
| Email | A metered mailbox check with deliverability, catch-all, status, reason and address hints, using included email checks or enabled on-demand usage. |
|
|
274
302
|
| VAT | A metered registry check where supported, using included VAT checks or enabled on-demand usage. |
|
|
275
|
-
| Phone, Time, Date, Currency, Language, Emoji,
|
|
303
|
+
| Phone, Time, Date, Currency, Language, Emoji, Bank, Point | Optional detail in the same pooled request on every plan. |
|
|
276
304
|
| Country, State, District, City, Postal | The place profile on paid plans, including demographic and tax facts where held. |
|
|
277
|
-
| Name,
|
|
278
|
-
|
|
|
305
|
+
| Name, Industry | Name evidence or the industry definition profile on paid plans. |
|
|
306
|
+
| NPI | Deactivation date, Medicare enrollment, opt-out and enrollment rows from stored sources on paid plans. Exclusion evidence stays core. |
|
|
307
|
+
| Vehicle, Tariff, Company | The complete product detail bag on paid plans. |
|
|
279
308
|
| Weather | Specialist current measurements and the existing forecast, alert, air and history bag on paid plans. |
|
|
280
309
|
| Carrier, HLR | Optional diagnostic detail within the same metered core unit, including Free allowance units. No second gate or additional check. |
|
|
281
310
|
|
|
@@ -331,16 +360,40 @@ Ordinary lookups retry network failures, 429, and 500/502/503/504 responses twic
|
|
|
331
360
|
|
|
332
361
|
An explicit `retries` setting on the client or call overrides those defaults. Another attempt can consume additional usage if the earlier response was lost. Cancellation stops the request and any retry wait. Automatic redirects are disabled.
|
|
333
362
|
|
|
363
|
+
Automatic retries wait at most five seconds per attempt. A longer valid `Retry-After` returns the original API error immediately without retrying early. Read `retryAfter` on the error for the original header, or null when absent.
|
|
364
|
+
|
|
334
365
|
## Docs
|
|
335
366
|
|
|
336
367
|
Full field reference for every endpoint: [parseapi.com/docs](https://parseapi.com/docs)
|
|
337
368
|
|
|
338
|
-
|
|
369
|
+
## Card
|
|
370
|
+
|
|
371
|
+
Send 2–11 leading digits as a string. Core returns `bin`, `brand`, `brand_name`
|
|
372
|
+
and a CDN SVG `logo`. Brand detection uses reviewed network rules independently
|
|
373
|
+
of issuer records. Unknown or ambiguous prefixes return null brand fields and a
|
|
374
|
+
generic logo; a known network without reviewed artwork also uses the generic logo.
|
|
375
|
+
|
|
376
|
+
Optional Deep adds `prefix`, `issuer`, `country`, `type` and `prepaid`, included
|
|
377
|
+
in the same pooled request on every plan. Six or more digits enable directory
|
|
378
|
+
matching. Fewer digits return all-null Deep fields. Compare `deep.prefix` with
|
|
379
|
+
`bin`: equal is an exact recorded match; shorter is broader; null is no match.
|
|
380
|
+
The longest row wins, including null fields. `prepaid: null` means unknown, not
|
|
381
|
+
false. This is partial reference data, not card validity or payment acceptance.
|
|
382
|
+
|
|
383
|
+
```javascript
|
|
384
|
+
const card = await parse.card('51');
|
|
385
|
+
console.log(card.brand, card.logo);
|
|
386
|
+
const details = await parse.card('43737400', { deep: true });
|
|
387
|
+
console.log(details.deep?.prefix, details.deep?.issuer);
|
|
388
|
+
```
|
|
339
389
|
|
|
390
|
+
Leading zeros are preserved. Only ASCII spaces, tabs, CR, LF and hyphens are
|
|
391
|
+
removed; raw input is limited to 64 characters. Invalid prefixes are rejected
|
|
392
|
+
before dispatch, accepted input is forwarded unchanged. Never send a full card number.
|
|
340
393
|
|
|
341
394
|
## Optional detail
|
|
342
395
|
|
|
343
|
-
The default response answers the common task. Ask for `deep` when you need more detail about that same result. Core fields stay equal. City,
|
|
396
|
+
The default response answers the common task. Ask for `deep` when you need more detail about that same result. Core fields stay equal. City, Industry and Emoji searches put detail inside each result. Postal nearby and distance put metropolitan detail beside the entity it describes. Time conversion keeps target detail in `to.deep`; only the source has `deep.next_dst`.
|
|
344
397
|
|
|
345
398
|
```ts
|
|
346
399
|
const basic = await parse.time('America/New_York');
|
|
@@ -361,3 +414,5 @@ Pass a public hostname without a scheme, path, port or IP address. Stack returns
|
|
|
361
414
|
Successful checks may be reused for up to 24 hours. `pretty` optionally formats the wire JSON. Stack uses your plan's request allowance and API version 2.0.0 selected by this client.
|
|
362
415
|
|
|
363
416
|
Stack defaults to 35 seconds per attempt so a first scan has time to finish. Other lookups retain their 10-second default. An explicit client timeout applies to every operation; JavaScript also supports a per-call `timeoutMs` override.
|
|
417
|
+
|
|
418
|
+
Vehicle lookups use `vin` as the input and response field. Existing VIN methods remain available for compatibility.
|
package/dist/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ __export(index_exports, {
|
|
|
24
24
|
parseAPI: () => parseAPI
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
var VERSION = "1.
|
|
27
|
+
var VERSION = "1.8.0";
|
|
28
28
|
var API_VERSION = "2.0.0";
|
|
29
29
|
var DEFAULT_BASE_URL = "https://api.parseapi.com";
|
|
30
30
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
@@ -40,13 +40,16 @@ var ParseAPIError = class extends Error {
|
|
|
40
40
|
docs;
|
|
41
41
|
/** Send this if you contact support */
|
|
42
42
|
requestId;
|
|
43
|
-
|
|
43
|
+
/** Original Retry-After response header, when supplied. */
|
|
44
|
+
retryAfter;
|
|
45
|
+
constructor(status, code, message, docs, requestId, retryAfter = null) {
|
|
44
46
|
super(message);
|
|
45
47
|
this.name = "ParseAPIError";
|
|
46
48
|
this.status = status;
|
|
47
49
|
this.code = code;
|
|
48
50
|
this.docs = docs;
|
|
49
51
|
this.requestId = requestId;
|
|
52
|
+
this.retryAfter = retryAfter;
|
|
50
53
|
}
|
|
51
54
|
};
|
|
52
55
|
function tariffSelection(result, opts) {
|
|
@@ -91,16 +94,20 @@ function metered(path, query) {
|
|
|
91
94
|
}
|
|
92
95
|
function retryDelayMs(attempt, retryAfter) {
|
|
93
96
|
if (retryAfter) {
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
+
const value = retryAfter.trim();
|
|
98
|
+
if (/^[0-9]+(?:\.[0-9]+)?$/.test(value)) {
|
|
99
|
+
const seconds = Number(value);
|
|
100
|
+
return seconds > RETRY_AFTER_CAP_MS / 1e3 ? null : seconds * 1e3;
|
|
97
101
|
}
|
|
98
|
-
if (
|
|
99
|
-
const date = Date.parse(
|
|
100
|
-
if (Number.isFinite(date))
|
|
102
|
+
if (/^[A-Za-z]{3,9},? /.test(value)) {
|
|
103
|
+
const date = Date.parse(value);
|
|
104
|
+
if (Number.isFinite(date)) {
|
|
105
|
+
const delay = Math.max(date - Date.now(), 0);
|
|
106
|
+
return delay > RETRY_AFTER_CAP_MS ? null : delay;
|
|
107
|
+
}
|
|
101
108
|
}
|
|
102
109
|
}
|
|
103
|
-
return Math.random() * 250 * 2 ** attempt;
|
|
110
|
+
return Math.random() * Math.min(250 * 2 ** Math.min(attempt, 16), RETRY_AFTER_CAP_MS);
|
|
104
111
|
}
|
|
105
112
|
function parseAPI(apiKey, options = {}) {
|
|
106
113
|
const key = apiKey || env("PARSEAPI_KEY");
|
|
@@ -133,7 +140,7 @@ function parseAPI(apiKey, options = {}) {
|
|
|
133
140
|
const onAbort = () => controller.abort(signal.reason);
|
|
134
141
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
135
142
|
const timer = setTimeout(() => controller.abort(new DOMException("Request timed out", "TimeoutError")), attemptTimeout);
|
|
136
|
-
let
|
|
143
|
+
let retryDelay;
|
|
137
144
|
try {
|
|
138
145
|
let res;
|
|
139
146
|
try {
|
|
@@ -159,8 +166,8 @@ function parseAPI(apiKey, options = {}) {
|
|
|
159
166
|
res = void 0;
|
|
160
167
|
}
|
|
161
168
|
}
|
|
162
|
-
if (res
|
|
163
|
-
|
|
169
|
+
if (res) retryDelay = retryDelayMs(attempt, res.headers.get("Retry-After"));
|
|
170
|
+
if (res && RETRY_STATUS.has(res.status) && attempt < retries && retryDelay !== null) {
|
|
164
171
|
await res.body?.cancel().catch(() => {
|
|
165
172
|
});
|
|
166
173
|
} else if (res) {
|
|
@@ -177,14 +184,15 @@ function parseAPI(apiKey, options = {}) {
|
|
|
177
184
|
typeof body2.code === "string" ? body2.code : "unknown_error",
|
|
178
185
|
typeof body2.message === "string" ? body2.message : `Request failed with status ${res.status}`,
|
|
179
186
|
typeof body2.docs === "string" ? body2.docs : null,
|
|
180
|
-
typeof body2.request_id === "string" ? body2.request_id : null
|
|
187
|
+
typeof body2.request_id === "string" ? body2.request_id : null,
|
|
188
|
+
res.headers.get("Retry-After")
|
|
181
189
|
);
|
|
182
190
|
}
|
|
183
191
|
} finally {
|
|
184
192
|
clearTimeout(timer);
|
|
185
193
|
signal?.removeEventListener("abort", onAbort);
|
|
186
194
|
}
|
|
187
|
-
await sleep(retryDelayMs(attempt,
|
|
195
|
+
await sleep(retryDelay ?? retryDelayMs(attempt, null), signal);
|
|
188
196
|
}
|
|
189
197
|
}
|
|
190
198
|
const enc = encodeURIComponent;
|
|
@@ -198,6 +206,12 @@ function parseAPI(apiKey, options = {}) {
|
|
|
198
206
|
for (const [name, value2] of Object.entries(query)) url.searchParams.set(name, String(value2));
|
|
199
207
|
return !numericJson && url.href.length <= 8e3 ? request("/elevation", query, void 0, opts) : request("/elevation", void 0, void 0, opts, { [selector]: coordinates, ...sampling });
|
|
200
208
|
}
|
|
209
|
+
const industry = Object.assign(
|
|
210
|
+
(code, opts) => request(`/industry/${enc(code)}`, deepQuery(opts), void 0, opts),
|
|
211
|
+
{
|
|
212
|
+
search: (query, opts) => request("/industry", { q: query, limit: opts?.limit, ...deepQuery(opts) }, void 0, opts)
|
|
213
|
+
}
|
|
214
|
+
);
|
|
201
215
|
return {
|
|
202
216
|
/** Estimate task access, capacity and additional charges. Requires a secret key. Reserves no units or money and does not enforce the supplied budget. */
|
|
203
217
|
preflight: (task, opts) => request("/preflight", void 0, void 0, opts, task),
|
|
@@ -283,8 +297,16 @@ function parseAPI(apiKey, options = {}) {
|
|
|
283
297
|
from: opts?.from,
|
|
284
298
|
...deepQuery(opts)
|
|
285
299
|
}, void 0, opts),
|
|
300
|
+
// Keep existing callers on their established HTTP contracts.
|
|
286
301
|
iban: (iban, opts) => request(`/iban/${enc(iban)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
302
|
+
bin: (bin, opts) => request(`/bin/${enc(bin)}`, { deep: opts?.deep }, void 0, opts),
|
|
287
303
|
npi: (npi, opts) => request(`/npi/${enc(npi)}`, deepQuery(opts), void 0, opts),
|
|
304
|
+
bank: (iban, opts) => request("/bank", void 0, void 0, opts, { iban, country: opts?.country, deep: opts?.deep }),
|
|
305
|
+
/** Check US routing/account syntax using POST. Does not verify ownership, existence or ACH eligibility. */
|
|
306
|
+
bankUsAch: (input, opts) => request("/bank", void 0, void 0, opts, { format: "us_ach", country: "US", routing: input.routing, account: input.account }),
|
|
307
|
+
/** Describe supported input fields and check scope; this does not establish country directory coverage. */
|
|
308
|
+
bankRequirements: (country, opts) => request("/bank/requirements", { country, format: opts?.format }, void 0, opts),
|
|
309
|
+
provider: (npi, opts) => request(`/provider/${enc(npi)}`, deepQuery(opts), void 0, opts),
|
|
288
310
|
/** Parse a phone number and its formats. Pass country for national numbers when needed. Deep adds numbering-plan geography. */
|
|
289
311
|
phone: (number, opts) => request(`/phone/${enc(number)}`, { country: opts?.country, ...deepQuery(opts) }, void 0, opts),
|
|
290
312
|
/** Request a metered carrier lookup. No automatic retries by default. */
|
|
@@ -299,8 +321,13 @@ function parseAPI(apiKey, options = {}) {
|
|
|
299
321
|
domain: (domain, opts) => request(`/domain/${enc(domain)}`, deepQuery(opts), void 0, opts),
|
|
300
322
|
asn: (asn, opts) => request(`/asn/${enc(asn)}`, void 0, void 0, opts),
|
|
301
323
|
mac: (mac, opts) => request(`/mac/${enc(mac)}`, void 0, void 0, opts),
|
|
302
|
-
/** Look up a
|
|
303
|
-
|
|
324
|
+
/** Look up a 2-11 digit card prefix. Keep leading zeros in the input string. */
|
|
325
|
+
card: async (bin, opts) => {
|
|
326
|
+
if (typeof bin !== "string" || bin.length > 64 || !/^[0-9]{2,11}$/.test(bin.replace(/[ \t\r\n-]/g, ""))) {
|
|
327
|
+
throw new TypeError("parseAPI: Card requires a string containing 2 to 11 digits. Send a prefix only.");
|
|
328
|
+
}
|
|
329
|
+
return request(`/card/${enc(bin)}`, deepQuery(opts), void 0, opts);
|
|
330
|
+
},
|
|
304
331
|
/** Parse a measurement or convert it to `to`. Without `to`, use its type's canonical unit. Invalid input is plain data with `valid: false`. */
|
|
305
332
|
measure: Object.assign(
|
|
306
333
|
(measure, opts) => request(`/measure/${enc(measure)}`, { to: opts?.to, locale: opts?.locale, system: opts?.system }, void 0, opts),
|
|
@@ -313,14 +340,14 @@ function parseAPI(apiKey, options = {}) {
|
|
|
313
340
|
dns: (domain, opts) => request(`/dns/${enc(domain)}`, { type: opts?.type }, void 0, opts),
|
|
314
341
|
mx: (domain, opts) => request(`/mx/${enc(domain)}`, void 0, void 0, opts),
|
|
315
342
|
useragent: (ua, opts) => request("/useragent", deepQuery(opts), { "User-Agent": ua }, opts),
|
|
343
|
+
/** Identify a vehicle by VIN. Paid deep adds specifications and model-level recall campaigns. */
|
|
344
|
+
vehicle: (vin, opts) => request(`/vehicle/${enc(vin)}`, deepQuery(opts), void 0, opts),
|
|
345
|
+
/** Compatibility entry for VIN callers. */
|
|
316
346
|
vin: (vin, opts) => request(`/vin/${enc(vin)}`, deepQuery(opts), void 0, opts),
|
|
317
347
|
/** US NAICS 2022 definitions and hierarchy. */
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
search: (query, opts) => request("/naics", { q: query, limit: opts?.limit, ...deepQuery(opts) }, void 0, opts)
|
|
322
|
-
}
|
|
323
|
-
),
|
|
348
|
+
industry,
|
|
349
|
+
/** Compatibility name for industry. */
|
|
350
|
+
naics: industry,
|
|
324
351
|
/** Look up the general US duty schedule line. Paid deep adds units and the special and other schedule columns. Add origin with deep to resolve country-specific measures. Without origin, schedule detail remains available and origin-dependent fields are null. A null effective rate is not a zero rate. */
|
|
325
352
|
tariff: Object.assign(
|
|
326
353
|
(code, opts) => request(`/tariff/${enc(code)}`, { origin: opts?.origin, edition: opts?.edition, date: opts?.date, ...deepQuery(opts) }, void 0, opts).then((result) => tariffSelection(result, opts)),
|