{
  "openapi": "3.1.0",
  "info": {
    "title": "Food Nutrition API",
    "version": "2.3.0",
    "description": "Structured nutrition data from USDA (USA) and MEXT (Japan)",
    "contact": {
      "name": "Food Nutrition API",
      "url": "https://fooddata-api.com"
    },
    "x-guidance": "Free endpoints: GET /api/foods, GET /api/search, GET /api/stats. Paid endpoints: POST /api/jp/foods, POST /api/jp/search. Each paid request costs 0.01 USD (USDC on Base). Send a POST with JSON body. Unpaid requests receive HTTP 402 with payment requirements."
  },
  "servers": [
    {
      "url": "https://fooddata-api.com"
    }
  ],
  "x-service-info": {
    "categories": [
      "data",
      "nutrition",
      "health"
    ],
    "docs": {
      "homepage": "https://fooddata-api.com"
    }
  },
  "security": [
    {
      "mpp": []
    }
  ],
  "components": {
    "securitySchemes": {
      "mpp": {
        "type": "http",
        "scheme": "mpp",
        "description": "Machine Payments Protocol (HTTP 402 + X-PAYMENT header)"
      }
    }
  },
  "paths": {
    "/api/jp/foods": {
      "post": {
        "operationId": "listJapaneseFoods",
        "summary": "Japanese foods list",
        "description": "2538 Japanese foods with full nutrient profiles",
        "x-payment-info": {
          "pricingMode": "fixed",
          "price": "0.010000",
          "protocols": [
            "mpp",
            "x402"
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000,
                    "default": 100,
                    "description": "Number of results"
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0,
                    "default": 0,
                    "description": "Pagination offset"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "foods": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  },
                  "required": [
                    "total",
                    "limit",
                    "offset",
                    "foods"
                  ]
                }
              }
            }
          },
          "402": {
            "description": "Payment Required"
          }
        }
      }
    },
    "/api/jp/foods/{food_id}": {
      "post": {
        "operationId": "getJapaneseFoodById",
        "summary": "Japanese food by ID",
        "description": "Full nutrient profile for a specific Japanese food",
        "x-payment-info": {
          "pricingMode": "fixed",
          "price": "0.010000",
          "protocols": [
            "mpp",
            "x402"
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "food_id": {
                    "type": "string",
                    "description": "Japanese food ID"
                  }
                },
                "required": [
                  "food_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required"
          }
        }
      }
    },
    "/api/jp/search": {
      "post": {
        "operationId": "searchJapaneseFoods",
        "summary": "Search Japanese foods",
        "description": "Search Japanese foods by name (JP or EN)",
        "x-payment-info": {
          "pricingMode": "fixed",
          "price": "0.010000",
          "protocols": [
            "mpp",
            "x402"
          ]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "q": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Search query (JP or EN)"
                  }
                },
                "required": [
                  "q"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required"
          }
        }
      }
    },
    "/api/foods": {
      "get": {
        "operationId": "listUSDAFoods",
        "summary": "USDA foods list (free)",
        "security": [],
        "responses": {
          "200": {
            "description": "Successful response"
          }
        }
      }
    },
    "/api/stats": {
      "get": {
        "operationId": "getStats",
        "summary": "Database statistics (free)",
        "security": [],
        "responses": {
          "200": {
            "description": "Successful response"
          }
        }
      }
    }
  }
}