
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@ideal-postcodes/core-node
Advanced tools
Node.js client for api.ideal-postcodes.co.uk
@ideal-postcodes/core-node
is the Node.js client for api.ideal-postcodes.co.uk
Our JavaScript client implements a common interface defined at @ideal-postcodes/core-interface.
High level client documentation can be found at core-interface.
In depth client documentation can be found at core-interface.ideal-postcodes.dev.
@ideal-postcodes/core-node
is tested against all maintained, stable releases.
npm install @ideal-postcodes/core-node
const { Client } = require("@ideal-postcodes/core-node");
// or, if applicable,
import { Client } from "@ideal-postcodes/core-node"
const client = new Client({ api_key: "iddqd" });
import { lookupPostcode } from "@ideal-postcodes/core-node";
const addresses = await lookupPostcode({ client, postcode: "SW1A2AA" });
import { lookupAddress, errors } from "@ideal-postcodes/core-node";
try {
await lookupAddress({ client, query: "10 downing street" });
} catch (error) {
if (error instanceof errors.IdpcRequestFailedError) {
// IdpcRequestFailedError indicates a 402 response code
// Possibly the key balance has been depleted
}
}
core-node
uses got as its underlying HTTP client. The Ideal Postcodes API client can also be optionally configured with a got options object which is fed to got on every request.
Be aware this options object will overwrite any existing got HTTP request parameters.
const client = new Client({ api_key: "iddqd" }, {
cache: new Map, // Instantiate a cache: https://github.com/sindresorhus/got#cache-1
hooks: { // Hook into HTTP responses: https://github.com/sindresorhus/got#hooksafterresponse
afterResponse: response => {
modify(response);
log(response);
return response;
}
},
});
You can proxy requests by configuring the underlying got HTTP client.
const tunnel = require("tunnel");
const client = new Client(config, {
agent: tunnel.httpOverHttp({
proxy: {
host: "localhost"
}
})
});
The client exposes a number of simple methods to get at the most common tasks when interacting with the API. Below is a (incomplete) list of commonly used methods.
For a complete list of client methods, including low level resource methods, please see the core-interface documentation
Return addresses associated with a given postcode
import { lookupPostcode } from "@ideal-postcodes/core-node";
const postcode = "id11qd";
const addresses = await lookupPostcode({ client, postcode });
Return addresses associated with a given query
import { lookupAddress } from "@ideal-postcodes/core-node";
const query = "10 downing street sw1a";
const addresses = await lookupAddress({ client, query });
Return address for a given udprn
Invalid UDPRN will return null
import { lookupUdprn } from "@ideal-postcodes/core-node";
const udprn = 23747771;
const address = await lookupUdprn({ client, udprn });
npm test
MIT
FAQs
Node.js client for api.ideal-postcodes.co.uk
The npm package @ideal-postcodes/core-node receives a total of 1,584 weekly downloads. As such, @ideal-postcodes/core-node popularity was classified as popular.
We found that @ideal-postcodes/core-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.