{
  "openapi": "3.0.3",
  "info": {
    "title": "NPSNAV Public API",
    "description": "Public API for accessing Net Asset Values (NAVs) of India's National Pension Scheme (NPS) funds.\n\nNo authentication required.\nUnlimited non-commercial usage.\nDesigned for Google Sheets, Microsoft Excel, and personal financial dashboards.",
    "version": "1.1.0"
  },
  "servers": [
    {
      "url": "https://npsnav.in",
      "description": "Production API"
    }
  ],
  "paths": {
    "/api/schemes": {
      "get": {
        "summary": "All Schemes API",
        "description": "Returns the list of all available NPS scheme codes and scheme names.\n\nUse this endpoint to discover valid `scheme_code` values before calling other APIs.",
        "responses": {
          "200": {
            "description": "List of all NPS schemes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "array",
                        "items": [
                          { "type": "string", "example": "SM001001" },
                          { "type": "string", "example": "SBI PENSION FUND SCHEME - CENTRAL GOVT" }
                        ]
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "count": { "type": "integer", "example": 151 },
                        "lastUpdated": { "type": "string", "example": "22-12-2025" }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },

    "/api/{scheme_code}": {
      "get": {
        "summary": "Latest NAV API",
        "description": "Returns the raw NAV value as plain text for a single NPS fund.\n\nIdeal for spreadsheet functions like IMPORTDATA (Google Sheets) and WEBSERVICE (Excel).",
        "parameters": [
          {
            "name": "scheme_code",
            "in": "path",
            "required": true,
            "description": "Unique NPS scheme code (example: SM001001)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Plain text NAV value",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "49.7707"
                }
              }
            }
          }
        }
      }
    },

    "/api/latest": {
      "get": {
        "summary": "Latest NAV of All Funds (Detailed)",
        "description": "Returns the most recent NAV values for all NPS funds with PFM details and last updated date.",
        "responses": {
          "200": {
            "description": "Detailed NAV snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "PFM Code": { "type": "string" },
                          "PFM Name": { "type": "string" },
                          "Scheme Code": { "type": "string" },
                          "Scheme Name": { "type": "string" },
                          "NAV": { "type": "string" },
                          "Last Updated": { "type": "string" }
                        }
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "currency": { "type": "string", "example": "INR" },
                        "dataType": { "type": "string", "example": "NAV" },
                        "count": { "type": "integer" },
                        "lastUpdated": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },

    "/api/latest-min": {
      "get": {
        "summary": "Latest NAV of All Funds (Minimal)",
        "description": "Lightweight endpoint returning only Scheme Code and NAV for all funds.",
        "responses": {
          "200": {
            "description": "Minimal NAV snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "array",
                        "items": [
                          { "type": "string", "example": "SM001001" },
                          { "type": "number", "example": 49.7707 }
                        ]
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "count": { "type": "integer" },
                        "lastUpdated": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },

    "/api/detailed/{scheme_code}": {
      "get": {
        "summary": "Detailed All Funds Data",
        "description": "Returns NAV along with 1D to 5Y return percentages for a specific NPS fund.",
        "parameters": [
          {
            "name": "scheme_code",
            "in": "path",
            "required": true,
            "description": "Unique NPS scheme code",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Detailed fund data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "Last Updated": { "type": "string" },
                    "PFM Code": { "type": "string" },
                    "PFM Name": { "type": "string" },
                    "Scheme Code": { "type": "string" },
                    "Scheme Name": { "type": "string" },
                    "NAV": { "type": "string" },
                    "1D": { "type": "string" },
                    "7D": { "type": "string" },
                    "1M": { "type": "string" },
                    "3M": { "type": "string" },
                    "6M": { "type": "string" },
                    "1Y": { "type": "string" },
                    "3Y": { "type": "string" },
                    "5Y": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },

    "/api/historical/{scheme_code}": {
      "get": {
        "summary": "Historical Fund NAV Data",
        "description": "Returns historical daily NAV values for a specific NPS fund.",
        "parameters": [
          {
            "name": "scheme_code",
            "in": "path",
            "required": true,
            "description": "Unique NPS scheme code",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Historical NAV dataset",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "date": { "type": "string" },
                          "nav": { "type": "number" }
                        }
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "currency": { "type": "string", "example": "INR" },
                        "dataType": { "type": "string", "example": "NAV" },
                        "lastUpdated": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
