{
  "openapi": "3.1.1",
  "info": {
    "title": "Ledgerly Income \u0026 Wealth Percentile API",
    "version": "1.0.0",
    "summary": "How rich am I? Your income or net wealth percentile in your country, from official surveys.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://ledgerlywealthpercentile.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "How rich am I? Your income or net wealth percentile in your country, from official surveys.",
        "description": "Places your household net income (Eurostat EU-SILC, 34 European countries) or net wealth (ECB Household Finance and Consumption Survey, euro area) among the people or households of your country, with the published cut points, your household-size equivalent and the EU or euro-area position. Interpolation is explained and every figure carries its source and year.\n\nMethodology:\n- Income: household disposable income ÷ the modified OECD scale (1 + 0.5 per further person aged 14+ + 0.3 per child under 14) gives the equivalised income per person that Eurostat ranks; persons, not households, are counted.\n- Wealth: household net wealth (all assets minus all debts) is ranked among households, as in the ECB survey; no equivalence scale.\n- Between published cut points (income P1–P5, deciles, quartiles, P95–P99; wealth P10–P90) the percentile is interpolated linearly. Above the top cut point a Pareto tail is fitted to the two highest cut points; below the lowest only a bound is given.\n- National-currency amounts are compared with Eurostat’s national-currency table; the EU comparison converts them at the ratio of the two tables’ medians (Eurostat’s own annual exchange rate).\n\nSurvey snapshots, not live data: incomes and wealth have moved since the survey year, and surveys miss most of the very richest households.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "ledgerly_wealth_percentile",
        "x-owner-app": "ledgerly",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LedgerlyWealthPercentileInput"
              },
              "examples": {
                "example1": {
                  "summary": "Germany: couple with €52,000 net income",
                  "value": {
                    "measure": "income",
                    "country": "DE",
                    "amount": 52000,
                    "currency": "EUR",
                    "adults": 2,
                    "children": 0
                  }
                },
                "example2": {
                  "summary": "Spain: net wealth of €250,000",
                  "value": {
                    "measure": "wealth",
                    "country": "ES",
                    "amount": 250000
                  }
                },
                "example3": {
                  "summary": "Sweden: family of four, SEK 720,000",
                  "value": {
                    "measure": "income",
                    "country": "SE",
                    "amount": 720000,
                    "currency": "national",
                    "adults": 2,
                    "children": 2
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LedgerlyWealthPercentileResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "LedgerlyWealthPercentileInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "measure": {
            "title": "Compare",
            "type": "string",
            "enum": [
              "income",
              "wealth"
            ],
            "default": "income"
          },
          "country": {
            "title": "Country",
            "type": "string",
            "enum": [
              "EA",
              "EU",
              "AL",
              "AT",
              "BE",
              "BG",
              "HR",
              "CY",
              "CZ",
              "DK",
              "EE",
              "FI",
              "FR",
              "DE",
              "GR",
              "HU",
              "IE",
              "IT",
              "LV",
              "LT",
              "LU",
              "MT",
              "ME",
              "NL",
              "MK",
              "NO",
              "PL",
              "PT",
              "RO",
              "RS",
              "SK",
              "SI",
              "ES",
              "SE",
              "CH",
              "TR"
            ],
            "default": "DE"
          },
          "amount": {
            "title": "Your amount",
            "description": "Income: disposable household income per year after taxes and social contributions, including benefits. Wealth: everything you own (home, savings, investments, vehicles, business) minus all debts.",
            "type": "number",
            "minimum": -100000000000,
            "maximum": 100000000000,
            "default": 52000
          },
          "currency": {
            "title": "Currency of the amount",
            "type": "string",
            "enum": [
              "EUR",
              "national"
            ],
            "default": "EUR"
          },
          "adults": {
            "title": "People aged 14 or over in the household",
            "type": "integer",
            "minimum": 1,
            "maximum": 12,
            "default": 2
          },
          "children": {
            "title": "Children under 14 in the household",
            "type": "integer",
            "minimum": 0,
            "maximum": 12,
            "default": 0
          }
        },
        "required": []
      },
      "LedgerlyWealthPercentileResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "measure",
              "country",
              "countryName",
              "dataYear",
              "currency",
              "amount",
              "comparedAmount",
              "equivalenceScale",
              "percentile",
              "bound",
              "segment",
              "median",
              "ratioToMedian",
              "reference",
              "cutPoints"
            ],
            "properties": {
              "measure": {
                "type": "string",
                "enum": [
                  "income",
                  "wealth"
                ]
              },
              "country": {
                "type": "string"
              },
              "countryName": {
                "type": "string"
              },
              "dataYear": {
                "type": "integer"
              },
              "currency": {
                "type": "string"
              },
              "amount": {
                "type": "number"
              },
              "comparedAmount": {
                "type": "number"
              },
              "equivalenceScale": {
                "type": "number"
              },
              "percentile": {
                "type": "number"
              },
              "bound": {
                "type": "string",
                "enum": [
                  "below",
                  "within",
                  "above"
                ]
              },
              "segment": {
                "type": "string"
              },
              "median": {
                "type": "number"
              },
              "ratioToMedian": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "reference": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "area",
                  "percentile",
                  "bound"
                ],
                "properties": {
                  "area": {
                    "type": "string"
                  },
                  "percentile": {
                    "type": "number"
                  },
                  "bound": {
                    "type": "string",
                    "enum": [
                      "below",
                      "within",
                      "above"
                    ]
                  }
                }
              },
              "cutPoints": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "percentile",
                    "value"
                  ],
                  "properties": {
                    "percentile": {
                      "type": "integer"
                    },
                    "value": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}