API V2 Documentation
API Errors
For authentication and request signing related error output, see here. For errors from the /v2/ endpoints, error responses will be of the following format:
{
"error": {
"type": "invalid_request_error",
"detail": "Please provide one of the following fields: name, ndc"
}
}
error.type will be a string with the error type. Current error types are:
error.code will be a string with the error code. Current error code values are:
-
no_prices_found - we could not find any prices for the given drug
-
unknown_drug - we could not find a drug with the provided name; this error will also return an array of auto-suggested drug names in the error.extras.candidates attribute
-
invalid_location - the location provided was invalid
-
invalid_param - the query contains a parameter with an invalid value
error.detail will be a string containing the error message if any
Request Authentication
Request authentication for the API can be seen here.
Tracking Workflow-specific API Usage
API partners can utilize the c parameter (documented below) in requests to v2 APIs to identify specific workflows.
Using the c parameter, API usage can be organized by workflow in partner reports.
API V2 Resources
The GoodRx API expects HTTP URL request parameters and returns JSON responses. All requests must include your API Key and the parameters must be signed using the provided shared private key.
Before making any requests, be sure to request an API key.
The V2 Price Compare API
The Compare Price API allows clients to retrieve the lowest available prices for a prescription medication. The API will use our extensive data set to select the most common forms and quantities if not provided, as well as including generic or brand equivalents.
Available Requests
| GET /v2/price/compare |
Get prices for the given drug, store, and optional location.
|
| URL |
https://api.goodrx.com/v2/price/compare |
| Format |
JSON |
| URL Parameters |
api_key
-
c
-
- Optional, Query String
- Expected Data Type: String
- Example: "campaign"
- Not required, but necessary for attributing coupon and url visits to a particular source/campaign.
- Character limit: 100
name
-
- Optional, Query String
- Expected Data Type: String
- Example: "lipitor"
- Name of the drug to search for; either name or ndc must be provided.
- Note: Omit if
ndc is passed.
ndc
-
- Optional, Query String
- Expected Data Type: String
- Examples: "55154242200"
- NDC11 of the drug to search for; either name or ndc must be provided.
- Note: Omit if
name is passed.
form
-
- Optional, Query String
- Expected Data Type: String
- Examples: "tablet", "capsule"
- Form of the drug to search for.
- Note: Omit if
ndc is passed.
dosage
-
- Optional, Query String
- Expected Data Type: String
- Examples: "20mg", "40mg"
- Dosage of the drug to search for.
- Note: Omit if
ndc is passed.
quantity
-
- Optional, Query String
- Expected Data Type: Float
- Examples: "30" for 30 tablets, "8.5" for 1x 8.5g inhalers, "17" for 2x 8.5g inhalers, etc.
- Metric quantity of the drug to search for; numeric value.
- NOTE: This parameter is deprecated. Please use metric_quantity, which behaves the same as quantity.
metric_quantity
-
- Optional, Query String
- Expected Data Type: Float
- Examples: "30" for 30 tablets, "8.5" for 1x 8.5g inhalers, "17" for 2x 8.5g inhalers, etc.
- Metric quantity of the drug to search for; numeric value.
user_quantity
-
- Optional, Query String
- Expected Data Type: Integer
- Examples: "30" for 30 tablets, "1" for 1x 8.5g inhalers, "2" for 2x 8.5g inhalers, etc.
- User quantity (ex: quantity displayed on GoodRx.com) of the drug searched for; numeric value.
manufacturer_type
-
- Optional, Query String
- Expected Data Type: String
- Examples: "brand"
- Manufacturer type of the drug to use; one of
brand, generic, match. match will use the drug name that is passed instead of a recommended manufacturer type. brand and generic act like overrides and will search for an equivalent drug with the overridden type.
location
-
- Optional, Query String
- Expected Data Type: String
- Examples: "90401", "Santa Monica CA"
- Location to use; if provided, will compare prices between pharmacies near the provided location. Values can either be zip codes or a city+state.
- Note: Omit if
ncpdp is passed.
exclude_local
-
- Optional, Query String
- Expected Data Type: Boolean
- Examples: 0, 1
- If provided, will exclude non-NABP approved pharmacies from the results. Values can be a boolean, either 0 or 1. Default is 0.
ncpdp
-
- Optional, Query String
- Expected Data Type: List[String], values are left-padded to 7 characters
- Examples: "1111111"
- NCPDP of the pharmacy to include in the price comparison. Multiple NCPDPs can be passed by including this parameter multiple times, e.g.
ncpdp=1111111&ncpdp=2222222
- Note: Omit if
location is passed.
expand_chains
-
- Optional, Query String
- Expected Data Type: Boolean
- Examples: 0, 1
- If true, will add an additional chain_ncpdps parameter in the
price_detail_object containing a list of NCPDPs of the underlying stores of a chain.
- Only has affect when doing a search using the location parameter. This parameter is ignored when searching with the ncpdp parameter.
|
| Response |
JSON
The following keys will be available, encompassed in the data element:
days_supply
-
Days supply of the drug searched for
Example: 30
dosage
-
String containing the dosage searched for
Example: "20mg"
display
-
Display name of the drug
Example: "Lipitor (atorvastatin)"
quantity
-
Metric quantity of the drug searched for
Example: 30 for 30 tablets, 8.5 for 1x 8.5g inhalers, 17 for 2x 8.5g inhalers, etc.
NOTE: This parameter is deprecated. Please use metric_quantity, which behaves the same as quantity.
metric_quantity
-
Metric quantity of the drug searched for
Example: 30 for 30 tablets, 8.5 for 1x 8.5g inhalers, 17 for 2x 8.5g inhalers, etc.
user_quantity
-
User quantity (ex: quantity displayed on GoodRx.com) of the drug searched for
Example: 30 for 30 tablets, 1 for 1x 8.5g inhaler, 2 for 2x 8.5g inhalers, etc.
manufacturer_type
-
Manufacturer type of the drug returned
Example: "generic"
form
-
Form of the drug searched for
Example: "tablet"
url
-
Website of the drug price page on www.goodrx.com
Example: "https://www.goodrx.com/atorvastatin?grx_ref=api"
short_url
-
Shortened website url of the drug price page on www.goodrx.com
Example: "http://bit.ly/2JIDy9J"
(Added 1/3/2017)
mobile_url
-
Mobile website url of teh drug price page on m.goodrx.com
Example: "https://m.goodrx.com/?grx_ref=api#/drug/atorvastatin/tablet"
short_mobile_url
-
Shortened mobile website url of the drug price page on m.goodrx.com
Example: "http://bit.ly/2JCZByU"
(Added 1/3/2017)
equivalent_drugs
-
Object containing an array of generic/brand equivalents
Example:
{
"generic": [
"atorvastatin"
],
"brand": [
"lipitor"
]
}
prices
-
List of price objects (see price object detail below)
Price Object Detail
coupon_url
-
URL to link directly to the coupon page on www.goodrx.com
Example: "https://www.goodrx.com/coupon?pharmacy_id=2&drug_id=33397&quantity=30"
coupon_key
-
String containing the key to pass to the Coupon Detail endpoint to retrieve coupon detail (if price type is coupon). Note: This may be a large value in excess of 1024 characters.
Example: "longstringhere"
type
-
Type of the price (one of "cash", "coupon", or "membership"
Example: "coupon"
ncpdp
-
NCPDP of the pharmacy, null if store is a chain
Example: 1072937
chain_ncpdps
-
List of NCPDP strings of the underlying pharmacies comprising the chain. If the result is for a single store (i.e. independent pharmacies), then chain_ncpdps will contain a single result which will be the NCPDP of that store.
Example: ["1072937",]
pharmacy
-
Name of the pharmacy
Example: "CVS Pharmacy"
pharmacy_type
-
Type of pharmacy. "RETAIL" or "MAIL_ORDER"
Example: "RETAIL"
program_cost
-
If this price requires a membership, then this will give the price of the membership fee, in USD. If membership is free, this will be 0.0. If there is no membership, then this will be null
Example: 36
price
-
Coupon price (if price type is coupon)
Example: 11.27
savings
-
String showing percentage savings between the cash price (if data available) and coupon price at the pharmacy. null if data not available
Example: "71%"
retail_price
-
Retail price (if available)
Example: 123.0
savings
-
Percentage of savings a GoodRx coupon has over a retail price (if applicable)
Example: 90.84%
has_goodrx_advantage
-
NOTE: This feature is available upon request and will not be available in the response without opt-in. Please reach out to partner-integrations@goodrx.com for more information.
Boolean value true or false.This field indicates that GoodRx has a good price worth notifying external users about.
Sample template when has_goodrx_advantage is true:
[Entity Name] is sending you a one-time message. Click this link to view your requested pricing information [URL].
|
| Example Response Object |
{
"data": {
"url": "http://www.goodrx.com/atorvastatin?grx_ref=api",
"short_url": "http://bit.ly/2JIDy9J",
"mobile_url": "http://m.goodrx.com/?grx_ref=api#/drug/atorvastatin/tablet",
"short_mobile_url": "http://bit.ly/2JCZByU",
"equivalent_drugs": {
"generic": [
"atorvastatin"
],
"brand": [
"lipitor"
]
},
"form": "tablet",
"manufacturer_type": "generic",
"prices": [
{
"coupon_url": "https://www.goodrx.com/coupon?pharmacy_id=2&drug_id=33397&quantity=30",
"coupon_key": "Dt-r26DzNfrUnmA0fXE7FnPB62O267_fS930qsiWM_HwrSwS2APJNatMePgR05vEfkF6Vq9rB0LGHv36EXVaCgiXZ1_t23ByH3_SvLl6a2m1V4s-a5uINiKkMRM=",
"ncpdp": "1072937",
"type": "coupon",
"price": 11.27,
"pharmacy_type": "RETAIL",
"pharmacy": "Wal-Mart Pharmacy",
"retail_price": 123.0,
"savings": "90.84%",
"has_goodrx_advantage": true
},
{
"coupon_url": "https://www.goodrx.com/coupon?pharmacy_id=2&drug_id=33397&quantity=30",
"coupon_key": "Dt-r26DzNfrUnmA0fXE7FnPB62O267_fS930qsiWM_HwrSwS2APJNatMePgR05vEfkF6Vq9rB0LGHv36EXVaCgiXZ1_t23ByH3_SvLl6a2m1V4s-a5uINiKkMRM=",
"ncpdp": "3334860",
"type": "coupon",
"price": 11.27,
"pharmacy_type": "RETAIL",
"pharmacy": "Wal-Mart Pharmacy 10-1997",
"retail_price": 123.0,
"savings": "90.84%",
"has_goodrx_advantage": true
}
],
"quantity": 30,
"metric_quantity": 30,
"user_quantity": 30,
"display": "Lipitor (atorvastatin)",
"dosage": "20mg",
"days_supply": "30"
}
}
|
The V2 Coupon API
The Coupon API allows clients to query the GoodRx drug database with strings in order to retrieve the coupon adjudication info for a particular drug, You will be able to request contact info for customers and pharmacists. Additionally, you can obtain the URL to the GoodRx coupon and specify the format of HTML or PDF.
Available Requests
| POST /v2/coupon |
Retrieve coupon and adjudication information for a coupon that was returned in an earlier V2 price API call.
|
| URL |
https://api.goodrx.com/v2/coupon |
| Format |
JSON |
| URL Parameters |
api_key
-
c
-
- Optional, POST body
- Expected Data Type: String
- Example: "campaign"
- Not required, but necessary for attributing coupon and url visits to a particular source/campaign.
- Character limit: 100
- Note: If a
c parameter is provided in the original /v2/price/ compare endpoint call, all the coupon_keys already have the c parameter encoded in them. If a different c parameter is provided in the /v2/coupon call, it will override the original c parameter.
coupon_key
-
- Required, POST body
- Expected Data Type: String
- Example: "longstringhere"
- Value of the
coupon_key parameter in the price object returned from the /v2/price/compare endpoint.
coupon_format
-
- Optional, POST body
- Expected Data Type: String
- Example: "html"
- The format of the pre-rendered coupon to return. Valid values are
both, none, pdf, or html. If this parameter is not given, the API will default to returning HTML.
- If a value of
none is selected, the API will return the adjudication information in the response but will not return an html or pdf rendering.
- Note: Multiple calls to this API with the same coupon key generate slightly different coupon outputs. We do not recommend calling this API multiple times with the same coupon_key (eg. once for HTML, another for PDF) unless the HTML/PDF of the previous call are discarded.
shorten_url
-
- Optional, POST body
- Expected Data Type: Bool
- Example: 0, 1
- Valid values are
0 and 1
- Whether to return the shortened version of the coupon page URL in the response.
- Note: Setting this to
1 can cause a slight delay in the response times. Due to legacy reasons, the default value of the parameter is 1.
email
-
- NOTE: This parameter is deprecated. Its inclusion will return a 400 error. Please reach out to partner-integrations@goodrx.com for further support.
- Optional, POST body
- Expected Data Type: String
- Example: "example_email@gmail.com"
- Value must be a single, valid email address
- A coupon will be sent to the provided email address
- PLEASE NOTE: only one of either
email or phone_number can be sent within a single request. An error will occur if both are provided
phone_number
-
- NOTE: This parameter is deprecated. Its inclusion will return a 400 error. Please reach out to partner-integrations@goodrx.com for further support.
- Optional, POST body
- Expected Data Type: String
- Examples: "1234567891", "123-456-7891", "1-1234567891", "1-123-456-7891", "+1-123-456-7891"
- Value must be a single, valid United States phone number
- A coupon will be sent via sms to the provided phone number
- PLEASE NOTE: only one of either
email or phone_number can be sent within a single request. An error will occur if both are provided
|
| Response |
JSON
The following keys will be available, encompassed in the data element:
price
-
Coupon price
Example: 11.27
group_number
-
Group number of the coupon
Example: "AME08"
member_id
-
Member ID of the coupon
Example: "R490954478"
rxbin
-
RxBIN of the coupon
Example: "003585"
rxpcn
-
RxPCN of the coupon
Example: "ASPROD1"
phone
-
String containing phone number and optionally hours of operation to print on the coupon. This is the phone number consumers would call regarding the coupon.
Example: "1-866-788-8452 (M-F 9AM-8PM EST, SAT 10AM-3PM EST)"
pharmacy_name
-
String containing the name of the pharmacy that is associated with the coupon’s adjudication information
Example: "Walmart"
pharm_phone
-
String containing phone number and optionally hours of operation to print on the coupon. This is the phone number pharmacists would call regarding the coupon
Example: "1-866-788-8452"
url
-
String containing the URL to the coupon on the GoodRx.com website.
Example: "https://www.goodrx.com/..."
coupon_html
-
Base64 encoded string of HTML.
This is only provided if the coupon_format from the request was html, both, or omitted.
See below an example implementation on how to use the value of this parameter.
coupon_pdf
-
Base64 encoded string of the PDF binary.
This is only provided if the coupon_format from the request was pdf or both.
Base64 decode the string before writing/opening the PDF.
See below an example implementation of how to use the value of this parameter.
|
| Coupon HTML Example Implementation (JavaScript) |
var coupon_html = data.coupon_html;
var coupon_iframe = document.createElement(‘iframe’);
document.body.appendChild(coupon_iframe);
// Use an onload event listener on the iframe element to make sure
// content is loaded prior to opening the print window.
coupon_iframe.onload = function() { this.contentWindow.print(); };
// Write coupon_html into iframe document
// Uses atob to decode base64 content
coupon_iframe.contentWindow.document.open();
coupon_iframe.contentWindow.document.write(atob(coupon_html));
coupon_iframe.contentWindow.document.close();
// To trigger print manually
coupon_iframe.contentWindow.print();
Note: The CSS is responsive to some level, so there is flexibility in sizing of the iframe. There is a print style sheet that will handle formatting the print styling regardless of iframe window size.
|
| Coupon PDF Web Display Example Implementation (JavaScript) |
var coupon_pdf = data.coupon_pdf;
var coupon_iframe = document.createElement('iframe');
coupon_iframe.src = 'data:application/pdf;base64,' + coupon_pdf;
document.body.appendChild(coupon_iframe);
|
| Example Response Object |
{
"data": {
"price": 11.27,
"group_number": "AME08",
"rxpcn": "ASPROD1",
"phone": "1-866-788-8452 (M-F 9AM-8PM EST, SAT 10AM-3PM EST)",
"member_id": "R490954478",
"rxbin": "003585",
"pharmacy_name": "Walmart"
"pharm_phone": "1-866-788-8452",
"url": "https://www.goodrx.com/...",
"coupon_html": < base64 encoded string of html >,
"coupon_pdf": < base64 encoded string of pdf binary >
}
}
|
Rate Limits
The GoodRx API by default will not impose rate limiting on accounts. However, API usage is tracked and any abuse of the system will result in an account suspension and an inquiry into the high activity.
If your company is planning on high activity, please contact info@goodrx.com with a request for an unrestricted rate limit.