Docs / Build

Medicine autocomplete with Node.js, React and Python

Build the first working search before connecting it to your own application.

Run the starter

Download the starter files, set MEDIFONTIS_API_KEY privately in your environment, then run node server.mjs with Node.js 24 or later. Open http://127.0.0.1:3000. No dependencies are needed.

Get your free API key

Use it in React

Mount MedicineSearch.jsx in your existing React app and route /api/suggestions to the Node server on the same origin. The component waits 300 milliseconds after typing, cancels stale requests, and waits for text composition to finish.

React
import MedicineSearch from './MedicineSearch.jsx'

export default function App() {
  return <MedicineSearch />
}

Call suggestions from Python

Python 3
import json, os
from urllib.request import Request, urlopen
from urllib.parse import urlencode

params = urlencode({'country': 'fr', 'q': 'dolip', 'limit': 10})
request = Request('https://api.medifontis.com/v1/drugs/suggestions?' + params,
    headers={'Authorization': 'Bearer ' + os.environ['MEDIFONTIS_API_KEY']})
with urlopen(request, timeout=10) as response:
    print(json.load(response)['suggestions'])

Connect it to your application

Keep keys on your server. The starter binds to loopback and limits requests; before public deployment, add your application authentication, shared rate limiting and HTTPS. Suggestions are names, not product identities: use the search and record endpoints to select a specific source record.