Oushodh logooushodh

How to move your existing medicine list to the Oushodh API

By Al Amin Ahamed · Published · Updated · 6 min read

Short answer

Export your items to CSV with brand, strength, dosage form and maker, and search each brand with the API. Save the medicine's uuid only when exactly one answer fits, and let a person decide the rest. Load only the uuid and its status back, so your own records never change.

Key facts

  • Search matches the start of words in the brand, an alternate name, the generic or the manufacturer, not the strengthSearch, API reference, 30 Nov, 2026
  • A Developer key makes up to 60 requests a minute, and the account up to 50,000 a monthRate limits and quota, 30 Nov, 2026
  • A 429 answer carries Retry-After, the seconds to waitErrors, API reference, 30 Nov, 2026
  • Medicine IDs may be stored with no time limit; API responses may notTerms of use, 30 Nov, 2026

Most teams that come to Oushodh already have a medicine list: an item table in a POS, a product master in an ERP, a spreadsheet kept by the pharmacist, or a list copied from another site years ago. This post shows how to move that list onto Oushodh IDs from a CSV export, with a script you can run today, and without changing a record you hold.

What does moving to the API change in your data?

Less than you might expect. Your item codes, stock, selling prices, sales and invoices stay as they are. Each item gains the uuid of the Oushodh medicine it is, and the screens that show medicine details read them live with GET /v1/medicines/{uuid}.

Flowchart for moving an existing medicine list: back up and add two empty columns, a trial run on a test key, match every item, people decide the rest, then switch screens to live details behind a setting. Turning the setting off undoes the switch.
Five steps, and a way back at each one.

The migration guide walks the five steps with screenshots of the member portal. This post covers the part most teams write themselves: the matching run.

What should the export look like?

One row per item, with your own code and the four things that tell medicines apart: brand, strength, dosage form and maker. Any other columns, such as your price, ride along untouched.

sku,brand,strength,form,maker,price
1001,Napa,500 mg,Tab,Beximco,1.20
1002,Napa,120mg/5ml,Susp,Beximco,35
1003,Seclo,20 mg,Cap,Square,7
1004,Shop bag,,,,5

Export the item table as it is today, and keep that file: it is your backup of the list before the move.

How does the script match each item?

It searches each item’s brand, and keeps only the answers whose strength, dosage form and maker fit your row. Search matches the start of words in the brand, an alternate name, the generic and the maker, but not the strength, so that check happens in your code. It saves the uuid only when exactly one medicine fits.

import csv
import os
import sys
import time

import requests

API = "https://api.oushodh.dev/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['OUSHODH_API_KEY']}"}
# Your own short forms, expanded before comparing.
SHORT = {"tab": "tablet", "cap": "capsule", "syp": "syrup", "inj": "injection", "susp": "suspension"}


def squash(s):
    return "".join((s or "").lower().split())


def form(s):
    s = squash(s).rstrip(".")
    return SHORT.get(s, s)


def search(q):
    while True:
        r = requests.get(f"{API}/medicines/search", headers=HEADERS,
                         params={"q": q, "limit": 50}, timeout=10)
        if r.status_code == 429:
            time.sleep(int(r.headers.get("Retry-After", "60")))
            continue
        r.raise_for_status()
        return r.json()["items"]


def fits(row):
    return [m["uuid"] for m in search(row["brand"])
            if squash(m["brand"]) == squash(row["brand"])
            and squash(m["strength"]) == squash(row["strength"])
            and squash(m["dosage_form"]) == form(row["form"])
            and squash((m["manufacturer"] or {}).get("name")).startswith(squash(row["maker"]))]


src, out = sys.argv[1], sys.argv[2]
with open(src, newline="", encoding="utf-8") as f:
    rows = list(csv.DictReader(f))

done = {}
if os.path.exists(out):
    with open(out, newline="", encoding="utf-8") as f:
        done = {r["sku"]: r for r in csv.DictReader(f)}

fields = list(rows[0]) + ["oushodh_uuid", "match_status", "candidates"]
with open(out, "w", newline="", encoding="utf-8") as f:
    w = csv.DictWriter(f, fieldnames=fields)
    w.writeheader()
    for row in rows:
        if row["sku"] in done:  # matched on an earlier run
            w.writerow(done[row["sku"]])
            continue
        found = fits(row)
        status = "matched" if len(found) == 1 else "review" if found else "none"
        w.writerow({**row, "oushodh_uuid": found[0] if status == "matched" else "",
                    "match_status": status, "candidates": " ".join(found) if status == "review" else ""})
        f.flush()

Run it with your key in the environment, never in the file:

export OUSHODH_API_KEY=oush_...
python match.py items.csv items-matched.csv

On the four rows above, the output adds three columns:

sku,brand,strength,form,maker,price,oushodh_uuid,match_status,candidates
1001,Napa,500 mg,Tab,Beximco,1.20,01a1ba6f-f4d6-7143-ac84-9376f520eef8,matched,
1002,Napa,120mg/5ml,Susp,Beximco,35,01a1ba6f-fc33-7121-ac9c-a2b5ca7005e8,matched,
1003,Seclo,20 mg,Cap,Square,7,01a1ba6f-f71d-74e9-9b5d-7078fe508a55,matched,
1004,Shop bag,,,,5,,none,

squash drops spaces and case, so 120mg/5ml and 120 mg/5 ml compare equal. SHORT expands your own short forms: add the ones your records use. Napa comes as both a syrup and a suspension at 120 mg/5 ml, and the form keeps them apart.

What if the run stops halfway?

Run it again with the same two files. Rows already in the output are copied across without a new search, so the run picks up where it stopped and no request is spent twice. On a 429 answer the script waits the seconds in Retry-After, then goes on.

A Developer key makes up to 60 requests a minute, so 3,000 items take at least 50 minutes and use 3,000 of the month’s 50,000 requests. Try the first few hundred on a test app’s key, which runs at 10 a minute, before you run the whole list. The rate limits page has every plan’s numbers.

What happens to the rows that did not match?

review rows list the candidates’ uuids, and a person picks one, or none. none rows are often not medicines at all, like the shop bag, or are spelled so differently that a search by the generic finds them. A few are not in the data yet. All of them keep working in your system, unmapped.

Never take the first search result because it comes first. Rank says which name matched best, not which medicine is on your shelf. Connecting your inventory has the matching rules in more detail.

How do you load the result back?

Import oushodh_uuid and match_status into the two empty columns you added, by sku. Do not import anything else: the file holds IDs and your own data only, and the terms of use let you store medicine IDs with no time limit, but not the medicine records. Then switch the screens over behind a setting, as the migration guide shows, so turning it off puts everything back as it was.

Share this post

FAQ

  • Do I have to change my item codes?

    No. Your codes, stock, prices and sales stay as they are. Each item gains the uuid of the Oushodh medicine it is, in a column of its own.

  • Is there a bulk-match endpoint?

    No. Each item is one search, within your plan's per-minute limit. A run that stops can start again without searching the matched rows twice.

  • Can I undo the move?

    Yes. Nothing you held is changed: the match fills two new columns, and the screens switch behind a setting. Turn the setting off and the old screens work as before.

  • Can I copy the medicine details into my table while I am at it?

    No. The terms let you store medicine IDs, not API answers. Screens read the details live with the uuid.

Sources

Choosing a data source

Plan your catalogue migration