1lookup
v0.1.0
Published
Official Node.js client for the 1Lookup API: phone validation, carrier and line type, HLR, caller name (CNAM), reverse phone and email lookup, email verification, IP lookup and DNC scrub.
Downloads
404
Maintainers
Readme
1lookup
Official Node.js client for the 1Lookup API: phone validation, carrier and line type, HLR lookup, caller name (CNAM), reverse phone and reverse email lookup, email verification, IP lookup and Do Not Call scrub.
- One API key and one shared credit balance for every endpoint.
- Typed results and typed errors (TypeScript types included).
- Zero runtime dependencies. Uses the built-in
fetch(Node 18 or newer). - ESM and CommonJS.
Full API reference: https://app.1lookup.io/api Pricing: https://www.1lookup.io/pricing
Install
npm install 1lookupCreate an API key at https://app.1lookup.io/api-keys and keep it on your server. Never ship it to a browser.
import { OneLookup } from "1lookup";
// CommonJS: const { OneLookup } = require("1lookup");
const client = new OneLookup({ apiKey: process.env.ONELOOKUP_API_KEY });If you leave out apiKey, the client reads the ONELOOKUP_API_KEY environment variable.
Examples
1. Validate a phone number (line type and carrier)
const phone = await client.validatePhone("+14155552671");
console.log(phone.classification.line_type); // e.g. "MOBILE"
console.log(phone.classification.number_status); // e.g. "ACTIVE"
console.log(phone.insights.raw_api_fields?.network); // carrier name
console.log(phone.insights.reachability?.is_reachable);2. Verify an email address
const email = await client.verifyEmail("[email protected]");
if (email.classification.deliverability_status === "DELIVERABLE") {
// safe to send
}
console.log(email.risk_assessment?.risk_factors); // e.g. ["ROLE_BASED_EMAIL"]3. HLR lookup (live mobile network status)
const hlr = await client.hlrLookup("+447700900123");
console.log(hlr.classification.connectivity_status); // CONNECTED, ABSENT, INVALID_MSISDN or UNDETERMINED
console.log(hlr.insights.hlr_result.current_carrier);4. Check Do Not Call, then look up the caller name (CNAM)
const scrub = await client.scrubPhone("+14155552671");
if (!scrub.classification.doNotCall && !scrub.classification.litigator) {
const cnam = await client.cnamLookup("+14155552671");
if (cnam.classification.matched) {
console.log(cnam.classification.primary_name);
}
}5. Look up an IP address
const ip = await client.lookupIp("8.8.8.8");
console.log(ip.insights.location?.country_code);
console.log(ip.classification.connection_type);
console.log(ip.risk_assessment?.fraud_score);Methods
Every lookup method returns the response's data object. Results come from a 7-day cache when the same lookup ran recently; pass { bypassCache: true } to force a fresh lookup (it spends credits even when a cached result exists).
| Method | Endpoint | Returns |
|---|---|---|
| validatePhone(phone) | POST /phone | Line type, carrier, location, reachability, porting, DNC/DNO flags |
| carrierLookup(phone) | POST /phone | Same call as validatePhone; carrier name in insights.raw_api_fields.network |
| lineType(phone) | POST /nt-lookup | Mobile, landline, VoIP or other, plus validity |
| hlrLookup(phone) | POST /hlr-lookup | Live subscriber status, roaming state and network |
| mnpLookup(phone) | POST /mnp-lookup | The network a number was ported to |
| reversePhone(phone, { lookupSource }) | POST /reverse-phone-lookup | Person or business behind a number ("standard" or "premium") |
| cnamLookup(phone) | POST /reverse-phone-lookup | Caller name from caller ID records (lookup_source: "standard") |
| scrubPhone(phone) | POST /phone-scrub | Do Not Call and known-litigator check |
| phoneSpam(phone) | POST /phone-spam | Spam or fraud history |
| verifyEmail(email) | POST /email | Deliverability; disposable, role-based and risky flags |
| reverseEmail(email) | POST /reverse-email-append | Person and company behind an email address |
| lookupIp(ip) | POST /ip | Geolocation, connection type, proxy, VPN, Tor and datacenter flags |
| getAccount() | GET /account | Plan, credit balance and usage (spends no credits) |
| request(method, path, body?) | any | Any other endpoint in the API reference |
What each lookup costs: see pricing.
Any other endpoint
const age = await client.request("POST", "/domain-age", { domain: "example.com" });Errors and retries
Failed calls throw a subclass of OneLookupError with status, code (the API's error code), message, requestId and, when the API sends it, retryAfter in seconds.
import { InsufficientCreditsError, RateLimitError, AuthenticationError } from "1lookup";
try {
await client.validatePhone("+14155552671");
} catch (err) {
if (err instanceof InsufficientCreditsError) {
// 402: out of credits, see https://www.1lookup.io/pricing
} else if (err instanceof RateLimitError) {
// 429: wait err.retryAfter seconds
} else if (err instanceof AuthenticationError) {
// 401: check the API key
} else {
throw err;
}
}| Status | Class |
|---|---|
| 400 | BadRequestError |
| 401 | AuthenticationError |
| 402 | InsufficientCreditsError |
| 403 | PermissionDeniedError |
| 429 | RateLimitError (also has rateLimit.limit, .remaining, .reset) |
| 503 | ServiceUnavailableError |
| other 5xx | ServerError |
| no answer | APIConnectionError, APITimeoutError |
The client retries 429 and 503 answers up to 2 times, waiting for Retry-After. Nothing else is retried. Change it with maxRetries (0 turns retries off) and maxRetryDelayMs (a Retry-After longer than this is thrown to you instead of waited on).
const client = new OneLookup({
apiKey: process.env.ONELOOKUP_API_KEY,
timeoutMs: 30_000, // per request, default 60000
maxRetries: 2,
maxRetryDelayMs: 20_000,
});AI agents
Agents can also call 1Lookup over the hosted MCP server at https://app.1lookup.io/api/mcp instead of REST.
License
MIT
