Oushodh logooushodh

How to add the Oushodh API to the software you already run

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

Short answer

Put one small API client on your server, between your POS, ERP or store and Oushodh: it holds the key, waits and retries after a 429, and turns errors into plain messages. Use an official SDK where your stack has one. Store only medicine IDs and your own records, and call the API each time you need a medicine's data.

Key facts

  • Official SDKs install from Packagist, npm, PyPI and six other registriesSDKs, 30 Nov, 2026
  • An SDK retries a 429 rate_limited after Retry-After, a 5xx and a network error, but not quota_exceededSDKs, 30 Nov, 2026
  • API responses may not be cached, stored or copied; medicine IDs may be stored with no time limitTerms of use, 30 Nov, 2026
  • /v1 mostly gains fields and endpoints; a breaking change is named on the changelog, as when manufacturer became an objectVersions, API guide, 2 Dec, 2026

Most teams that call Oushodh already run something: a pharmacy POS, an ERP, a hospital or clinic system, an e-pharmacy store. The API is plain HTTPS that answers JSON, mostly GET, so any stack can call it. What makes an integration last is the small layer around the call: where the key lives, what happens on an error, and what your database keeps. This guide covers that layer, with short examples in PHP and Laravel, Node and Python.

Where should the API call live?

On your server, in one small client that every part of your software goes through. The POS, the ERP screen or the store’s web page calls your server, and only your server calls Oushodh.

That is not a style choice. Anyone who has the key can use your plan, and a key inside a web page, a desktop app or a phone app can be copied out of it. Keep the key in your server’s environment, as OUSHODH_API_KEY, and put the route that calls Oushodh behind your own sign-in. The authentication page has the rest, and the POS search guide shows the same path for a search box.

Diagram: your POS, ERP or store has no API key and calls your API client on your server, which holds the key, retries and handles errors, and calls the Oushodh API. Your database keeps your own records and medicine IDs, never API answers.
One client on your server holds the key. Your software talks only to it.

Is there an SDK for my stack?

Yes for the common ones. The official SDKs are on Packagist, npm and PyPI, among others, and each reads the key from OUSHODH_API_KEY when you pass none:

Stack Install
PHP and Laravel composer require oushodh/oushodh-php
Node and TypeScript npm install @oushodh/sdk
Python pip install oushodh

Go, Rust, Java, .NET, Ruby and Dart have one too; the SDKs page lists them all. Every SDK has the same methods, named in each language’s style:

import { Oushodh } from "@oushodh/sdk";

const oushodh = new Oushodh(); // reads OUSHODH_API_KEY
const result = await oushodh.search("napa", { limit: 10 });
const medicine = await oushodh.getMedicine("MED-012933");

An SDK also handles retries for you. It waits the seconds in Retry-After after a 429 rate_limited, and tries again after a fault on our side or a network error. A 429 quota_exceeded it raises at once.

What does the call look like without an SDK?

A GET with the key in the Authorization header. In Laravel, a route your POS calls might be:

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Route;

// OUSHODH_API_KEY is in .env and read in config/services.php
Route::middleware('auth')->get('/medicines/search', function (Request $request) {
    $response = Http::withToken(config('services.oushodh.key'))
        ->timeout(10)
        ->get('https://api.oushodh.dev/v1/medicines/search', [
            'q' => $request->query('q'),
            'limit' => 10,
        ]);

    if ($response->failed()) {
        return response()->json(['error' => $response->json('error.code')], $response->status());
    }

    return $response->json('items');
});

In Node, one function can do the call and the retry:

const API = "https://api.oushodh.dev/v1";

export async function oushodh(path, params = {}, tries = 3) {
  const res = await fetch(`${API}${path}?${new URLSearchParams(params)}`, {
    headers: { Authorization: `Bearer ${process.env.OUSHODH_API_KEY}` },
  });
  if (res.ok) return res.json();

  const { error } = await res.json();
  if (error.code === "rate_limited" && tries > 1) {
    const wait = Number(res.headers.get("Retry-After") ?? 1);
    await new Promise((done) => setTimeout(done, wait * 1000));
    return oushodh(path, params, tries - 1);
  }
  throw Object.assign(new Error(error.message), { code: error.code, status: res.status });
}

