{
  "openapi": "3.1.0",
  "info": {
    "title": "シルギア 郵便料金API",
    "version": "1.0.0",
    "description": "登録不要・無料の郵便料金API。日本国内あての郵便物の基本料金（税込）を返します。定形・定形外（規格内・規格外）の重さごとの料金、はがき・往復はがき・ミニレター・スマートレター・レターパックライト・レターパックプラス・ゆうパケットの料金と、サイズ・重さの条件。速達・書留などのオプション、ゆうパック・クリックポストは含みません。日本郵便の料金表と照らし合わせて作成し、照合した日を data_version で返します。説明: https://api.shirugear.com/postage/ 。v1 の中では項目や種類を足すことはあっても、名前や意味は変えません（知らない項目は無視してください）。",
    "termsOfService": "https://api.shirugear.com/terms/",
    "contact": {
      "name": "アナライズギア株式会社（シルギア）",
      "url": "https://shirugear.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://api.shirugear.com"
    }
  ],
  "paths": {
    "/postage/v1/rates.json": {
      "get": {
        "summary": "全部の種類の料金と条件",
        "operationId": "getRates",
        "responses": {
          "200": {
            "description": "10種類の料金",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Rates"
                }
              }
            }
          },
          "403": {
            "description": "日本国内以外から",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "GET/HEAD以外",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/postage/v1/{key}.json": {
      "get": {
        "summary": "1種類の料金と条件",
        "operationId": "getService",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "teikei",
                "teikeigai_in",
                "teikeigai_out",
                "hagaki",
                "ofuku",
                "minileter",
                "smartletter",
                "lp_light",
                "lp_plus",
                "yu_packet"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "1種類",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceResponse"
                }
              }
            }
          },
          "400": {
            "description": "URLの形が違う",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "日本国内以外から",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "無い種類",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "GET/HEAD以外",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/postage/v1/meta.json": {
      "get": {
        "summary": "データの版・出典・種類の一覧",
        "operationId": "getMeta",
        "responses": {
          "200": {
            "description": "版",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Meta"
                }
              }
            }
          },
          "403": {
            "description": "日本国内以外から",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Tier": {
        "type": "object",
        "required": [
          "max_g",
          "price"
        ],
        "properties": {
          "max_g": {
            "type": "integer",
            "description": "その重さまで（g）"
          },
          "price": {
            "type": "integer",
            "description": "料金（円・税込）"
          }
        }
      },
      "Limits": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "long_min_mm": {
            "type": [
              "integer",
              "null"
            ]
          },
          "long_max_mm": {
            "type": [
              "integer",
              "null"
            ]
          },
          "short_min_mm": {
            "type": [
              "integer",
              "null"
            ]
          },
          "short_max_mm": {
            "type": [
              "integer",
              "null"
            ]
          },
          "thickness_max_mm": {
            "type": [
              "integer",
              "null"
            ]
          },
          "sum_max_mm": {
            "type": [
              "integer",
              "null"
            ]
          },
          "weight_max_g": {
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "description": "サイズ・重さの条件（mm・g）。決まりが無い項目は null。はがきは null"
      },
      "Source": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Service": {
        "type": "object",
        "required": [
          "key",
          "name",
          "group",
          "pricing",
          "price",
          "tiers",
          "weight_max_g",
          "limits",
          "note",
          "source"
        ],
        "properties": {
          "key": {
            "type": "string",
            "enum": [
              "teikei",
              "teikeigai_in",
              "teikeigai_out",
              "hagaki",
              "ofuku",
              "minileter",
              "smartletter",
              "lp_light",
              "lp_plus",
              "yu_packet"
            ]
          },
          "name": {
            "type": "string"
          },
          "group": {
            "type": "string",
            "enum": [
              "letter",
              "postcard",
              "envelope",
              "parcel"
            ]
          },
          "pricing": {
            "type": "string",
            "enum": [
              "by_weight",
              "flat"
            ],
            "description": "by_weight＝tiers を見る、flat＝price を見る"
          },
          "price": {
            "type": [
              "integer",
              "null"
            ],
            "description": "決まった料金（円・税込）。by_weight のときは null"
          },
          "tiers": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/Tier"
            },
            "description": "重さの区分（軽い順）。flat のときは null"
          },
          "weight_max_g": {
            "type": [
              "integer",
              "null"
            ],
            "description": "送れる重さの上限（g）。記載が無いもの（はがき）は null"
          },
          "limits": {
            "$ref": "#/components/schemas/Limits"
          },
          "note": {
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/Source"
          }
        }
      },
      "ServiceResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Service"
          },
          {
            "type": "object",
            "properties": {
              "currency": {
                "type": "string",
                "const": "JPY"
              },
              "tax": {
                "type": "string",
                "const": "included"
              },
              "data_version": {
                "type": "string",
                "description": "日本郵便のページと照らし合わせた日 YYYY-MM-DD"
              }
            }
          }
        ]
      },
      "Rates": {
        "type": "object",
        "properties": {
          "services": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Service"
            }
          },
          "currency": {
            "type": "string",
            "const": "JPY"
          },
          "tax": {
            "type": "string",
            "const": "included"
          },
          "data_version": {
            "type": "string",
            "description": "日本郵便のページと照らし合わせた日 YYYY-MM-DD"
          }
        }
      },
      "Meta": {
        "type": "object",
        "properties": {
          "data_version": {
            "type": "string"
          },
          "checked_at": {
            "type": "string"
          },
          "scope": {
            "type": "string"
          },
          "services": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "counts": {
            "type": "object",
            "properties": {
              "services": {
                "type": "integer"
              }
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Source"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "status": {
                "type": "integer"
              },
              "code": {
                "type": "string",
                "enum": [
                  "invalid_request",
                  "region_not_allowed",
                  "not_found",
                  "method_not_allowed"
                ]
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
