{
  "openapi": "3.1.0",
  "info": {
    "title": "Oushodh API",
    "version": "1",
    "summary": "Medicine data for Bangladesh, checked against the DGDA register.",
    "description": "Read-only JSON over HTTPS. Every request needs an API key from the member portal at https://app.oushodh.dev. `/v1` only gains fields and endpoints: a field is never renamed, retyped or removed in `v1`.",
    "contact": {
      "name": "Oushodh",
      "email": "support@oushodh.dev",
      "url": "https://oushodh.dev/contact"
    },
    "termsOfService": "https://oushodh.dev/terms-of-use"
  },
  "servers": [
    {
      "url": "https://api.oushodh.dev"
    }
  ],
  "security": [
    {
      "key": []
    }
  ],
  "tags": [
    {
      "name": "Medicines",
      "description": "Medicines, one record per brand, strength and form."
    },
    {
      "name": "Account",
      "description": "What the key belongs to."
    }
  ],
  "paths": {
    "/v1/meta": {
      "get": {
        "operationId": "getMeta",
        "tags": [
          "Account"
        ],
        "summary": "Account info",
        "description": "The account the key belongs to, its ID profile, the number of medicines and the time of the last import. Use it to check that a key works.",
        "responses": {
          "200": {
            "description": "The account and the data it reads.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Meta"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/PlanExpired"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          }
        }
      }
    },
    "/v1/medicines": {
      "get": {
        "operationId": "listMedicines",
        "tags": [
          "Medicines"
        ],
        "summary": "List medicines",
        "description": "One page of medicines, in the order of their permanent number. Page through to the end to copy the whole database, or pass `updated_since` to get only what changed.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Medicines on one page.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "The `next` value from the page before. Leave it out for the first page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "updated_since",
            "in": "query",
            "description": "Only medicines changed at or after this time, oldest change first. Written like `2026-11-08T09:30:00Z`.",
            "schema": {
              "type": "string",
              "format": "date-time",
              "examples": [
                "2026-11-08T09:30:00Z"
              ]
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Only medicines whose brand, generic or manufacturer starts with these words, or whose ID matches.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of medicines.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/PlanExpired"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          }
        }
      }
    },
    "/v1/medicines/search": {
      "get": {
        "operationId": "searchMedicines",
        "tags": [
          "Medicines"
        ],
        "summary": "Search",
        "description": "The best matches for a person typing a name, best match first. Each word of `q` matches the start of a brand, alternate name, generic or manufacturer word. When `q` is an ID in any profile, an old ID or a UUID, the answer is that one medicine. There is no cursor: to page every match, use List medicines with `q`.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "What the person typed: brand, generic, manufacturer or alternate-name words, or an ID.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Most medicines to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The best matches and the count of every match.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/PlanExpired"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          }
        }
      }
    },
    "/v1/medicines/{ref}": {
      "get": {
        "operationId": "getMedicine",
        "tags": [
          "Medicines"
        ],
        "summary": "Get a medicine",
        "description": "One medicine. The answer always carries the medicine's current ID in your profile, even when you asked by an old ID.",
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "The medicine's ID in any profile, an old ID, or its UUID.",
            "schema": {
              "type": "string",
              "examples": [
                "MED-012933",
                "01a1ba6f-f4d6-7143-ac84-9376f520eef8"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The medicine.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Medicine"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/PlanExpired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "key": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key from the member portal's Keys page. It starts with `oush_` and is shown once."
      }
    },
    "schemas": {
      "Medicine": {
        "type": "object",
        "description": "One medicine: one brand in one strength and dosage form. A value no source gives is `null`, never a blank, a zero or an estimate.",
        "required": [
          "id",
          "uuid",
          "brand",
          "category",
          "product_name",
          "product_image",
          "unit",
          "size",
          "price",
          "price_per",
          "price_source",
          "unit_prices",
          "description_en",
          "description_bn",
          "dosage_form",
          "strength",
          "generic_name",
          "manufacturer",
          "source_url",
          "last_updated",
          "dgda_listed",
          "medicine_type"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The medicine's ID in your account's ID profile. Show it to people; it never changes and is never reused.",
            "examples": [
              "MED-012933"
            ]
          },
          "uuid": {
            "type": "string",
            "description": "The key that never changes. Store it to match a medicine across syncs.",
            "examples": [
              "01a1ba6f-f4d6-7143-ac84-9376f520eef8"
            ]
          },
          "brand": {
            "type": "string",
            "examples": [
              "Napa"
            ]
          },
          "category": {
            "type": [
              "string",
              "null"
            ],
            "description": "Reserved for a symptom category. `null` for every medicine today."
          },
          "product_name": {
            "type": "string",
            "description": "Brand, strength and dosage form together.",
            "examples": [
              "Napa 500 mg Tablet"
            ]
          },
          "product_image": {
            "type": [
              "string",
              "null"
            ],
            "description": "Reserved for an image. `null` for every medicine today."
          },
          "unit": {
            "type": [
              "string",
              "null"
            ],
            "description": "The pack's unit, such as `Strip` or `Bottle`."
          },
          "size": {
            "type": [
              "string",
              "null"
            ],
            "description": "The pack's size, such as `10 Tablets` or `200 ml`."
          },
          "price": {
            "type": [
              "number",
              "null"
            ],
            "description": "MRP in Bangladeshi taka (BDT) of what `price_per` names. `null` when `unit_prices` holds the prices instead."
          },
          "price_per": {
            "type": [
              "string",
              "null"
            ],
            "description": "What `price` buys: `unit`, `strip`, or the pack as its source names it, such as `100 ml bottle`.",
            "examples": [
              "unit",
              "strip",
              "100 ml bottle"
            ]
          },
          "price_source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the price comes from. The DGDA price list comes first when it has one.",
            "examples": [
              "dgda_price",
              "medex"
            ]
          },
          "unit_prices": {
            "type": "array",
            "description": "The unit price in each pack size, cheapest first, when `price_source` gives several (a 15 gm and a 30 gm tube). `price` and `price_per` are then `null`, unless a person chose one size as the price. Empty when the source gives one price.",
            "items": {
              "type": "object",
              "required": [
                "size",
                "price"
              ],
              "properties": {
                "size": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "The pack size as the source names it. `null` when the source names none for this price.",
                  "examples": [
                    "15 gm in Tube Pack"
                  ]
                },
                "price": {
                  "type": "number",
                  "description": "MRP in BDT of one unit (a tablet, a tube) in that size."
                }
              }
            }
          },
          "description_en": {
            "type": [
              "string",
              "null"
            ],
            "description": "A description in English."
          },
          "description_bn": {
            "type": [
              "string",
              "null"
            ],
            "description": "A description in Bangla."
          },
          "dosage_form": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "Tablet"
            ]
          },
          "strength": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "500 mg"
            ]
          },
          "generic_name": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "Paracetamol"
            ]
          },
          "manufacturer": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "Beximco Pharmaceuticals PLC."
            ]
          },
          "source_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The page the record was read from."
          },
          "last_updated": {
            "type": "string",
            "format": "date-time",
            "description": "When any field of this record last changed. Sync uses it.",
            "examples": [
              "2026-11-09T15:27:34Z"
            ]
          },
          "dgda_listed": {
            "type": "boolean",
            "description": "`true` when a DGDA registration (DAR number) links to the medicine."
          },
          "medicine_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "allopathic",
              "homoeopathic",
              "herbal",
              "ayurvedic",
              "unani",
              null
            ],
            "description": "The DGDA register that lists it. `null` when no register lists it."
          }
        }
      },
      "Page": {
        "type": "object",
        "required": [
          "items",
          "next",
          "total"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Medicine"
            },
            "description": "The medicines on this page. Each is a [medicine object](https://oushodh.dev/docs/medicine); a value no source gives is `null`."
          },
          "next": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass it back as `cursor` for the next page. `null` on the last page."
          },
          "total": {
            "type": "integer",
            "description": "How many medicines match, across all pages."
          }
        }
      },
      "SearchResult": {
        "type": "object",
        "required": [
          "items",
          "total"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Medicine"
            },
            "description": "The best matches first, at most `limit`. Each is a [medicine object](https://oushodh.dev/docs/medicine)."
          },
          "total": {
            "type": "integer",
            "description": "How many medicines match, including those past `limit`."
          }
        }
      },
      "Meta": {
        "type": "object",
        "required": [
          "client",
          "id_profile",
          "medicines",
          "last_import"
        ],
        "properties": {
          "client": {
            "type": "string",
            "description": "The account the key belongs to."
          },
          "id_profile": {
            "type": "string",
            "description": "The ID profile your medicine IDs come from."
          },
          "medicines": {
            "type": "integer",
            "description": "How many medicines the API holds.",
            "examples": [
              58937
            ]
          },
          "last_import": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the data was last imported.",
            "examples": [
              "2026-11-09T15:27:40Z"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "bad_request",
                  "unauthorized",
                  "plan_expired",
                  "not_found",
                  "rate_limited",
                  "quota_exceeded",
                  "internal"
                ]
              },
              "message": {
                "type": "string",
                "description": "For people. Do not match on it; it may change."
              }
            }
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "`bad_request`: a bad parameter, such as `limit=0`, a time in another form, or a missing `q`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "`unauthorized`: no key, an unknown key or a revoked key. The answer never says which.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PlanExpired": {
        "description": "`plan_expired`: the key's account has no active plan.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "`not_found`: no medicine has that ID or UUID.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "`rate_limited`: more requests in a minute than the key's plan allows. `quota_exceeded`: the plan's requests for this month are used up.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before trying again. For `quota_exceeded`, the seconds to the start of next month.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Internal": {
        "description": "`internal`: a fault on our side. The details go to our log, not the answer.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}