デジタル プラットフォーム API - 郵便番号サービス

郵便番号サービスは読み取り専用サービスです。 このサービスを使用すると、そのディメンションをサポートするレポートを設定または構成するときに、地理的なターゲット設定の目的で Xandr に登録されている郵便番号 ID を取得することができます。 郵便番号サービスの主な使用例は、郵便番号データベースを Xandr を使用して最新の状態に保つことです。 サービスへの最後の呼び出し以降にデータベースに加えられた変更にアクセスするには、呼び出しで min_last_modified フィールドを使用してください。

警告

郵便番号の完全な一覧を取得するには (ページネーションの結果として) 大量の GET 呼び出しを行う必要があるため、次のことをお勧めします。

  • キャッシュを作成し、サービス上のすべてのオブジェクトの GET 呼び出しをそのキャッシュに設定します。
  • その後の GET 呼び出しでは、 min_last_modified フィルターを使用して更新を取得します (郵便番号は頻繁に更新されないため、1 時間に 1 回または 1 日に 1 回)。

このサービスを初めてクエリする場合のみ、 min_last_modified フィルターを省略する必要があります。

REST API

HTTP メソッド エンドポイント 説明
GET https://api.appnexus.com/postal-code ページネーションを使用してすべての郵便番号を表示します。
GET - https://api.appnexus.com/postal-code?min_last_modified=LAST_MODIFIED
- https://api.appnexus.com/postal-code?max_last_modified=LAST_MODIFIED
View all postal codes since last modified (最終更新以降のすべての郵便番号を表示します)。
GET https://api.appnexus.com/postal-code?country_code=COUNTRY_CODE 特定の国/地域の郵便番号を表示します。
GET https://api.appnexus.com/postal-code/meta フィルター処理と並べ替えの基準にされるフィールドを確認します。

JSON フィールド

フィールド タイプ (長さ) 説明
id int 郵便番号の ID。
code string 郵便番号は、14 文字までの英数字文字列にすることができ、スペースまたはハイフンを含めることができます。
country_id string 国/地域の ID。
country_code string その都市が属する国/地域の ISO Alpha-2 コード。 国/地域のサービスを使用すると、国コードの完全な一覧を取得できます。
country_name string 都市が属する国/地域の名称。 Country Service を使用すると、国/地域名の完全な一覧を取得できます。
last_modified timestamp 郵便番号が最後に変更された日時。
active ブール型 郵便番号がアクティブかどうかを指定します。 trueの場合、郵便番号はアクティブであり、ターゲットに使用できます。 falseの場合、郵便番号の地理的な場所データがないため、ターゲティングできません。

注:
郵便番号は、IP アドレスの変更、位置情報技術の変更、地理的な境界の変更に基づいて、アクティブまたは非アクティブになる場合があります。

すべての郵便番号を表示

$ curl -b cookies -c cookies -X GET  'https://api.appnexus.com/postal-code'
      
{
    "response": {
        "status": "OK",
        "count": 238899,
        "start_element": 0,
        "num_elements": 100,
        "postal_codes": [
            {
                "id": 120560,
                "code": "AD100",
                "country_id": "4",
                "country_code": "AD",
                "country_name": "Andorra"
            },
            {
                "id": 120561,
                "code": "AD200",
                "country_id": "4",
                "country_code": "AD",
                "country_name": "Andorra"
            },
            {
                "id": 120562,
                "code": "AD300",
                "country_id": "4",
                "country_code": "AD",
                "country_name": "Andorra"
            },
            {
                "id": 120563,
                "code": "AD400",
                "country_id": "4",
                "country_code": "AD",
                "country_name": "Andorra"
            },
            {
                "id": 120564,
                "code": "AD500",
                "country_id": "4",
                "country_code": "AD",
                "country_name": "Andorra"
            },
            {
                "id": 120565,
                "code": "AD600",
                "country_id": "4",
                "country_code": "AD",
                "country_name": "Andorra"
            },
            {
                "id": 120566,
                "code": "AD700",
                "country_id": "4",
                "country_code": "AD",
                "country_name": "Andorra"
            },
            {
                "id": 173241,
                "code": "1701",
                "country_id": "6",
                "country_code": "AF",
                "country_name": "Afghanistan"
            },
            {
                "id": 173242,
                "code": "3001",
                "country_id": "6",
                "country_code": "AF",
                "country_name": "Afghanistan"
            },
            ...
       ]
    }
}

