Amazon Pharmacy prices depend on how you pay. In one search for Atorvastatin, the 80mg, 30-day supply showed a $0.00 average insurance price, an $8.30 Prime member price, and a $138.60 retail price. That's three prices for the same medication, with a gap of more than $130.
If you're building a prescription price comparison tool, researching what medications cost, or tracking how Amazon Pharmacy prices change over time, you need those numbers in a structured format rather than copying them from a browser.
SerpApi's Amazon Pharmacy API returns Amazon Pharmacy search results as JSON and Markdown. You search a medication name and get back each result's form, strength, days of supply, and its insurance, Prime member, and retail prices. You can also choose a US delivery ZIP code and apply Amazon's filters, such as generic medications only.
In this tutorial, you'll try the API in the playground, then call it with cURL, Python, and JavaScript. You'll also paginate through results and narrow them by location and filter.

What data can you retrieve with the Amazon Pharmacy API?
Each medication is returned as an item in the organic_results array. Here's what's most useful:
- Medication details: The medication's
titleand its Amazonasin. - Dosage and supply: The
form(tablet, capsule, cream),strength(the dose), andsupply(such as30 days supply). - Prices:
insurance_estimate,prime_price, andretail_price, each with anextracted_numeric version (for example,extracted_retail_price) ready for sorting and math. - Coupon savings: When Amazon Pharmacy shows a coupon, the result can include
save_with_couponorsave_with_insurance_coupon, along with the crossed-outold_price. - Badges and delivery:
badges(such as "Prescription Required") anddelivery(such as "FREE delivery"). - Filters and pagination: The response can include the available
filters(each with a ready-madeserpapi_link) andserpapi_paginationlinks for the next and previous pages.
Not every result includes every price. For example, some results have no prime_price, so read optional fields defensively. See the Amazon Pharmacy API documentation for the full list of fields and parameters.
How to use the Amazon Pharmacy API
Try it in the playground
Open the SerpApi Playground with Atorvastatin as the search. The engine is set to amazon_pharmacy, and the medication goes in the k parameter.
Run the search and expand organic_results. Compare insurance_estimate, prime_price, and retail_price across the results. The same medication can appear more than once, in different strengths or supplies, each with its own prices. Then open filters to see which filters you can apply to this search.

Get your API key
To call the API from code, you need a SerpApi API key. Create a free SerpApi account, then copy your key from the API key page.
Store the key in an environment variable so it stays out of your code:
export SERPAPI_API_KEY="YOUR_SERPAPI_API_KEY"
Replace YOUR_SERPAPI_API_KEY with your own key on your machine, and make sure to store your API key in a safe location if your code will be shared or published. If the key is leaked or stolen, you can regenerate it from the dashboard.
Make a GET request
The endpoint is https://serpapi.com/search with engine=amazon_pharmacy. This request returns JSON, the default format:
https://serpapi.com/search?engine=amazon_pharmacy&k=Atorvastatin&api_key=YOUR_SERPAPI_API_KEY
Add output=md to get the same results as Markdown:
https://serpapi.com/search?engine=amazon_pharmacy&k=Atorvastatin&api_key=YOUR_SERPAPI_API_KEY&output=md
Markdown output is a compact, readable version of the results that works well as input for an LLM or AI agent. It leaves out some details, so use JSON when your code needs exact fields such as extracted_retail_price.
cURL implementation
Here's the same request with cURL:
curl --get https://serpapi.com/search \
--data-urlencode "engine=amazon_pharmacy" \
--data-urlencode "k=Atorvastatin" \
--data-urlencode "api_key=$SERPAPI_API_KEY"
Two parameters are required, plus your key:
engine: Set toamazon_pharmacy.k: The medication you want to search, such asAtorvastatinorcream.api_key: Your SerpApi API key, read here from the environment variable.
Python implementation
Install the official SerpApi Python library:
pip install serpapi
Create a file named main.py:
import os
import sys
import serpapi
client = serpapi.Client(api_key=os.environ["SERPAPI_API_KEY"])
results = client.search({
"engine": "amazon_pharmacy",
"k": "Atorvastatin",
})
if "error" in results:
sys.exit(f"Amazon Pharmacy API: {results['error']}")
for medication in results.get("organic_results", []):
print(f"{medication['title']} | {medication.get('strength')} | {medication.get('supply')}")
print(f" Insurance estimate: {medication.get('insurance_estimate', 'n/a')}")
print(f" Prime member price: {medication.get('prime_price', 'n/a')}")
print(f" Retail price: {medication.get('retail_price', 'n/a')}")
Run it:
python main.py
The script prints each medication's title, strength, and supply, followed by its three prices. These are the formatted price strings shown on Amazon Pharmacy, including the dollar sign. A result without a Prime member price prints n/a.
Amazon Pharmacy describes the insurance price as an average, so treat insurance_estimate as an estimate rather than a quote for a specific insurance plan.
If the search can't return results, the response includes an error message, and the script prints it and stops.

