npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ideal-postcodes/core-browser

v3.0.1

Published

Browser javascript client for api.ideal-postcodes.co.uk

Downloads

11,504

Readme

JavaScript (browser) client for api.ideal-postcodes.co.uk

CI Cross Browser Testing codecov Dependency Status

npm version npm bundle size Release

@ideal-postcodes/core-browser is the JavaScript browser 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.

Tested against a suite of modern and legacy, mobile and desktop browsers.

@ideal-postcodes/core-browsershould be consumed by a bundler or transpiler (e.g. webpack, parcel, rollup) for minification, module resolution and specific browser support.

core-browser-bundled provides pre-bundled versions of core-browser, which can be immediately dropped into a page.

Links

Example Setup

Webpack Status

Parcel Status

Rollup Status

Polymer Status

Other JavaScript Clients

Documentation

Configuration & Usage

Install

npm install @ideal-postcodes/core-browser

Instantiate

import { Client } from "@ideal-postcodes/core-browser";

const client = new Client({ api_key: "iddqd" });

Configuration options

Use

const addresses = await lookupPostcode({ client: client, postcode: "SW1A2AA" });

Catch Errors

import { errors } from "@ideal-postcodes/core-browser";
const { IdpcRequestFailedError } = errors;

try {
  await lookupAddress({ client, query: "10 downing street" });
} catch (error) {
  if (error instanceof IdpcRequestFailedError) {
    // IdpcRequestFailedError indicates a 402 response code
    // Possibly the key balance has been depleted
  }
}

HTTP Agent and legacy browser support

core-browser uses the Fetch API under the hood to facilitate HTTP requests.

A configuration object can be passed to the Client constructor as a second argument to override certain attributes on the Request of all subsequent fetch requests. Request configuration is documented here.

If you need to support older browsers, please include a fetch polyfill and transpile this library down to ES3. Alternatively use one of our pre-transpiled outputs at ideal-postcodes/core-browser-bundled.


Quickstart

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

Lookup a Postcode

Return addresses associated with a given postcode

const postcode = "id11qd";

const addresses = await lookupPostcode({ client, postcode });

Method options

Search for an Address

Return addresses associated with a given query

const query = "10 downing street sw1a";

const addresses = await lookupAddress({ client, query });

Method options

Search for an Address by UDPRN

Return address for a given udprn

Invalid UDPRN will return null

const udprn = 23747771;

const address = await lookupUdprn({ client, udprn });

Method options

Test

npm test

Licence

MIT