OpenAlex API in Python#
by Michael T. Moen
Please see the following resources for more information on API usage:
Documentation
Terms
Data Reuse
OpenAlex License: “OpenAlex data is licensed as CC0 so it is free to use and distribute.
NOTE: The OpenAlex API limits requests to a maximum of 100,000 per user per day and 10 requests per second.
These recipe examples were tested on May 6, 2025.
Setup#
Import Libraries#
The following external libraries need to be installed into your enviornment to run the code examples in this tutorial:
We import the libraries used in this tutorial below:
import requests
import matplotlib.pyplot as plt
from time import sleep
from collections import Counter
from dotenv import load_dotenv
import os
Import User Information#
An API key is not required to access the OpenAlex API. However, it is recommended that you add your email to all API requests. Doing so will provide much faster and much more consistent response times.
We keep our email in a .env
file and use the dotenv
library to access it. If you would like to use this method, create a .env
file and add the following line to it:
EMAIL="example@domain.com"
load_dotenv()
try:
EMAIL = os.environ["EMAIL"]
except KeyError:
print("Email not found. Please set 'EMAIL' in your .env file.")
OpenAlex Snapshot#
OpenAlex also offers a database download that is updated monthly. This option may be more useful than the API when working with larger datasets and when up-to-date data is unimportant.
More information can be found here.
1. Simple Queries#
The OpenAlex API has a works
endpoint that can be used to search for works using a query. In this example, we’ll consider several different queries. More information on search queries can be found here.
Simple Title Query#
This first example will search for the term “geodetics”:
BASE_URL = 'https://api.openalex.org/'
endpoint = 'works'
filters = 'title.search:"geodetics"'
params = {
'filter': filters,
'mailto': EMAIL
}
geodetics_data = requests.get(BASE_URL + endpoint, params=params).json()
# Display resulting metadata
geodetics_data['meta']
{'count': 13150,
'db_response_time_ms': 81,
'page': 1,
'per_page': 25,
'groups_count': None}
The ‘count’ in the output above tells us how many works have been published by UA authors.
It’s also important to note that the data returned by this API request is just the first page of size 25. That means that in order to obtain the data for all works in data_retrieved['results']
, we must page through this data.
Each work obtained in the query will have the following structure:
geodetics_data['results'][0]
{'id': 'https://openalex.org/W2095673763',
'doi': 'https://doi.org/10.1007/bf00989270',
'title': 'Geodetic Reference System 1980',
'display_name': 'Geodetic Reference System 1980',
'relevance_score': 367.76678,
'publication_year': 1992,
'publication_date': '1992-01-01',
'ids': {'openalex': 'https://openalex.org/W2095673763',
'doi': 'https://doi.org/10.1007/bf00989270',
'mag': '2095673763'},
'language': 'en',
'primary_location': {'is_oa': False,
'landing_page_url': 'https://doi.org/10.1007/bf00989270',
'pdf_url': None,
'source': {'id': 'https://openalex.org/S4210224534',
'display_name': 'Bulletin Géodésique',
'issn_l': '0007-4632',
'issn': ['0007-4632'],
'is_oa': False,
'is_in_doaj': False,
'is_indexed_in_scopus': False,
'is_core': False,
'host_organization': 'https://openalex.org/P4310319965',
'host_organization_name': 'Springer Nature',
'host_organization_lineage': ['https://openalex.org/P4310319965'],
'host_organization_lineage_names': ['Springer Nature'],
'type': 'journal'},
'license': None,
'license_id': None,
'version': None,
'is_accepted': False,
'is_published': False},
'type': 'article',
'type_crossref': 'journal-article',
'indexed_in': ['crossref'],
'open_access': {'is_oa': False,
'oa_status': 'closed',
'oa_url': None,
'any_repository_has_fulltext': False},
'authorships': [{'author_position': 'first',
'author': {'id': 'https://openalex.org/A5058176159',
'display_name': 'Helmut Moritz',
'orcid': None},
'institutions': [],
'countries': [],
'is_corresponding': True,
'raw_author_name': 'H. Moritz',
'raw_affiliation_strings': [],
'affiliations': []}],
'institution_assertions': [],
'countries_distinct_count': 0,
'institutions_distinct_count': 0,
'corresponding_author_ids': ['https://openalex.org/A5058176159'],
'corresponding_institution_ids': [],
'apc_list': None,
'apc_paid': None,
'fwci': 15.659,
'has_fulltext': False,
'cited_by_count': 755,
'citation_normalized_percentile': {'value': 0.990211,
'is_in_top_1_percent': True,
'is_in_top_10_percent': True},
'cited_by_percentile_year': {'min': 99, 'max': 100},
'biblio': {'volume': '66',
'issue': '2',
'first_page': '187',
'last_page': '192'},
'is_retracted': False,
'is_paratext': False,
'primary_topic': {'id': 'https://openalex.org/T13734',
'display_name': 'Advanced Computational Techniques and Applications',
'score': 0.8949,
'subfield': {'id': 'https://openalex.org/subfields/1702',
'display_name': 'Artificial Intelligence'},
'field': {'id': 'https://openalex.org/fields/17',
'display_name': 'Computer Science'},
'domain': {'id': 'https://openalex.org/domains/3',
'display_name': 'Physical Sciences'}},
'topics': [{'id': 'https://openalex.org/T13734',
'display_name': 'Advanced Computational Techniques and Applications',
'score': 0.8949,
'subfield': {'id': 'https://openalex.org/subfields/1702',
'display_name': 'Artificial Intelligence'},
'field': {'id': 'https://openalex.org/fields/17',
'display_name': 'Computer Science'},
'domain': {'id': 'https://openalex.org/domains/3',
'display_name': 'Physical Sciences'}},
{'id': 'https://openalex.org/T14163',
'display_name': 'Astronomical Observations and Instrumentation',
'score': 0.8938,
'subfield': {'id': 'https://openalex.org/subfields/2206',
'display_name': 'Computational Mechanics'},
'field': {'id': 'https://openalex.org/fields/22',
'display_name': 'Engineering'},
'domain': {'id': 'https://openalex.org/domains/3',
'display_name': 'Physical Sciences'}},
{'id': 'https://openalex.org/T13854',
'display_name': 'Historical Geography and Cartography',
'score': 0.8863,
'subfield': {'id': 'https://openalex.org/subfields/3305',
'display_name': 'Geography, Planning and Development'},
'field': {'id': 'https://openalex.org/fields/33',
'display_name': 'Social Sciences'},
'domain': {'id': 'https://openalex.org/domains/2',
'display_name': 'Social Sciences'}}],
'keywords': [],
'concepts': [{'id': 'https://openalex.org/C58754882',
'wikidata': 'https://www.wikidata.org/wiki/Q1502887',
'display_name': 'Geodetic datum',
'level': 2,
'score': 0.8561057},
{'id': 'https://openalex.org/C13280743',
'wikidata': 'https://www.wikidata.org/wiki/Q131089',
'display_name': 'Geodesy',
'level': 1,
'score': 0.51892185},
{'id': 'https://openalex.org/C41008148',
'wikidata': 'https://www.wikidata.org/wiki/Q21198',
'display_name': 'Computer science',
'level': 0,
'score': 0.41343182},
{'id': 'https://openalex.org/C127313418',
'wikidata': 'https://www.wikidata.org/wiki/Q1069',
'display_name': 'Geology',
'level': 0,
'score': 0.31957805}],
'mesh': [],
'locations_count': 1,
'locations': [{'is_oa': False,
'landing_page_url': 'https://doi.org/10.1007/bf00989270',
'pdf_url': None,
'source': {'id': 'https://openalex.org/S4210224534',
'display_name': 'Bulletin Géodésique',
'issn_l': '0007-4632',
'issn': ['0007-4632'],
'is_oa': False,
'is_in_doaj': False,
'is_indexed_in_scopus': False,
'is_core': False,
'host_organization': 'https://openalex.org/P4310319965',
'host_organization_name': 'Springer Nature',
'host_organization_lineage': ['https://openalex.org/P4310319965'],
'host_organization_lineage_names': ['Springer Nature'],
'type': 'journal'},
'license': None,
'license_id': None,
'version': None,
'is_accepted': False,
'is_published': False}],
'best_oa_location': None,
'sustainable_development_goals': [{'score': 0.45,
'id': 'https://metadata.un.org/sdg/13',
'display_name': 'Climate action'}],
'grants': [],
'datasets': [],
'versions': [],
'referenced_works_count': 0,
'referenced_works': [],
'related_works': ['https://openalex.org/W4381329014',
'https://openalex.org/W4252642356',
'https://openalex.org/W2949194655',
'https://openalex.org/W2612515138',
'https://openalex.org/W2366229771',
'https://openalex.org/W2340859935',
'https://openalex.org/W2028428095',
'https://openalex.org/W2019057379',
'https://openalex.org/W1989808455',
'https://openalex.org/W1982102372'],
'abstract_inverted_index': None,
'abstract_inverted_index_v3': None,
'cited_by_api_url': 'https://api.openalex.org/works?filter=cites:W2095673763',
'counts_by_year': [{'year': 2025, 'cited_by_count': 1},
{'year': 2024, 'cited_by_count': 2},
{'year': 2023, 'cited_by_count': 2},
{'year': 2022, 'cited_by_count': 1},
{'year': 2021, 'cited_by_count': 22},
{'year': 2020, 'cited_by_count': 28},
{'year': 2019, 'cited_by_count': 31},
{'year': 2018, 'cited_by_count': 21},
{'year': 2017, 'cited_by_count': 51},
{'year': 2016, 'cited_by_count': 32},
{'year': 2015, 'cited_by_count': 50},
{'year': 2014, 'cited_by_count': 50},
{'year': 2013, 'cited_by_count': 36},
{'year': 2012, 'cited_by_count': 42}],
'updated_date': '2025-05-06T05:22:58.417031',
'created_date': '2016-06-24'}
Index Out Query Results#
Now that we’ve obtained some data from the API, we can index out some of data from this query:
# Display the DOI of the second work returned
geodetics_data['results'][1]['doi']
'https://doi.org/10.1002/2014gc005407'
# Display the title of the second work returned
geodetics_data['results'][1]['title']
'A geodetic plate motion and Global Strain Rate Model'
# Display the primary institution of the first author of the second work returned
geodetics_data['results'][1]['authorships'][0]['institutions'][0]['display_name']
'University of Nevada, Reno'
# Display titles of first 10 results
for work in geodetics_data['results'][:10]:
print(work['title'])
Geodetic Reference System 1980
A geodetic plate motion and Global Strain Rate Model
A testing procedure for use in geodetic networks
Geodetic determination of relative plate motion in central California
Inertial Navigation Systems with Geodetic Applications
Effect of annual signals on geodetic velocity
Short Note: A global model of pressure and temperature for geodetic applications
Geodetic Reference System 1980
Density assumptions for converting geodetic glacier volume change to mass change
Geodetic reference system 1980
Query with Boolean Logic#
The API also allows us to use boolean operators AND, OR, and NOT (must be capitalized) when querying for works. This example searches for works whose abstracts contain “simulation” and “chemistry” and not “medicine” or “energy”:
endpoint = 'works'
filters = 'abstract.search:("simulation" AND "chemistry") NOT ("medicine" OR "energy")'
params = {
'filter': filters,
'mailto': EMAIL
}
data = requests.get(BASE_URL + endpoint, params=params).json()
# Display resulting metadata
data['meta']
{'count': 26750,
'db_response_time_ms': 89,
'page': 1,
'per_page': 25,
'groups_count': None}
2. Retrieve Publications from an Institution#
The OpenAlex API provides several ways to find the works published through an institution. In this tutorial, we’ll look at how to achieve this by searching with an ROR ID and an OpenAlex ID.
Search Using an ROR Identifier#
The OpenAlex API allows us to access the publications from an institution through its ROR ID. To find the ROR ID for an institution, we can search for the institution here.
To see how to programmatically obtain ROR IDs for institutions, please see our Research Organization Registry cookbook tutorials.
In this example, we’ll look at the University of Alabama, which has the ROR identifier of https://ror.org/03xrrjk67.
ua_ror = 'https://ror.org/03xrrjk67'
endpoint = 'works'
filters = f'institutions.ror:{ua_ror}'
params = {
'filter': filters,
'mailto': EMAIL
}
ua_data = requests.get(BASE_URL + endpoint, params=params).json()
# Display length of data and other info
ua_data['meta']
{'count': 67125,
'db_response_time_ms': 112,
'page': 1,
'per_page': 25,
'groups_count': None}
Search Using an OpenAlex ID#
To find the OpenAlex ID of an institution, we’ll first perform an institution search:
endpoint = 'institutions'
search = 'University of Alabama'
params = {
'search': search,
'mailto': EMAIL
}
institutions_search_results = requests.get(BASE_URL + endpoint, params=params).json()
# Display resulting metadata
institutions_search_results['meta']
{'count': 11,
'db_response_time_ms': 35,
'page': 1,
'per_page': 25,
'groups_count': None}
institutions_search_results['results'][0]
{'id': 'https://openalex.org/I32389192',
'ror': 'https://ror.org/008s83205',
'display_name': 'University of Alabama at Birmingham',
'relevance_score': 111419.7,
'country_code': 'US',
'type': 'funder',
'type_id': 'https://openalex.org/institution-types/funder',
'lineage': ['https://openalex.org/I32389192'],
'homepage_url': 'https://www.uab.edu',
'image_url': 'https://commons.wikimedia.org/w/index.php?title=Special:Redirect/file/UABirmingham%20logo.png',
'image_thumbnail_url': 'https://commons.wikimedia.org/w/index.php?title=Special:Redirect/file/UABirmingham%20logo.png&width=300',
'display_name_acronyms': ['UAB'],
'display_name_alternatives': ["Université d'alabama à birmingham"],
'repositories': [],
'works_count': 136892,
'cited_by_count': 5318657,
'summary_stats': {'2yr_mean_citedness': 3.9929190751445085,
'h_index': 663,
'i10_index': 66083},
'ids': {'openalex': 'https://openalex.org/I32389192',
'ror': 'https://ror.org/008s83205',
'mag': '32389192',
'grid': 'grid.265892.2',
'wikipedia': 'https://en.wikipedia.org/wiki/University%20of%20Alabama%20at%20Birmingham',
'wikidata': 'https://www.wikidata.org/wiki/Q1472663'},
'geo': {'city': 'Birmingham',
'geonames_city_id': '4049979',
'region': None,
'country_code': 'US',
'country': 'United States',
'latitude': 33.52066,
'longitude': -86.80249},
'international': {'display_name': {'ar': 'جامعة ألاباما في برمنغهام',
'arz': 'جامعة الاباما فى برمنجهام',
'ast': "Universidá d'Alabama en Birmingham",
'azb': 'برمینقم\u200cده\u200cکی آلاباما بیلیم\u200cیوردو',
'be': 'Алабамскі ўніверсітэт у Бірмінгеме',
'ca': "Universitat d'Alabama a Birmingham",
'cs': 'University of Alabama at Birmingham',
'de': 'University of Alabama at Birmingham',
'en': 'University of Alabama at Birmingham',
'eo': 'Universitato de Alabamo ĉe Birmingham',
'es': 'Universidad de Alabama en Birmingham',
'fa': 'دانشگاه آلاباما در برمینگهم',
'fi': 'Alabaman yliopisto (Birmingham)',
'fr': "université de l'Alabama à Birmingham",
'ga': 'Ollscoil Alabama, Birmingham',
'he': 'אוניברסיטת אלבמה בבירמינגהם',
'it': "Università dell'Alabama a Birmingham",
'ja': 'アラバマ大学バーミンガム校',
'pl': 'University of Alabama at Birmingham',
'ru': 'Университет Алабамы в Бирмингеме',
'sl': 'Univerza Alabame v Birminghamu',
'sv': 'University of Alabama at Birmingham',
'uk': 'Університет Алабами в Бірмінгемі',
'ur': 'یونیورسٹی آف الاباما ایٹ برمنگھم',
'zh': '阿拉巴馬大學伯明翰分校',
'zh-cn': '亚拉巴马大學伯明翰校區',
'zh-hant': '亞拉巴馬大學伯明翰校區'}},
'associated_institutions': [{'id': 'https://openalex.org/I2800507078',
'ror': 'https://ror.org/051fvmk98',
'display_name': 'University of Alabama System',
'country_code': 'US',
'type': 'education',
'relationship': 'parent'},
{'id': 'https://openalex.org/I320755355',
'ror': 'https://ror.org/053bp9m60',
'display_name': "Children's of Alabama",
'country_code': 'US',
'type': 'healthcare',
'relationship': 'related'},
{'id': 'https://openalex.org/I4210157920',
'ror': 'https://ror.org/04vzsq290',
'display_name': 'Mississippi Alabama Sea Grant Consortium',
'country_code': 'US',
'type': 'other',
'relationship': 'related'},
{'id': 'https://openalex.org/I1335695989',
'ror': 'https://ror.org/01rm42p40',
'display_name': 'University of Alabama at Birmingham Hospital',
'country_code': 'US',
'type': 'healthcare',
'relationship': 'related'}],
'counts_by_year': [{'year': 2025,
'works_count': 1843,
'cited_by_count': 106349},
{'year': 2024, 'works_count': 6496, 'cited_by_count': 365567},
{'year': 2023, 'works_count': 6997, 'cited_by_count': 372340},
{'year': 2022, 'works_count': 6874, 'cited_by_count': 366599},
{'year': 2021, 'works_count': 6866, 'cited_by_count': 375341},
{'year': 2020, 'works_count': 6959, 'cited_by_count': 341421},
{'year': 2019, 'works_count': 6170, 'cited_by_count': 280931},
{'year': 2018, 'works_count': 5823, 'cited_by_count': 252965},
{'year': 2017, 'works_count': 5495, 'cited_by_count': 242055},
{'year': 2016, 'works_count': 5259, 'cited_by_count': 227481},
{'year': 2015, 'works_count': 4899, 'cited_by_count': 221700},
{'year': 2014, 'works_count': 4799, 'cited_by_count': 209782},
{'year': 2013, 'works_count': 4592, 'cited_by_count': 198106},
{'year': 2012, 'works_count': 3941, 'cited_by_count': 182861}],
'roles': [{'role': 'funder',
'id': 'https://openalex.org/F4320310431',
'works_count': 812},
{'role': 'institution',
'id': 'https://openalex.org/I32389192',
'works_count': 136892}],
'topics': [{'id': 'https://openalex.org/T11020',
'display_name': 'Immune Cell Function and Interaction',
'count': 2376,
'subfield': {'id': 'https://openalex.org/subfields/2403',
'display_name': 'Immunology'},
'field': {'id': 'https://openalex.org/fields/24',
'display_name': 'Immunology and Microbiology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T10082',
'display_name': 'HIV/AIDS Research and Interventions',
'count': 2199,
'subfield': {'id': 'https://openalex.org/subfields/2725',
'display_name': 'Infectious Diseases'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10112',
'display_name': 'HIV Research and Treatment',
'count': 2054,
'subfield': {'id': 'https://openalex.org/subfields/2406',
'display_name': 'Virology'},
'field': {'id': 'https://openalex.org/fields/24',
'display_name': 'Immunology and Microbiology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T10031',
'display_name': 'T-cell and B-cell Immunology',
'count': 2041,
'subfield': {'id': 'https://openalex.org/subfields/2403',
'display_name': 'Immunology'},
'field': {'id': 'https://openalex.org/fields/24',
'display_name': 'Immunology and Microbiology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T10549',
'display_name': 'Neonatal Respiratory Health Research',
'count': 1965,
'subfield': {'id': 'https://openalex.org/subfields/2740',
'display_name': 'Pulmonary and Respiratory Medicine'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T11016',
'display_name': 'Monoclonal and Polyclonal Antibodies Research',
'count': 1809,
'subfield': {'id': 'https://openalex.org/subfields/2741',
'display_name': 'Radiology, Nuclear Medicine and Imaging'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10144',
'display_name': 'Blood Pressure and Hypertension Studies',
'count': 1518,
'subfield': {'id': 'https://openalex.org/subfields/2705',
'display_name': 'Cardiology and Cardiovascular Medicine'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10077',
'display_name': 'Neuroscience and Neuropharmacology Research',
'count': 1509,
'subfield': {'id': 'https://openalex.org/subfields/2804',
'display_name': 'Cellular and Molecular Neuroscience'},
'field': {'id': 'https://openalex.org/fields/28',
'display_name': 'Neuroscience'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T10613',
'display_name': 'Virus-based gene therapy research',
'count': 1498,
'subfield': {'id': 'https://openalex.org/subfields/1311',
'display_name': 'Genetics'},
'field': {'id': 'https://openalex.org/fields/13',
'display_name': 'Biochemistry, Genetics and Molecular Biology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T10580',
'display_name': 'Immunotherapy and Immune Responses',
'count': 1382,
'subfield': {'id': 'https://openalex.org/subfields/2403',
'display_name': 'Immunology'},
'field': {'id': 'https://openalex.org/fields/24',
'display_name': 'Immunology and Microbiology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T10010',
'display_name': 'Obesity, Physical Activity, Diet',
'count': 1362,
'subfield': {'id': 'https://openalex.org/subfields/2739',
'display_name': 'Public Health, Environmental and Occupational Health'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10602',
'display_name': 'Glycosylation and Glycoproteins Research',
'count': 1345,
'subfield': {'id': 'https://openalex.org/subfields/1312',
'display_name': 'Molecular Biology'},
'field': {'id': 'https://openalex.org/fields/13',
'display_name': 'Biochemistry, Genetics and Molecular Biology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T10308',
'display_name': 'Systemic Lupus Erythematosus Research',
'count': 1297,
'subfield': {'id': 'https://openalex.org/subfields/2745',
'display_name': 'Rheumatology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10804',
'display_name': 'Health Systems, Economic Evaluations, Quality of Life',
'count': 1265,
'subfield': {'id': 'https://openalex.org/subfields/2002',
'display_name': 'Economics and Econometrics'},
'field': {'id': 'https://openalex.org/fields/20',
'display_name': 'Economics, Econometrics and Finance'},
'domain': {'id': 'https://openalex.org/domains/2',
'display_name': 'Social Sciences'}},
{'id': 'https://openalex.org/T11930',
'display_name': 'Cardiac, Anesthesia and Surgical Outcomes',
'count': 1263,
'subfield': {'id': 'https://openalex.org/subfields/2705',
'display_name': 'Cardiology and Cardiovascular Medicine'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10981',
'display_name': 'Cytomegalovirus and herpesvirus research',
'count': 1230,
'subfield': {'id': 'https://openalex.org/subfields/2713',
'display_name': 'Epidemiology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10645',
'display_name': 'Cardiac Arrest and Resuscitation',
'count': 1185,
'subfield': {'id': 'https://openalex.org/subfields/2711',
'display_name': 'Emergency Medicine'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10200',
'display_name': 'Rheumatoid Arthritis Research and Therapies',
'count': 1171,
'subfield': {'id': 'https://openalex.org/subfields/2745',
'display_name': 'Rheumatology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10625',
'display_name': 'Herpesvirus Infections and Treatments',
'count': 1171,
'subfield': {'id': 'https://openalex.org/subfields/2713',
'display_name': 'Epidemiology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10526',
'display_name': 'HIV/AIDS drug development and treatment',
'count': 1160,
'subfield': {'id': 'https://openalex.org/subfields/2725',
'display_name': 'Infectious Diseases'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10821',
'display_name': 'Cardiovascular Function and Risk Factors',
'count': 1155,
'subfield': {'id': 'https://openalex.org/subfields/2705',
'display_name': 'Cardiology and Cardiovascular Medicine'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T12267',
'display_name': 'Diet and metabolism studies',
'count': 1154,
'subfield': {'id': 'https://openalex.org/subfields/2737',
'display_name': 'Physiology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10428',
'display_name': 'Reproductive tract infections research',
'count': 1148,
'subfield': {'id': 'https://openalex.org/subfields/2404',
'display_name': 'Microbiology'},
'field': {'id': 'https://openalex.org/fields/24',
'display_name': 'Immunology and Microbiology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T11141',
'display_name': "Childhood Cancer Survivors' Quality of Life",
'count': 1143,
'subfield': {'id': 'https://openalex.org/subfields/2735',
'display_name': 'Pediatrics, Perinatology and Child Health'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10269',
'display_name': 'Epigenetics and DNA Methylation',
'count': 1134,
'subfield': {'id': 'https://openalex.org/subfields/1312',
'display_name': 'Molecular Biology'},
'field': {'id': 'https://openalex.org/fields/13',
'display_name': 'Biochemistry, Genetics and Molecular Biology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}}],
'topic_share': [{'id': 'https://openalex.org/T12315',
'display_name': 'Older Adults Driving Studies',
'value': 0.013943,
'subfield': {'id': 'https://openalex.org/subfields/3612',
'display_name': 'Physical Therapy, Sports Therapy and Rehabilitation'},
'field': {'id': 'https://openalex.org/fields/36',
'display_name': 'Health Professions'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T13522',
'display_name': 'Cardiovascular Health and Risk Factors',
'value': 0.0103753,
'subfield': {'id': 'https://openalex.org/subfields/2705',
'display_name': 'Cardiology and Cardiovascular Medicine'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T11655',
'display_name': 'HIV-related health complications and treatments',
'value': 0.009924,
'subfield': {'id': 'https://openalex.org/subfields/2711',
'display_name': 'Emergency Medicine'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10665',
'display_name': 'Cystic Fibrosis Research Advances',
'value': 0.0098301,
'subfield': {'id': 'https://openalex.org/subfields/2740',
'display_name': 'Pulmonary and Respiratory Medicine'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T12075',
'display_name': 'Sodium Intake and Health',
'value': 0.0095541,
'subfield': {'id': 'https://openalex.org/subfields/2916',
'display_name': 'Nutrition and Dietetics'},
'field': {'id': 'https://openalex.org/fields/29',
'display_name': 'Nursing'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10428',
'display_name': 'Reproductive tract infections research',
'value': 0.009419,
'subfield': {'id': 'https://openalex.org/subfields/2404',
'display_name': 'Microbiology'},
'field': {'id': 'https://openalex.org/fields/24',
'display_name': 'Immunology and Microbiology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T10112',
'display_name': 'HIV Research and Treatment',
'value': 0.0092998,
'subfield': {'id': 'https://openalex.org/subfields/2406',
'display_name': 'Virology'},
'field': {'id': 'https://openalex.org/fields/24',
'display_name': 'Immunology and Microbiology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T10082',
'display_name': 'HIV/AIDS Research and Interventions',
'value': 0.0086649,
'subfield': {'id': 'https://openalex.org/subfields/2725',
'display_name': 'Infectious Diseases'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T11290',
'display_name': 'Preterm Birth and Chorioamnionitis',
'value': 0.0082946,
'subfield': {'id': 'https://openalex.org/subfields/2713',
'display_name': 'Epidemiology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10261',
'display_name': 'Genetic Associations and Epidemiology',
'value': 0.0078039,
'subfield': {'id': 'https://openalex.org/subfields/1311',
'display_name': 'Genetics'},
'field': {'id': 'https://openalex.org/fields/13',
'display_name': 'Biochemistry, Genetics and Molecular Biology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T11616',
'display_name': 'Autoimmune and Inflammatory Disorders Research',
'value': 0.0074184,
'subfield': {'id': 'https://openalex.org/subfields/2720',
'display_name': 'Hematology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10684',
'display_name': 'Acute Kidney Injury Research',
'value': 0.0072665,
'subfield': {'id': 'https://openalex.org/subfields/2727',
'display_name': 'Nephrology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T11139',
'display_name': 'Gout, Hyperuricemia, Uric Acid',
'value': 0.0072642,
'subfield': {'id': 'https://openalex.org/subfields/2727',
'display_name': 'Nephrology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T12654',
'display_name': 'Xenotransplantation and immune response',
'value': 0.0070146,
'subfield': {'id': 'https://openalex.org/subfields/2746',
'display_name': 'Surgery'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10031',
'display_name': 'T-cell and B-cell Immunology',
'value': 0.0068811,
'subfield': {'id': 'https://openalex.org/subfields/2403',
'display_name': 'Immunology'},
'field': {'id': 'https://openalex.org/fields/24',
'display_name': 'Immunology and Microbiology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T10200',
'display_name': 'Rheumatoid Arthritis Research and Therapies',
'value': 0.0067996,
'subfield': {'id': 'https://openalex.org/subfields/2745',
'display_name': 'Rheumatology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10137',
'display_name': 'Multiple Sclerosis Research Studies',
'value': 0.0067786,
'subfield': {'id': 'https://openalex.org/subfields/2734',
'display_name': 'Pathology and Forensic Medicine'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10724',
'display_name': 'Ion Transport and Channel Regulation',
'value': 0.0065007,
'subfield': {'id': 'https://openalex.org/subfields/1312',
'display_name': 'Molecular Biology'},
'field': {'id': 'https://openalex.org/fields/13',
'display_name': 'Biochemistry, Genetics and Molecular Biology'},
'domain': {'id': 'https://openalex.org/domains/1',
'display_name': 'Life Sciences'}},
{'id': 'https://openalex.org/T10925',
'display_name': 'Spinal Cord Injury Research',
'value': 0.0064848,
'subfield': {'id': 'https://openalex.org/subfields/2734',
'display_name': 'Pathology and Forensic Medicine'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10526',
'display_name': 'HIV/AIDS drug development and treatment',
'value': 0.0063024,
'subfield': {'id': 'https://openalex.org/subfields/2725',
'display_name': 'Infectious Diseases'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10144',
'display_name': 'Blood Pressure and Hypertension Studies',
'value': 0.0062936,
'subfield': {'id': 'https://openalex.org/subfields/2705',
'display_name': 'Cardiology and Cardiovascular Medicine'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T11189',
'display_name': 'Transplantation: Methods and Outcomes',
'value': 0.0058912,
'subfield': {'id': 'https://openalex.org/subfields/2746',
'display_name': 'Surgery'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T11860',
'display_name': 'HIV, Drug Use, Sexual Risk',
'value': 0.0058615,
'subfield': {'id': 'https://openalex.org/subfields/2713',
'display_name': 'Epidemiology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}},
{'id': 'https://openalex.org/T10675',
'display_name': 'Mechanical Circulatory Support Devices',
'value': 0.0056885,
'subfield': {'id': 'https://openalex.org/subfields/2204',
'display_name': 'Biomedical Engineering'},
'field': {'id': 'https://openalex.org/fields/22',
'display_name': 'Engineering'},
'domain': {'id': 'https://openalex.org/domains/3',
'display_name': 'Physical Sciences'}},
{'id': 'https://openalex.org/T10981',
'display_name': 'Cytomegalovirus and herpesvirus research',
'value': 0.0056605,
'subfield': {'id': 'https://openalex.org/subfields/2713',
'display_name': 'Epidemiology'},
'field': {'id': 'https://openalex.org/fields/27',
'display_name': 'Medicine'},
'domain': {'id': 'https://openalex.org/domains/4',
'display_name': 'Health Sciences'}}],
'x_concepts': [{'id': 'https://openalex.org/C71924100',
'wikidata': 'https://www.wikidata.org/wiki/Q11190',
'display_name': 'Medicine',
'level': 0,
'score': 86.3},
{'id': 'https://openalex.org/C86803240',
'wikidata': 'https://www.wikidata.org/wiki/Q420',
'display_name': 'Biology',
'level': 0,
'score': 77.4},
{'id': 'https://openalex.org/C126322002',
'wikidata': 'https://www.wikidata.org/wiki/Q11180',
'display_name': 'Internal medicine',
'level': 1,
'score': 63.9},
{'id': 'https://openalex.org/C54355233',
'wikidata': 'https://www.wikidata.org/wiki/Q7162',
'display_name': 'Genetics',
'level': 1,
'score': 48.5},
{'id': 'https://openalex.org/C185592680',
'wikidata': 'https://www.wikidata.org/wiki/Q2329',
'display_name': 'Chemistry',
'level': 0,
'score': 45.7},
{'id': 'https://openalex.org/C142724271',
'wikidata': 'https://www.wikidata.org/wiki/Q7208',
'display_name': 'Pathology',
'level': 1,
'score': 40.8},
{'id': 'https://openalex.org/C55493867',
'wikidata': 'https://www.wikidata.org/wiki/Q7094',
'display_name': 'Biochemistry',
'level': 1,
'score': 39.1},
{'id': 'https://openalex.org/C15744967',
'wikidata': 'https://www.wikidata.org/wiki/Q9418',
'display_name': 'Psychology',
'level': 0,
'score': 36.3},
{'id': 'https://openalex.org/C141071460',
'wikidata': 'https://www.wikidata.org/wiki/Q40821',
'display_name': 'Surgery',
'level': 1,
'score': 29.1},
{'id': 'https://openalex.org/C121332964',
'wikidata': 'https://www.wikidata.org/wiki/Q413',
'display_name': 'Physics',
'level': 0,
'score': 27.6},
{'id': 'https://openalex.org/C134018914',
'wikidata': 'https://www.wikidata.org/wiki/Q162606',
'display_name': 'Endocrinology',
'level': 1,
'score': 24.6},
{'id': 'https://openalex.org/C203014093',
'wikidata': 'https://www.wikidata.org/wiki/Q101929',
'display_name': 'Immunology',
'level': 1,
'score': 23.6},
{'id': 'https://openalex.org/C118552586',
'wikidata': 'https://www.wikidata.org/wiki/Q7867',
'display_name': 'Psychiatry',
'level': 1,
'score': 23.4},
{'id': 'https://openalex.org/C33923547',
'wikidata': 'https://www.wikidata.org/wiki/Q395',
'display_name': 'Mathematics',
'level': 0,
'score': 22.4},
{'id': 'https://openalex.org/C41008148',
'wikidata': 'https://www.wikidata.org/wiki/Q21198',
'display_name': 'Computer science',
'level': 0,
'score': 21.2}],
'is_super_system': False,
'works_api_url': 'https://api.openalex.org/works?filter=institutions.id:I32389192',
'updated_date': '2025-05-05T13:12:13.603189',
'created_date': '2016-06-24'}
This query returned several universities related to the “University of Alabama”:
for institution in institutions_search_results['results']:
print(f"{institution['display_name']}: {institution['id']}")
University of Alabama at Birmingham: https://openalex.org/I32389192
University of Alabama: https://openalex.org/I17301866
University of Alabama in Huntsville: https://openalex.org/I82495205
University of South Alabama: https://openalex.org/I83809506
University of Alabama at Birmingham Hospital: https://openalex.org/I1335695989
University of Alabama System: https://openalex.org/I2800507078
University of North Alabama: https://openalex.org/I12970578
University of South Alabama Medical Center: https://openalex.org/I4210151789
University of West Alabama: https://openalex.org/I68631920
UAB Medicine: https://openalex.org/I4390039250
Amridge University: https://openalex.org/I2800517358
As we can see above, the OpenAlex ID for the University of Alabama is “https://openalex.org/I17301866” or just “I17301866”
ua_openalex_id = 'I17301866'
endpoint = 'works'
filters = f'institutions.id:{ua_openalex_id}'
params = {
'filter': filters,
'mailto': EMAIL
}
ua_data = requests.get(BASE_URL + endpoint, params=params).json()
# Display resulting metadata
ua_data['meta']
{'count': 67125,
'db_response_time_ms': 179,
'page': 1,
'per_page': 25,
'groups_count': None}
As we can see from the count
in the metadata, these two approaches found the same number of publications.
3. Page through the Results of a Query#
In the examples above, we have only retrieved the first page of results for a query. If we wish to obtain all of the data for an institution, we must page through the results. Paging is used in the example below to obtain all of the publications by UA in the OpenAlex database:
# Parameters for obtaining UA publications
endpoint = 'works'
filters = 'institutions.id:I17301866'
# The cursor to the next page is given in the metadata of the response
# To get the first page, we set the cursor parameter to '*'
cursor = '*'
page_size = 200
ua_articles = []
# When the end of the results has been reached, the 'next_cursor' variable will be null
# This while loop iterates through all pages of the results
while cursor is not None:
params = {
'filter': filters,
'cursor': cursor,
'per-page': page_size,
'mailto': EMAIL
}
page_data = requests.get(BASE_URL + endpoint, params=params).json()
# Set cursor to the next page
cursor = page_data['meta']['next_cursor']
# Add results to the ua_articles list
ua_articles.extend(page_data['results'])
# Wait 0.2 seconds between requests to follow OpenAlex's rate limit
sleep(0.2)
# Display number of UA articles in database
len(ua_articles)
67125
Plot UA Publications by Year#
This example plots the number of UA publications per year from 1970 onward:
# Extract publication years
publication_years = []
for article in ua_articles:
if article['publication_year'] >= 1970:
publication_years.append(article['publication_year'])
# Count occurrences of each publication year
year_counts = Counter(publication_years)
# Plot data
years = list(year_counts.keys())
counts = list(year_counts.values())
plt.bar(years, counts, color='skyblue')
plt.xlabel('Publication Year')
plt.ylabel('Number of Articles')
plt.title('UA Articles per Publication Year')
plt.show()

Plot Open Access UA Publications#
Inspired by: https://github.com/ourresearch/openalex-api-tutorials/blob/main/notebooks/institutions/oa-percentage.ipynb
This example plots the prevalence open access in UA articles from 2000 onward:
# Extract publication years and 'is_open' values
year_oa = [(art['publication_year'], art['open_access']['is_oa']) for art in ua_articles]
# Filter to include only years after 1999
filtered_data = [(year, is_open) for year, is_open in year_oa if 2008 <= year <= 2024]
# Count occurrences of (year, is_open)
count_per_year_is_open = Counter(filtered_data)
# Plot data
years = sorted(set(year for year, _ in filtered_data))
open_access_counts = [count_per_year_is_open[(year, True)] for year in years]
not_open_access_counts = [count_per_year_is_open[(year, False)] for year in years]
# Compute and add percentages
percent_oa = []
for oa,not_oa in zip(open_access_counts,not_open_access_counts):
percent_oa.append(round((oa/(oa + not_oa)*100)))
# Plot with percentage labels
fig, ax = plt.subplots(figsize=(10, 5))
bars = plt.bar(years, open_access_counts, color='darkgreen', label='Open Access')
# Add labels above bars
for bar, percent in zip(bars, percent_oa):
height = bar.get_height()
ax.text(bar.get_x() + bar.get_width() / 2, height, f'{percent}%', ha='center', va='bottom',
color='white', fontsize=10)
plt.bar(years, not_open_access_counts, bottom=open_access_counts, color='darkred',
label='Not Open Access')
plt.xlabel('Publication Year')
plt.ylabel('Number of Articles')
plt.title('Open Accss UA Articles per Publication Year')
plt.legend(loc='upper left')
ax.set_xticks(years)
plt.show()
