API

You can use our RESTful API to download spending data and other useful information. While we are in beta, no registration is required, but please be aware this may change.

You can retrieve data as CSV (compatible with Excel) by appending &format=csv to the URL, or as JSON by appending &format=json.

You can find information about our data sources here

You are welcome to use data or graphs from this site in your academic output with attribution. Our methods paper will be published shortly, until then please cite "OpenPrescribing.net, EBM DataLab, University of Oxford, 2017" as the source for academic attribution.


Spending API

Methods to calculate prescribing spending.

Retrieve total spending and items by CCG or practice on a particular chemical, presentation or BNF section. (Spending is calculated using the actual_cost field in the HSCIC data, items using the total_items field.)

Spending by code

Queries the last five years of data and returns total spending and items by month.

Total prescribing spending by month: /api/1.0/spending

Total by BNF code by month: /api/1.0/spending/?code=0212, /api/1.0/spending/?code=0212000AA, /api/1.0/spending/?code=0212000AAAAABAB

Spending by CCG

Queries the last five years of data and returns spending and items by CCG by month.

Spending by CCG on a chemical: /api/1.0/spending_by_ccg/?code=0212000AA

You can request individual CCGs by code: /api/1.0/spending_by_ccg/?code=0212000AA&org=03V

Spending by practice

Queries the last five years of data and returns total spending and items by practice by month.

You must specify either an organisation, or a date.

Spending by all practices on a BNF section: /api/1.0/spending_by_practice/?code=0212&date=2015-04-01

Spending by all practices on a chemical: /api/1.0/spending_by_practice/?code=0212000AA&date=2015-04-01

Spending by all practices on a presentation: /api/1.0/spending_by_practice/?code=0212000AAAAAAAA&date=2015-04-01

You can request individual practices by code: /api/1.0/spending_by_practice/?code=0212000AA&org=H81068

You can also request a CCG code to see spending by all practices in that CCG: /api/1.0/spending_by_practice/?code=0212000AA&org=99P


Information API

Methods to retrieve information about CCGs, practices, and BNF codes.

Drug details

Search for the official name and code of BNF sections, chemicals and presentations.

All BNF sections, chemicals and presentations matching a name (case-insensitive): /api/1.0/bnf_code/?q=lipid

All chemicals and presentations matching a code: /api/1.0/bnf_code/?q=0212000AA

All BNF sections matching a code: /api/1.0/bnf_code/?q=2.4

All BNF sections, chemicals and presentations exactly matching a name or code: /api/1.0/bnf_code/?q=0212000AA&exact=true

Organisation codes

Search for details about a CCG or practice by code or name.

All organisations matching a code or name: /api/1.0/org_code/?q=Beaumont

All CCGs matching a code or name: /api/1.0/org_code/?q=Gloucester&org_type=CCG

All practices matching a code or name: /api/1.0/org_code?q=Gloucester&org_type=practice

All organisations exactly matching a code or name: /api/1.0/org_code/?exact=true&q=99H

List size and ASTRO-PUs by CCG or practice

Search for details about a CCG or practice by code or name. Returns values for all months available.

Total list size for all CCGs: /api/1.0/org_details/?org_type=ccg&keys=total_list_size

Total list size for all practices by practice code, or CCG code: /api/1.0/org_details/?org_type=practice&org=99H&keys=total_list_size

ASTRO-PU cost and items for practices by practice code, or CCG code: /api/1.0/org_details/?org_type=practice&org=99H&keys=astro_pu_items,astro_pu_cost

CCG boundaries

Search for the boundaries of a CCG, or location of a practice, by code. Returns GeoJSON.

Boundaries of all CCGs: /api/1.0/org_location/?org_type=ccg

Boundaries of an individual CCG: /api/1.0/org_location/?org_type=ccg&q=99H

Location (approximate) of a practice, or practices in a CCG, by code: /api/1.0/org_location/?q=99H,P87003