Search
/v1/searchSearch FDA drug labels using natural language queries with phase-based semantic understanding.
Overview
The Search API enables semantic search across verified FDA drug labels. Use natural language queries to find relevant drug information, warnings, side effects, interactions, and contraindications.
Unlike traditional vector embeddings that use probabilistic similarity, Lemma uses phase-coherent semantic relationships for deterministic, reproducible search results. The same query always returns the same results in the same order.
Every result includes a 128-bit binary fingerprint for cryptographic verification, ensuring complete traceability back to official FDA sources.
Request Body
questionstringrequiredNatural language search question. Can be a question, phrase, or keywords related to drug information. The system uses semantic understanding to find relevant FDA label segments.
top_kintegerNumber of results to return (1-100). Controls how many FDA label segments are returned in the response.
Response Structure
Success responses follow a standard structure with status: 1, msg, and data containing the actual response payload.
statusintegerResponse status. 1 indicates success.
msgstringStatus message, typically "operation successful".
dataobjectThe actual response data containing search results.
querystringEcho of the original search question (returned as "query" in response).
resultsarrayArray of search results matching the query, ordered by relevance.
textstringFDA label text segment - exact text from the official FDA source
fingerprintstring128-bit binary fingerprint for cryptographic verification. Use this with the Verify API to prove this text came from FDA sources.
drugobjectDrug information
namestringGeneric drug name (lowercase)
brand_namesarrayBrand/trade names for this drug
manufacturerstringDrug manufacturer/company name
ndcarrayNational Drug Code identifiers - unique product identifiers assigned by FDA
routearrayAdministration routes (e.g., "ORAL", "TOPICAL", "INTRAVENOUS")
sectionstringFDA label section where this text was found (e.g., "Warnings", "Adverse Reactions", "Drug Interactions", "Contraindications", "Clinical Pharmacology")
sourceobjectSource information
urlstringOfficial DailyMed URL for independent verification
metadataobjectSearch metadata including result count and timing information.
countintegerNumber of results returned
search_time_msfloatSearch execution time in milliseconds
Use Cases
Search Tips
Use Natural Language
The search understands questions and phrases. You can ask "What are the side effects of aspirin?" or use keywords like "aspirin side effects" - both work well.
Be Specific
More specific queries return more relevant results. "warfarin bleeding risk" is better than just "warfarin".
Adjust top_k for Breadth
Use a higher top_k value (e.g., 50-100) when you want comprehensive results across multiple drugs or need to see all relevant warnings.
Error Responses
All error responses follow a standard structure with status: 0, errorCode, and msg fields:
Example: Verifying Search Results
Every search result includes a fingerprint that can be verified using the Verify API:
# 1. Search for information
search_response = requests.post(
"https://api.lemma.la/v1/search",
headers={"x-api-key": api_key},
json={"question": "aspirin warnings"}
)
response_data = search_response.json()
results = response_data['data']['results']
first_result = results[0]
print(f"Text: {first_result['text']}")
print(f"Fingerprint: {first_result['fingerprint']}")
# 2. Verify the fingerprint later
verify_response = requests.get(
f"https://api.lemma.la/v1/verify/{first_result['fingerprint']}"
)
verification_data = verify_response.json()
verification = verification_data.get('data', verification_data)
if verification.get('verified'):
print("✓ Citation verified!")
print(f"Source: {verification['source']['url']}")
else:
print(f"✗ Verification failed: {verification['message']}")