{
  "openapi": "3.0.0",
  "info": {
    "version": "3.0.0",
    "title": "Rig Veda API",
    "description": "Metadata API for the Rig Veda. Makes available relationships among mandals, suktas, poets, gods, and meters.",
    "contact": {
      "email": "ab.techwriter@gmail.com"
    },
    "license": {
      "name": "CC BY-NC 4.0",
      "url": "https://creativecommons.org/licenses/by-nc/4.0/"
    }
  },
  "externalDocs": {
    "description": "Indica APIs home",
    "url": "https://aninditabasu.github.io/indica/"
  },
  "servers": [
    {
      "url": "https://indica-1hwj.onrender.com/rv/v3",
      "description": "Rig Veda API"
    }
  ],
  "paths": {
    "/mandal/{n}": {
      "get": {
        "summary": "Get the hymn count in a mandal",
        "parameters": [
          { "$ref": "#/components/parameters/MandalParam" }
        ],
        "responses": {
          "200": {
            "description": "Hymn count in the mandal"
          },
          "400": {
            "description": "Only 10 mandals in Rig Veda"
          }
        }
      }
    },

    "/mandal/{n}/meters": {
      "get": {
        "summary": "Get the meter counts in a mandal",
        "parameters": [
          { "$ref": "#/components/parameters/MandalParam" }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/MeterCounts"
          }
        }
      }
    },

    "/mandal/{n}/sungfor": {
      "get": {
        "summary": "Get the counts of the various gods in a mandal",
        "parameters": [
          { "$ref": "#/components/parameters/MandalParam" }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/GodCounts"
          }
        }
      }
    },

    "/mandal/{n}/sungby": {
      "get": {
        "summary": "Get the counts of the various poets in a mandal",
        "parameters": [
          { "$ref": "#/components/parameters/MandalParam" }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/PoetCounts"
          }
        }
      }
    },

    "/sungfor/{god}/mandals": {
      "get": {
        "summary": "Get all mandals in which a god is sung to",
        "parameters": [
          { "$ref": "#/components/parameters/GodParam" },
          { "$ref": "#/components/parameters/ExpandParam" },
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "Mandal counts or expanded hymn list"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },

    "/sungfor/{god}/meters": {
      "get": {
        "summary": "Get all meters used for singing to a god",
        "parameters": [
          { "$ref": "#/components/parameters/GodParam" },
          { "$ref": "#/components/parameters/ExpandParam" },
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "Meter counts or expanded meter list"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },

    "/sungfor/{god}/sungby": {
      "get": {
        "summary": "Get all poets that sang to a specific god",
        "parameters": [
          { "$ref": "#/components/parameters/GodParam" },
          { "$ref": "#/components/parameters/ExpandParam" },
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "Poet counts or expanded poet-meter distribution",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SungforSungbyExpanded"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },

    "/sungby/{poet}/mandals": {
      "get": {
        "summary": "Get all mandals that the hymns of a poet are included in",
        "parameters": [
          { "$ref": "#/components/parameters/PoetParam" },
          { "$ref": "#/components/parameters/ExpandParam" },
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "Mandal counts or expanded hymn list"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },

    "/sungby/{poet}/meters": {
      "get": {
        "summary": "Get all meters used by a specific poet",
        "parameters": [
          { "$ref": "#/components/parameters/PoetParam" },
          { "$ref": "#/components/parameters/ExpandParam" },
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "Meter counts or expanded meter list"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },

    "/sungby/{poet}/sungfor": {
      "get": {
        "summary": "Get all gods that a poet sang to",
        "parameters": [
          { "$ref": "#/components/parameters/PoetParam" },
          { "$ref": "#/components/parameters/ExpandParam" },
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "God counts or expanded list"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },

    "/meters": {
      "get": {
        "summary": "Get all meter counts",
        "responses": {
          "200": {
            "$ref": "#/components/responses/MeterCounts"
          }
        }
      }
    },

    "/sungforcategories": {
      "get": {
        "summary": "Get the counts for the categories of gods",
        "parameters": [
          { "$ref": "#/components/parameters/ExpandParam" },
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "Counts or expanded hymn list"
          }
        }
      }
    },

    "/sungbycategories": {
      "get": {
        "summary": "Get the counts for the categories of poets",
        "parameters": [
          { "$ref": "#/components/parameters/ExpandParam" },
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "Counts or expanded hymn list"
          }
        }
      }
    },

    "/hymns": {
      "get": {
        "summary": "Get hymns matching one or more filters",
        "parameters": [
          { "$ref": "#/components/parameters/HymnSungforParam" },
          { "$ref": "#/components/parameters/HymnSungbyParam" },
          { "$ref": "#/components/parameters/HymnMeterParam" },
          { "$ref": "#/components/parameters/HymnMandalParam" }
        ],
        "responses": {
          "200": {
            "description": "Matching hymns"
          },
          "400": {
            "description": "At least one filter is required"
          }
        }
      }
    },

    "/pairs/{god}/{poet}": {
      "get": {
        "summary": "Get hymns for a god-poet pair",
        "parameters": [
          { "$ref": "#/components/parameters/GodParam" },
          { "$ref": "#/components/parameters/PoetParam" },
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "Matching hymns"
          }
        }
      }
    },

    "/pairs/{godcategory}/{poetcategory}": {
      "get": {
        "summary": "Get hymns for a god-category and poet-category pair",
        "parameters": [
          {
            "name": "godcategory",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SungforCategory"
            }
          },
          {
            "name": "poetcategory",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SungbyCategory"
            }
          },
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "Matching hymns"
          }
        }
      }
    },

    "/monologues": {
      "get": {
        "summary": "Get hymns where the poet sings to themselves",
        "parameters": [
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "Paginated monologue hymns"
          }
        }
      }
    },

    "/conversations": {
      "get": {
        "summary": "Get hymns that are dialogues",
        "parameters": [
          { "$ref": "#/components/parameters/PageParam" },
          { "$ref": "#/components/parameters/LimitParam" }
        ],
        "responses": {
          "200": {
            "description": "Paginated conversation hymns"
          }
        }
      }
    },

    "/godlist": {
  "get": {
    "summary": "List all gods",
    "responses": {
      "200": {
        "description": "Alphabetically sorted list of gods",
        "content": {
          "application/json": {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
},

    "/poetlist": {
  "get": {
    "summary": "List all poets",
    "responses": {
      "200": {
        "description": "Alphabetically sorted list of poets",
        "content": {
          "application/json": {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
},

    "/meterlist": {
  "get": {
    "summary": "List all meters",
    "responses": {
      "200": {
        "description": "Alphabetically sorted list of meters",
        "content": {
          "application/json": {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
},

    "/godcategorieslist": {
  "get": {
    "summary": "List all categories for gods",
    "responses": {
      "200": {
        "description": "Alphabetically sorted list of categories",
        "content": {
          "application/json": {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
},

    "/poetcategorieslist": {
  "get": {
    "summary": "List all categories for the poets",
    "responses": {
      "200": {
        "description": "Alphabetically sorted list of categories of poets",
        "content": {
          "application/json": {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
  },

  "components": {
    "parameters": {
      "MandalParam": {
        "name": "n",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10
        }
      },

      "GodParam": {
        "name": "god",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },

      "PoetParam": {
        "name": "poet",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },

      "ExpandParam": {
        "name": "expand",
        "in": "query",
        "required": false,
        "schema": {
          "type": "boolean",
          "default": false
        }
      },

      "PageParam": {
        "name": "page",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 1
        }
      },

      "LimitParam": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 50,
          "default": 27
        }
      },

      "HymnSungforParam": {
        "name": "sungfor",
        "in": "query",
        "schema": {
          "type": "string"
        }
      },

      "HymnSungbyParam": {
        "name": "sungby",
        "in": "query",
        "schema": {
          "type": "string"
        }
      },

      "HymnMeterParam": {
        "name": "meter",
        "in": "query",
        "schema": {
          "type": "string"
        }
      },

      "HymnMandalParam": {
        "name": "mandal",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10
        }
      }
    },

    "responses": {
      "NotFound": {
        "description": "Resource not found"
      },

      "MeterCounts": {
        "description": "Counts of poetic meters"
      },

      "GodCounts": {
        "description": "Counts of gods"
      },

      "PoetCounts": {
        "description": "Counts of poets"
      }
    },

    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },

      "SungbyCategory": {
        "type": "string",
        "enum": [
          "animal",
          "demon male",
          "divine female",
          "divine male",
          "human female",
          "human male"
        ]
      },

      "SungforCategory": {
        "type": "string",
        "enum": [
          "abstract",
          "animal",
          "demon male",
          "divine female",
          "divine human",
          "divine male",
          "human couple",
          "human female",
          "human male",
          "human unborn",
          "object",
          "plant"
        ]
      },

      "SungforSungbyExpanded": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer"
          },
          "pages": {
            "type": "integer"
          },
          "page": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "poet": {
                  "type": "string"
                },
                "meters": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "integer"
                  }
                }
              }
            }
          },
          "sungfor": {
            "type": "string"
          }
        }
      }
    }
  }
}
