Area Code (NPA) Lookup

Get all exchanges within an area code or look up a specific NPA-NXX combination

The NPA endpoint returns information about area codes and their associated exchanges (NXX codes).

Endpoints

GET /v1/npa/:npa
GET /v1/npa/:npa/nxx/:nxx
GET /v1/npa?npa=:npa
GET /v1/npa?npa=:npa&nxx=:nxx

Authentication

Requires API key via one of:

  • Authorization: Bearer <key> header (recommended)
  • X-API-Key header
  • apiKey query parameter

See Authentication for details.

Parameters

Path Parameters

ParameterTypeRequiredDescription
npastringYes3-digit area code (e.g., 415)
nxxstringNo3-digit exchange code (e.g., 555)

Query Parameters

ParameterTypeRequiredDescription
npastringYes*3-digit area code. *Required when not using path parameter.
nxxstringNo3-digit exchange code to filter results.
limitintegerNoNumber of results per page (default: 50, max: 100)
offsetintegerNoNumber of results to skip for pagination (default: 0)

Request Examples

Get All Exchanges in an Area Code

curl -H "Authorization: Bearer your-api-key" \
  "https://api.telco.dev/v1/npa/415"

Get a Specific NPA-NXX

curl -H "Authorization: Bearer your-api-key" \
  "https://api.telco.dev/v1/npa/415/nxx/555"

Using Query Parameters with Pagination

curl -H "Authorization: Bearer your-api-key" \
  "https://api.telco.dev/v1/npa?npa=415&limit=20&offset=40"

Response

Success Response (200 OK)

{
  "npa": "415",
  "state": "CA",
  "country": "US",
  "total_exchanges": 847,
  "exchanges": [
    {
      "nxx": "200",
      "ocn": "7500",
      "company_name": "AT&T WIRELESS",
      "rate_center": "SAN FRANCISCO",
      "status": "ASSIGNED"
    },
    {
      "nxx": "201",
      "ocn": "9740",
      "company_name": "PACIFIC BELL",
      "rate_center": "SAN FRANCISCO",
      "status": "ASSIGNED"
    }
  ],
  "pagination": {
    "limit": 50,
    "offset": 0,
    "total": 847
  }
}

Response Fields

FieldTypeDescription
npastringThe 3-digit area code
statestringPrimary state/province for this area code
countrystringCountry code: US or CA
total_exchangesintegerTotal number of exchanges in this area code
exchangesarrayList of exchange records
exchanges[].nxxstring3-digit exchange code
exchanges[].ocnstringOperating Company Number
exchanges[].company_namestringCarrier/company name
exchanges[].rate_centerstringRate center name
exchanges[].statusstringAssignment status
pagination.limitintegerNumber of results requested
pagination.offsetintegerNumber of results skipped
pagination.totalintegerTotal matching records

Error Responses

Invalid Request (400)

Missing or invalid area code:

{
  "error": "invalid_request",
  "message": "Missing required parameter 'npa' (3-digit area code). Usage: /v1/npa?npa=XXX"
}
{
  "error": "invalid_request",
  "message": "Invalid 'npa' parameter: '41'. Must be exactly 3 digits."
}

Code Examples

JavaScript

async function getAreaCodeExchanges(npa, options = {}) {
  const params = new URLSearchParams({
    npa,
    limit: options.limit || 50,
    offset: options.offset || 0
  });

  if (options.nxx) {
    params.set("nxx", options.nxx);
  }

  const response = await fetch(
    `https://api.telco.dev/v1/npa?${params}`,
    {
      headers: {
        "Authorization": `Bearer ${process.env.TELCO_API_KEY}`
      }
    }
  );

  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.message);
  }

  return response.json();
}

// Usage: Get all exchanges in 415
const result = await getAreaCodeExchanges("415");
console.log(`Found ${result.total_exchanges} exchanges in ${result.npa}`);

// Usage: Get specific NPA-NXX
const specific = await getAreaCodeExchanges("415", { nxx: "555" });
console.log(specific.exchanges[0]);

Python

import requests
import os

def get_area_code_exchanges(npa, nxx=None, limit=50, offset=0):
    params = {
        "npa": npa,
        "limit": limit,
        "offset": offset
    }
    if nxx:
        params["nxx"] = nxx

    response = requests.get(
        "https://api.telco.dev/v1/npa",
        params=params,
        headers={"Authorization": f"Bearer {os.environ['TELCO_API_KEY']}"}
    )
    response.raise_for_status()
    return response.json()

# Usage
result = get_area_code_exchanges("415")
print(f"Found {result['total_exchanges']} exchanges in {result['npa']}")

# With pagination
page2 = get_area_code_exchanges("415", limit=50, offset=50)

Use Cases

Find All Wireless Carriers in an Area Code

const result = await getAreaCodeExchanges("415");

const wirelessCarriers = result.exchanges.filter(
  ex => ex.company_name?.toLowerCase().includes("wireless")
);

console.log(`Found ${wirelessCarriers.length} wireless exchanges`);

Paginate Through All Exchanges

async function getAllExchanges(npa) {
  const allExchanges = [];
  let offset = 0;
  const limit = 100;

  while (true) {
    const result = await getAreaCodeExchanges(npa, { limit, offset });
    allExchanges.push(...result.exchanges);

    if (offset + limit >= result.pagination.total) {
      break;
    }
    offset += limit;
  }

  return allExchanges;
}

const all415Exchanges = await getAllExchanges("415");
console.log(`Total: ${all415Exchanges.length} exchanges`);