PHPackages                             kzykhys/portable-zipcode-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. kzykhys/portable-zipcode-api

ActiveLibrary[API Development](/categories/api)

kzykhys/portable-zipcode-api
============================

Easy, portable, self-hosting Japan postal code API

1.0.0(13y ago)1352MITPHPPHP &gt;=5.3.3

Since Apr 18Pushed 12y ago3 watchersCompare

[ Source](https://github.com/kzykhys/portable-zipcode-api)[ Packagist](https://packagist.org/packages/kzykhys/portable-zipcode-api)[ RSS](/packages/kzykhys-portable-zipcode-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

Portable ZipCode API
====================

[](#portable-zipcode-api)

Easy, portable, self-hosting Japan postal code API

Live Example
------------

[](#live-example)

[Try the demo!](http://zipapi.pagodabox.com/)

Requirements
------------

[](#requirements)

- PHP5.3.3 or later
- SQLite support (maybe installed on default PHP build)
- Latest jQuery

Installation
------------

[](#installation)

- Download [portable-zip-api.zip](http://kzykhys.github.com/portable-zipcode-api/releases/portable-zip-api.zip)
- Extract archive
- Upload zip.phar.php and zip.sqlite.db to same directory on your web server (eg. `http://www.example.com/API/zip.phar.php`)

If you prefer clean URLs, you'll need mod\_rewrite and .htaccess files like this:

```

    RewriteEngine On
    #RewriteBase /path/to/app
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ zip.phar.php [L]

```

API Reference
-------------

[](#api-reference)

### General notes

[](#general-notes)

- Every string passed to and from the API needs to be UTF-8 encoded.
- You can rename `zip.phar.php` to anything you like.

---

### `/version` Get version

[](#version-get-version)

#### URL

[](#url)

```
GET /zip.phar.php/version

```

#### Return value

[](#return-value)

An object with mime type 'application/json'

```
{
    "version": "1.0.0"
}
```

---

### `/api` Get Javascript API

[](#api-get-javascript-api)

#### URL

[](#url-1)

```
GET /zip.phar.php/api

```

#### Return value

[](#return-value-1)

The content of Javascript API with mime type 'text/javascript'

---

### `/search/{code}.{format}` Find an address by zip-code

[](#searchcodeformat-find-an-address-by-zip-code)

#### URL

[](#url-2)

```
GET  /zip.phar.php/search/{code}
GET  /zip.phar.php/search/{code}.{format}
POST /zip.phar.php/search

```

#### Arguments

[](#arguments)

- **code** *(string/integer)* The code to search (9999999/999-9999)
- **format** *(string)* The format (json|xml|php) Default:json

#### Return value

[](#return-value-2)

##### Format: json

[](#format-json)

An object with mime type 'application/json'

```
{
    "result": true,
    "data": {
        "id":   "38201",
        "code": "1600022",
        "pref": "\u6771\u4eac\u90fd",
        "city": "\u65b0\u5bbf\u533a",
        "town": "\u65b0\u5bbf"
    }
}
```

#### Format: xml

[](#format-xml)

A xml document with mime type 'application/xml'

```

    1

        38201
        1600022
        &#x6771;&#x4EAC;&#x90FD;
        &#x65B0;&#x5BBF;&#x533A;
        &#x65B0;&#x5BBF;

```

##### Format: php

[](#format-php)

A PHP [serialized](http://www.php.net/manual/en/function.serialize.php) string with mime type 'text/plain'

```
a:2:{s:6:"result";b:1;s:4:"data";a:5:{s:4:"city";s:9:"新宿区";s:4:"code";s:7:"1600022";s:2:"id";s:5:"38201";s:4:"pref";s:9:"東京都";s:4:"town";s:6:"新宿";}}

```

JavaScript API
--------------

[](#javascript-api)

### Configure and Paste the code above

[](#configure-and-paste-the-code-above)

```

```

### Call the API through jQuery

[](#call-the-api-through-jquery)

```
$.zipSearch('950-2014').done(function(json) {
    if (json.result) {
        console.log(json.data.pref);
        console.log(json.data.city);
        console.log(json.data.town);
    } else {
        console.log('Address not found for code: ' + json.data.code);
    }
});
```

Update address database
-----------------------

[](#update-address-database)

### Download full source code from repository

[](#download-full-source-code-from-repository)

```
$ git clone https://github.com/kzykhys/portable-zipcode-api.git zipapi
$ cd zipapi
```

### Install dependencies via Composer

[](#install-dependencies-via-composer)

```
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar install
```

### Download CSV (Lzh archive) from official website

[](#download-csv-lzh-archive-from-official-website)

Download lzh archive from

or just run

```
$ php app/console.php csv:download
```

### Extract Lzh archive

[](#extract-lzh-archive)

If you have lha command, just type

```
$ cd ./csv
$ find . -type f -exec lha x {} \;
```

### Setup database

[](#setup-database)

```
$ php app/console.php doctrine:schema:update --force
$ php app/console.php csv:import ./csv
```

### Rebuild phar archive

[](#rebuild-phar-archive)

```
$ php app/console.php build:phar
```

Author
------

[](#author)

Kazuyuki Hayashi (@kzykhys)

LICENSE
-------

[](#license)

The MIT License

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4774d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd0b200991bf7fdebb898cc649bb1ed5ef429b3e70fe16b79729d1517051354f?d=identicon)[kzykhys](/maintainers/kzykhys)

---

Top Contributors

[![kzykhys](https://avatars.githubusercontent.com/u/1751547?v=4)](https://github.com/kzykhys "kzykhys (12 commits)")

### Embed Badge

![Health badge](/badges/kzykhys-portable-zipcode-api/health.svg)

```
[![Health](https://phpackages.com/badges/kzykhys-portable-zipcode-api/health.svg)](https://phpackages.com/packages/kzykhys-portable-zipcode-api)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
