Download the PHP package jpzip/jpzip without Composer
On this page you can find all versions of the php package jpzip/jpzip. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package jpzip
Short Description jpzip PHP SDK — 日本の郵便番号を CDN 配信の JSON データから引く
License MIT
Homepage https://jpzip.nadai.dev
Informations about the package jpzip
PHP SDK for jpzip — a free, unlimited Japanese postal code (郵便番号) API. 日本の全郵便番号 120,677 件を CDN 配信 JSON から引く PHP SDK。
English | 日本語
jpzip/jpzip looks up Japanese postal codes (郵便番号) from jpzip.nadai.dev,
a CDN-hosted dataset built from Japan Post's KEN_ALL.csv and KEN_ALL_ROME.csv
normalized to JSON. No registration, no rate limits, no API key.
- 🇯🇵 Complete dataset — 120,677 entries with kanji, kana, romaji, and government codes (JIS X 0401 / 総務省地方公共団体コード)
- ⚡️ Fast — L1 LRU + optional L2 persistent cache;
preload()to serve lookups without per-request network round-trips - 🛡️ Resilient — 3-attempt retry with exponential backoff on 5xx / network failures
- 🐘 Modern PHP — PHP 8.2+, strict types, readonly DTOs, named arguments throughout
- 🆓 Free forever — backed by Cloudflare Pages' free tier (no billing axis exists)
- 🔌 Drop-in — same API surface across every jpzip SDK
Requirements
- PHP 8.2+
ext-jsonguzzlehttp/guzzle ^7.8(transitively pullspsr/http-message,guzzlehttp/promises,guzzlehttp/psr7)
Install
Quick Start
Romaji and government codes are on the same entry:
Use Cases
Zipcode lookup HTTP endpoint (Laravel)
Zipcode lookup HTTP endpoint (Slim 4)
Batch validation
Serve lookups from cache (BYO L2 backend)
The dataset is partitioned into 948 three-digit prefix buckets. The default L1
(100 entries) keeps the hottest buckets; to cache the whole dataset, pair
preload('all') with an L2 cache or raise memoryCacheSize above 948.
API Reference
Functions (namespace Jpzip, share a default Client)
| Function | Description |
|---|---|
Jpzip\lookup(string $zipcode): ?ZipcodeEntry |
Look up a single 7-digit zipcode. Returns null if not found or malformed (no network call for malformed input). |
Jpzip\lookupGroup(string $prefix): array<string, ZipcodeEntry> |
Look up by 1-, 2-, or 3-digit prefix. 1-digit fetches /g/{d}.json; 3-digit fetches /p/{ddd}.json; 2-digit fans out into 10 parallel 3-digit fetches and merges. |
Jpzip\lookupAll(): array<string, ZipcodeEntry> |
Fetch entire dataset (120k entries, ~37 MiB) in parallel across /g/0..9.json. |
Jpzip\getMeta(): ?Meta |
Dataset version, generated-at, per-prefecture counts, spec version. Result is cached until refresh(). |
Jpzip\preload(string $scope): void |
Warm L1 (and L2 when configured) for "all" or a specific 1–3-digit prefix. |
Jpzip\isValidZipcode(string $s): bool |
Pure syntax check (^\d{7}$) — no network. |
Jpzip\Client (advanced)
A configurable instance; required for L2 caching, custom HTTP client, alternate base URL, or multiple isolated caches:
Client exposes lookup() / lookupGroup() / lookupAll() / getMeta() / preload() plus:
| Method | Description |
|---|---|
$client->refresh() |
Wipe L1 (and L2 when configured) and forget the cached meta. |
When getMeta() observes that /meta.json's version has changed since the last successful fetch, L1 and L2 are cleared automatically — call getMeta() periodically to pick up dataset rollovers.
DTOs
All DTOs are final readonly classes with typed properties:
Each DTO exposes toArray() for JSON serialization and ::fromArray() for deserialization.
Errors
\InvalidArgumentException— thrown bylookupGroup()/preload()when the prefix is not"all"or 1–3 digits.\RuntimeException— thrown for non-404 4xx HTTP responses, malformed JSON, and 5xx responses that fail all retries.- Transient network failures and 5xx responses are retried up to 3 attempts (initial + 2 retries) with exponential backoff sleeps of 400ms and 800ms. 4xx responses other than 404 (which yields
null) are returned immediately.
CacheInterface
Bring your own L2 backend (file, APCu, Redis, Memcached, KV, etc.):
Keys are the full prefix-bucket URLs (e.g. https://jpzip.nadai.dev/p/231.json); values are raw JSON bytes.
Adapters for PSR-16 (Psr\SimpleCache\CacheInterface) and PSR-6 (Psr\Cache\CacheItemPoolInterface) can be written as ~20-line wrappers around the contract above.
Why jpzip/jpzip?
| jpzip/jpzip | sukohi/laravel-jp-postal-code | edgecreativemedia/japanaddressing | zipcloud API | |
|---|---|---|---|---|
Romaji (Yokohama Shi) |
✅ | ❌ | ✅ | ❌ |
| Government codes (JIS / 総務省) | ✅ | ❌ | ❌ | ❌ |
| No manual CSV download / DB seed | ✅ | ❌ Manual KEN_ALL.CSV |
✅ Bundled | ✅ |
| Framework-agnostic | ✅ | ❌ Laravel-only | ✅ | ✅ |
| Monthly updates | ✅ Auto | ❌ Manual | ❌ Abandoned (2016) | ✅ |
| Offline after preload | ✅ | ✅ | ✅ | ❌ |
| Rate-limit-free | ✅ | ✅ | ✅ | ⚠️ Discouraged for bulk |
| L1 + pluggable L2 cache | ✅ | ❌ | ❌ | ❌ |
| Modern PHP (8.2+, readonly DTOs) | ✅ | ❌ | ❌ PHP 5.4 | n/a |
Other Languages
Same API surface across all SDKs:
Go · TypeScript · Python · Rust · Ruby · Swift · Dart
Resources
- Website — https://jpzip.nadai.dev
- Protocol spec — jpzip/spec
- Data ETL — jpzip/data
- MCP server — jpzip/mcp — use jpzip from Claude / ChatGPT / Cursor
Keywords
japanese postal code, japan zipcode, 郵便番号, KEN_ALL, KEN_ALL_ROME, address validation, address autocomplete, japan address api, postal code lookup php, php japanese address, laravel zipcode, slim zipcode, JIS X 0401, 総務省地方公共団体コード
License
MIT