View all postal codes since last modified

$ curl -b cookies -c cookies -X GET  'https://api.appnexus.com/postal-code?min_last_modified=2016-05-18+15:29:37'
      
{
    "response": {
        "status": "OK",
        "count": 247890,
        "start_element": 0,
        "num_elements": 100,
        "postal_codes": [
            {
                "id": 1,
                "code": "00010",
                "active": true,
                "country_id": "113",
                "country_code": "IT",
                "country_name": "Italy",
                "last_modified": "2015-09-15 14:40:30"
            },
            {
                "id": 2,
                "code": "00011",
                "active": true,
                "country_id": "113",
                "country_code": "IT",
                "country_name": "Italy",
                "last_modified": "2015-09-15 14:40:32"
            },
            {
                "id": 3,
                "code": "00012",
                "active": true,
                "country_id": "113",
                "country_code": "IT",
                "country_name": "Italy",
                "last_modified": "2015-09-15 17:29:04"
            },
            {
                "id": 4,
                "code": "00013",
                "active": true,
                "country_id": "113",
                "country_code": "IT",
                "country_name": "Italy",
                "last_modified": "2015-09-15 17:29:04"
            },
            {
                "id": 5,
                "code": "00015",
                "active": true,
                "country_id": "113",
                "country_code": "IT",
                "country_name": "Italy",
                "last_modified": "2015-09-15 17:29:05"
            },
            {
                "id": 6,
                "code": "00017",
                "active": true,
                "country_id": "113",
                "country_code": "IT",
                "country_name": "Italy",
                "last_modified": "2015-09-15 17:29:05"
            },
            {
                "id": 7,
                "code": "00018",
                "active": true,
                "country_id": "113",
                "country_code": "IT",
                "country_name": "Italy",
                "last_modified": "2015-09-15 17:29:05"
            },
            ...
       ]
    }
}

カナダのすべての郵便番号を表示

$ curl -b cookies -c cookies -X GET  'https://api.appnexus.com/postal-code?country_code=CA'
      
{
    "response": {
        "status": "OK",
        "count": 44101,
        "start_element": 0,
        "num_elements": 100,
        "postal_codes": [
            {
                "id": 119892,
                "code": "A09 0A1",
                "country_id": "41",
                "country_code": "CA",
                "country_name": "Canada"
            },
            {
                "id": 119893,
                "code": "A0A 0B3",
                "country_id": "41",
                "country_code": "CA",
                "country_name": "Canada"
            },
            {
                "id": 119894,
                "code": "A0A 0C3",
                "country_id": "41",
                "country_code": "CA",
                "country_name": "Canada"
            },
            {
                "id": 119895,
                "code": "A0A 1B0",
                "country_id": "41",
                "country_code": "CA",
                "country_name": "Canada"
            },
            {
                "id": 119896,
                "code": "A0A 1C0",
                "country_id": "41",
                "country_code": "CA",
                "country_name": "Canada"
            },
            {
                "id": 119897,
                "code": "A0A 1E0",
                "country_id": "41",
                "country_code": "CA",
                "country_name": "Canada"  
        },
        ...
      ],
   }
}

郵便番号 ID で郵便番号を表示する

$ curl -b cookies -c cookies  'https://api.appnexus.com/postal-code?id=10'
      
{
    "response": {
        "status": "OK",
        "count": 1,
        "start_element": 0,
        "num_elements": 100,
        "postal_code": {
            "id": 10,
            "code": "00021",
            "country_id": "113",
            "country_code": "IT",
            "country_name": "Italy",
            "last_modified": "2015-09-15 17:29:05"
        }
    }
    }