Export records as CSV
GET/v1/drugs/export
Downloads records of one country as a CSV file: either every record that carries one exact name, or one whole kind of one source. Exports are part of the Pro and Business plans, and whole sources of the Business plan. Only sources published under an open licence are exported; a record from any other source is left out. A file holds up to 5,000 records, and the X-Medifontis-Next response header carries the cursor of the next one.
Parameters
-
countrystring Required - Two-letter ISO 3166-1 country code, lowercase. Every search is scoped to one country.
-
namestring - Export the records that carry this exact name, 3 to 120 characters. Accents and case are ignored. Use either name, or sourceId and kind.
-
kindsstring - With name: keep only these record kinds, as comma-separated sourceId:kind pairs of the requested country, at most 12.
-
sourceIdstring - Export one whole source of the requested country, such as it.aifa.packages. Requires kind.
-
kindstring - With sourceId: the record kind to export, such as packages.
-
afterstring - The cursor from the X-Medifontis-Next header of the previous file. Omit it for the first file.
Returns
-
bodytext/csv - One header row and one row per record, in UTF-8: country, source_id, record_id, kind, name, other_names, identifiers, holder, administrative_status, prescription_category, retrieved_at, source_url, licence and attribution. Identifiers are written scheme=value, separated by vertical bars.
-
X-Medifontis-Rowsheader - The number of records in this file.
-
X-Medifontis-Nextheader - The cursor of the next file. Absent when this file is the last one.
Errors
400 401
403 404
429 503 ·
Errors and rate limits
curl -G https://api.medifontis.com/v1/drugs/export \
-H "Authorization: Bearer $MEDIFONTIS_API_KEY" \
--data-urlencode "country=gb" \
--data-urlencode "name=Almodan 125mg/5ml syrup (Teva UK Ltd)" \
-o medicines.csvimport { writeFile } from 'node:fs/promises'
const params = new URLSearchParams({ country: 'gb', name: 'Almodan 125mg/5ml syrup (Teva UK Ltd)' })
let csv = ''
for (let after; ; ) {
if (after) params.set('after', after)
const response = await fetch(`https://api.medifontis.com/v1/drugs/export?${params}`, {
headers: { Authorization: `Bearer ${process.env.MEDIFONTIS_API_KEY}` },
})
if (!response.ok) throw new Error(`Medifontis ${response.status}`)
const page = await response.text()
// Later files repeat the header row.
csv += csv ? page.slice(page.indexOf('\n') + 1) : page
after = response.headers.get('x-medifontis-next')
if (!after) break
}
await writeFile('medicines.csv', csv)import os
import requests
params = {"country": "gb", "name": "Almodan 125mg/5ml syrup (Teva UK Ltd)"}
pages = []
while True:
response = requests.get(
"https://api.medifontis.com/v1/drugs/export",
params=params,
headers={"Authorization": f"Bearer {os.environ['MEDIFONTIS_API_KEY']}"},
timeout=30,
)
response.raise_for_status()
text = response.text
# Later files repeat the header row.
pages.append(text if not pages else text.split("\n", 1)[1])
cursor = response.headers.get("X-Medifontis-Next")
if not cursor:
break
params["after"] = cursor
with open("medicines.csv", "w", encoding="utf-8", newline="") as file:
file.write("".join(pages))
country,source_id,record_id,kind,name,other_names,identifiers,holder,administrative_status,prescription_category,retrieved_at,source_url,licence,attribution
gb,gb.nhsbsa.bnf-snomed,gb:nhsbsa:dmd:196111000001109,amp,Almodan 125mg/5ml syrup (Teva UK Ltd),Almodan 125mg/5ml syrup | Amoxicillin,dmd=196111000001109 | bnf=0501013B0BDABAJ | vtm=774586009,,,unknown,2026-11-09T02:32:19.182Z,https://www.nhsbsa.nhs.uk/prescription-data/understanding-our-data/bnf-snomed-mapping,OGL-UK-3.0,"BNF SNOMED Mapping data, NHSBSA Copyright 2026. This information is licenced under the terms of the Open Government Licence."