Skip to main content

日本の郵便番号から住所を取得するAPI

Project description

jpzipcode

郵便番号から住所を取得するためのライブラリ

Usage

import os

from jpzipcode import OFFICIAL_FILE_NAME, read_csv_file, read_official_URL

zip_code = "5650871"

# ファイルを読み込んで取得
resolver = read_csv_file(os.path.join("tests", "testdata", OFFICIAL_FILE_NAME))
zips = resolver.resolve(zip_code)

# 日本郵便のサイトからダウンロードして郵便番号を取得
resolver = read_official_URL()
zips = resolver.resolve(zip_code)

print(zips)
# [Zip(zip_code='5650871', address=Address(prefecture='大阪府', city='吹田市', town='山田丘'), address_kana=Address(prefecture='オオサカフ', city='スイタシ', town='ヤマダオカ'))]


from fastapi import FastAPI
from fastapi.testclient import TestClient

from jpzipcode.fastapi.endpoint import create_endopoint

app = FastAPI()

# appに郵便番号解決エンドポイントを追加
app.get("/zip")(create_endopoint())

client = TestClient(app)
res = client.get(f"/zip?zipcode={zip_code}")
result = res.json()
assert res.status_code == 200
assert result[0]["address"]["prefecture"] == "大阪府"
assert result[0]["address"]["city"] == "吹田市"
assert result[0]["address"]["town"] == "山田丘"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jpzipcode-0.3.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jpzipcode-0.3.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file jpzipcode-0.3.0.tar.gz.

File metadata

  • Download URL: jpzipcode-0.3.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for jpzipcode-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d1c7b83fdc9930076d939e87365f9217fc09a5b1beb3a90d2cc0eeab7048614a
MD5 f55936bf38a7f1e9ad00be611343326a
BLAKE2b-256 9cc424662957cc909d82ee5680075c4e74ceec2e80b999b88ee1d6f62502a5e1

See more details on using hashes here.

File details

Details for the file jpzipcode-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: jpzipcode-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for jpzipcode-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ca070089baa20184db416c9cefd58f24ead6ac2e9da3b1e3a4ef4345f56f8dc
MD5 75e96e68319785d54b15e2e99dc7bc50
BLAKE2b-256 2fac6fa50aac084d20f1897e925390a923e405d682f085787baf58a14f27a793

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page