TypeScript SDK
@ideal-postcodes/sdk is our new TypeScript SDK for the Ideal Postcodes API. It supersedes @ideal-postcodes/core-axios and @ideal-postcodes/core-node with one package that runs in browsers and Node.js 22 or later, has no runtime dependencies and covers every current API operation with generated types.
Details
- Native fetch: Requests use the runtime's own
fetch, so there is no Axios or Node-specific client to install or keep up to date - No runtime dependencies: Installing the SDK adds nothing else to your dependency tree
- Tree-shakeable: Each operation is a named export, so bundlers keep only what you import. A client and
findAddresscome to about 4.4 kB minified and gzipped - Every current operation: Postcode lookup, address search, UPRN lookup, address cleanse, email and phone validation, plus key, licensee and configuration management
- Types from the OpenAPI spec: Every request and response is typed, including Royal Mail PAF fields and each dataset's
nativerecord - Autocomplete helper:
createAutocompletedebounces keystrokes and exposesfindandresolve, ready to wire to your own search box. A search superseded by newer typing resolvesundefinedrather than throwing, so fast typists produce no unhandled rejections - Postcode lookup helper:
lookupPostcodereturns a postcode's addresses andtotal, the count across all pages. For an unknown postcode it returns the closest matching postcodes instead of throwing - Client options:
timeoutMsrejects any request that runs too long with aTimeoutError, andheaderssends default headers, such asUser-Agent, with every request - React and Preact: Optional TanStack Query adapters provide query options for every operation
- Typed errors: HTTP failures throw an
ApiErrorwith the status, API error code and message. PassthrowOnError: falseto get{ data, error }instead - Management Key kept out of URLs: Account operations send your Management Key in the
Authorizationheader, so it never appears in request URLs, proxy logs or browser history - Agent skill:
npx skills add ideal-postcodes/skillsgives coding agents setup guides and a reference for each operation
Start with the TypeScript SDK documentation. Moving from core-axios, core-node or core-browser? The migration guide maps each old call to its SDK equivalent.