📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

@ken-all/kenall

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ken-all/kenall

KENALL JavaScript SDK

2.0.2
latest
Source
npm
Version published
Weekly downloads
5.8K
-34.76%
Maintainers
2
Weekly downloads
 
Created
Source

kenall-js

What's this?

kenall-js is a JavaScript client library for KEN ALL, Japan postal code to address translation API service.

API document is here.

How to use

There are two options to use kenall-js in your project. The one is to put a <script> tag referring to the script bundle somewhere atop of your HTML file to invoke the API from within your script, and the other is to specify kenall package as a dependency in your Node.js project's package.json.

Usage from within the plain-old JavaScript

[!NOTE] As of v2.0.0, Internet Explorer is no longer supported.

All you need is put a <script> tag that refers to the script bundle as follows:

<script type="text/javascript" src="LOCATION-TO-THE-SCRIPT-BUNDLE"></script>

This adds a property kenall to the global window object, from which you can refer to KENALL constructor to create the object that works as the interface. Look at the following example to see what it goes like.

Note that you need to upload the script bundle beforehand somewhere accessible from the browser.

<script type="text/javascript">
function fill(form) {
  // You can obtain the API key from the dashboard at kenall.jp/home
  const k = new kenall.KENALL('API_KEY');
  const postalCode = form.elements["postalcode"].value;
  k.getAddress(postalCode).then(
    function (address) {
      const firstCandidate = address.data[0];
      form.elements["prefecture"].value = firstCandidate["prefecture"];
    }
  ).catch(function () {
    alert("Failed to invoke the API");
  });
}
</script>

The script bundle can be downloaded at the release page.

Alternatively, you can use the following URL for the latest bundle. Beware that we don't provide any warranty on its availability, though we'll put as much effort as possible for keeping it up.

Previous versions:

Usage in a Node.js project

Run

$ npm i @ken-all/kenall

to add kenall.js as a dependency for your project.

Then you can use it like the following:

const { KENALL } = require('@ken-all/kenall');

// You can obtain the API key from the dashboard at kenall.jp/home
const api = new KENALL('API_KEY');
api.getAddress(postalCode).then(
  r => {
    console.log(r);
  }
).catch(
  e => {
    console.error(e);
  }
);

or either in TypeScript,

import { KENALL } from '@ken-all/kenall';

const kenall = new KENALL('API_KEY');
const r = await kenall.getAddress(postalCode);
console.log(r);

Building

Run

$ npm run build

to generate JavaScript scripts under dist/. If you want to get the bundle, run

$ npm run bundle

and you'll find one under dist/.

Tests

$ npm run test

Examples & Demos

FAQs

Package last updated on 31 Mar 2025

Did you know?

Socket

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.

Install

Related posts