main.py for an Atorvastatin searcExport results to CSV
Each medication is a repeated record, so the results fit neatly into a spreadsheet. Add import csv at the top of main.py, then add this to the end. It reuses the results variable from the request above:
with open("amazon_pharmacy_atorvastatin.csv", "w", newline="", encoding="utf-8") as file:
writer = csv.writer(file)
writer.writerow([
"asin", "title", "form", "strength", "supply",
"insurance_estimate", "prime_price", "retail_price", "currency",
])
for medication in results.get("organic_results", []):
writer.writerow([
medication.get("asin"),
medication.get("title"),
medication.get("form"),
medication.get("strength"),
medication.get("supply"),
medication.get("extracted_insurance_estimate"),
medication.get("extracted_prime_price"),
medication.get("extracted_retail_price"),
medication.get("currency"),
])
The price columns use the extracted_ numeric values, so you can sort and compare them in a spreadsheet. Fields that are missing for a result, such as a Prime member price, are written as empty cells.

JavaScript implementation
Install the official SerpApi JavaScript library:
npm install serpapi
Create a file named main.js:
async function main() {
const { getJson } = await import("serpapi");
const apiKey = process.env.SERPAPI_API_KEY;
if (!apiKey) {
throw new Error("Set the SERPAPI_API_KEY environment variable first.");
}
const results = await getJson({
engine: "amazon_pharmacy",
k: "Atorvastatin",
api_key: apiKey,
});
if (results.error) {
throw new Error(`Amazon Pharmacy API: ${results.error}`);
}
for (const medication of results.organic_results ?? []) {
console.log(`${medication.title} | ${medication.strength} | ${medication.supply}`);
console.log(` Insurance estimate: ${medication.insurance_estimate ?? "n/a"}`);
console.log(` Prime member price: ${medication.prime_price ?? "n/a"}`);
console.log(` Retail price: ${medication.retail_price ?? "n/a"}`);
}
}
main().catch((error) => {
console.error(error.message);
process.exitCode = 1;
});
Run it:
node main.js
You'll see the same medications and prices as in the Python example.
Other languages and no-code options
- SerpApi has libraries for other languages too. See all integrations.
- With SerpApi's Make.com app, you can call engines that don't have their own Make module through the Universal Module ("Make an API Call"), using
/search.jsonwithengine=amazon_pharmacyandk. - SerpApi's verified n8n node covers a list of popular APIs. For engines outside that list, use n8n's HTTP Request node with the
engineparameter.
How to paginate the results
The Amazon Pharmacy API uses the page parameter:
pagedefaults to1and must be a whole number of 1 or more.- Each response includes
serpapi_paginationwith thecurrentpage number. When more results exist, it includes anextlink, and from page 2 onward, apreviouslink. - The
nextlink keeps all your other parameters (such ask,delivery_zip, ands) and changes onlypage. - When there's no
nextlink, you've reached the last page.
To request page 2 directly:
https://serpapi.com/search?engine=amazon_pharmacy&k=Atorvastatin&page=2&api_key=YOUR_SERPAPI_API_KEY
In Python, you can loop through a few pages. Replace everything after the client = ... line in main.py with this:
for page in range(1, 4):
results = client.search({
"engine": "amazon_pharmacy",
"k": "Atorvastatin",
"page": page,
})
if "error" in results:
sys.exit(f"Amazon Pharmacy API: {results['error']}")
for medication in results.get("organic_results", []):
print(f"Page {page}: {medication['title']} | {medication.get('retail_price', 'n/a')}")
if "next" not in results.get("serpapi_pagination", {}):
break
The loop stops after three pages, or earlier when there's no next page. Each page is a separate search and uses one search credit, so keep the page limit small while you're testing.
Customize or filter the results
Three parameters are especially useful for price research:
delivery_zip: A five-digit US ZIP code for the delivery location. Pass it as a string to keep leading zeros (for example,"02108"). Without it, results are for a default US location. Amazon Pharmacy doesn't show details, prices, or delivery information for Alaska, Hawaii, or Puerto Rico.rh: Amazon's filters, as comma-separatedkey:valuepairs. For example,p_n_feature_fourteen_browse-bin:19763604011limits results to generic medications. Filters available for a search vary, so the most reliable source is thefiltersobject in the response. Each filter has aserpapi_linkyou can follow. More common values are on the Amazon Pharmacy filters page.s: The sort order. Useprice-asc-rankfor low to high orprice-desc-rankfor high to low. Other values arerelevancerank(the default),review-rank,date-desc-rank, andexact-aware-popularity-rank. Sorted results are often a smaller set, and price ordering is approximate.
For example, this searches for generic Atorvastatin delivered to ZIP code 02108:
results = client.search({
"engine": "amazon_pharmacy",
"k": "Atorvastatin",
"delivery_zip": "02108",
"rh": "p_n_feature_fourteen_browse-bin:19763604011",
})
Use it in main.py in place of the original client.search(...) call. The rest of the script stays the same.
Conclusion
You can now search Amazon Pharmacy for a medication and get its form, strength, supply, and insurance, Prime member, and retail prices as JSON or Markdown. You can also export the results to CSV, page through them, and narrow them by ZIP code and filter. To explore other medications and parameters, open the Amazon Pharmacy API playground.
For your next project, these tutorials work with related Amazon data:
- Scrape Amazon Product Data (complete 2026 tutorial): search and product data from the main Amazon store.
- Automate Amazon Price Tracker using Python to See Real World Inflation: track Amazon prices over time on a schedule.
Frequently asked questions
Is the Amazon Pharmacy API an official Amazon API?
No. The Amazon Pharmacy API is a SerpApi API. It returns Amazon Pharmacy search results as structured JSON or Markdown through SerpApi's search endpoint, using engine=amazon_pharmacy.
How can I check Amazon Pharmacy prices with code?
Search for the medication with the k parameter and read insurance_estimate, prime_price, and retail_price from each item in organic_results. For calculations, use the numeric extracted_ versions, such as extracted_retail_price.
Can I get Amazon Pharmacy prices for a specific ZIP code?
Yes. Pass a five-digit US ZIP code in delivery_zip, as a string. Results for Alaska, Hawaii, and Puerto Rico don't include details, prices, or delivery information.
What happens if I misspell a medication name?
If Amazon Pharmacy corrects the spelling, results are for the corrected name, and search_information.spelling_fix shows it. For example, metfromin returns results for metformin. To exclude results from the corrected spelling, set dc=true.
Can I get the results in Markdown instead of JSON?
Yes. Add output=md to your request. JSON is the default and is the better choice when your code needs specific fields.