// const { items } = await oushodh("/medicines/search", { q: "napa", limit: 10 });

And in Python, getting one medicine by the uuid your records hold:

import os
import time
import requests

API = "https://api.oushodh.dev/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['OUSHODH_API_KEY']}"


def get_medicine(ref):
    for _ in range(3):
        r = session.get(f"{API}/medicines/{ref}", timeout=10)
        if r.status_code == 429 and r.json()["error"]["code"] == "rate_limited":
            time.sleep(int(r.headers.get("Retry-After", "1")))
            continue
        r.raise_for_status()
        return r.json()
    raise RuntimeError("Oushodh is still rate limiting this key")

How should errors be handled?

Every error answers a JSON body with a code to match on and a message for people. Match on the code, never on the message, which may change.

Code Status What your client does
bad_request 400 Fix the request. Sending it again gives the same answer
unauthorized 401 The key is missing, unknown or revoked. Do not retry; alert whoever owns the key
plan_expired 403 The plan has ended, or a production app’s key has no plan. Do not retry
not_found 404 No medicine has that ID. Check what you sent: a stored ID stays valid
rate_limited 429 Wait the seconds in Retry-After, then try again
quota_exceeded 429 The month’s requests are used up. Do not retry; Retry-After counts to next month
internal 500 A fault on our side. Try again a little later

Show the cashier or the clerk a plain message, such as “Medicine search is not available right now”, and let them carry on with the sale. The errors page has the full list.

Can I cache the answers to save requests?

No. The terms of use do not allow caching, storing or copying API responses, in a browser, an app, a server or a proxy. Your software calls the API each time it needs a medicine’s data.

What your database keeps is your own records and the medicine IDs. A sale line, for example, holds the IDs beside what you sold:

ALTER TABLE sale_line
  ADD COLUMN medicine_uuid CHAR(36),     -- the key that never changes
  ADD COLUMN medicine_id   VARCHAR(32);  -- the id you show people

There are other ways to use fewer requests. Wait for a pause in typing before you search, as the POS guide shows. Check GET /v1/meta before you look for changes, as keeping your stock list current shows. And show pictures straight from product_image in an <img> tag: pictures need no key and do not count as requests.

How do I stay inside the rate limits?

Each key has its own limit a minute, and every key on the account counts towards the month:

Plan Requests a minute, per key Requests a month
Developer 60 50,000
Team 120 250,000
Agency 300 1,000,000

Give each app its own key, as the plans expect: each key belongs to one app. Keep a separate key for your test or staging app. Test keys run at up to 10 requests a minute and share 5,000 a month, so a test run can never take more than 5,000 of the month your tills share. The Usage page in the member portal shows each day’s requests. The rate limits page has the details.

Will a change to the API break my integration?

Rarely. /v1 mostly gains fields and endpoints. A field that changes type or goes away does so only in a release the changelog marks as breaking, with the SDKs updated the same day: so far once, when manufacturer became an object on 2 Dec, 2026. So read the fields you need, and ignore any field you do not know. If you generate your client from a spec, the whole API is described in the OpenAPI file at https://oushodh.dev/docs/openapi.json, as the versions page says.

Share this post

FAQ

  • Can the POS or the store page call Oushodh directly?

    No. Anyone who has the key can use your plan, and a key in a web page or an app can be copied out. Your software calls your server, and your server calls Oushodh.

  • Is there a Laravel package?

    The PHP SDK, oushodh/oushodh-php on Packagist, installs with Composer like any PHP package. Without it, Laravel's HTTP client with the key as a bearer token is enough.

  • Should my client retry every error?

    No. Retry a 429 rate_limited after the seconds in Retry-After, and a 500 a little later. A 400, 401, 403 or 404 gives the same answer again, and quota_exceeded lasts until next month.

  • Can I cache answers to stay under my plan's limits?

    No. The terms do not allow caching or storing API responses. Store the medicine IDs, wait for a pause in typing before you search, and show pictures from product_image, which do not count as requests.

Sources

Choosing a data source

Choose an SDK for your stack