Skip to main content

diophila

Python API Wrapper for OpenAlex.

Entities / Endpoints

OpenAlex currently describes five different scholarly entity types and their connections:

Each entity type comes with an endpoint of the same name that can be queried for a single (random or specific) entity or multiple (grouped or listed) entities.

Installation

pip (or pip3) install diophila

Usage

First off, you need to initialize a client. The client offers all methods to query the API.

from diophila import OpenAlex

openalex = OpenAlex()

You can use the client to query for a single random entity with the method get_random_<entity>:

random_author = openalex.get_random_author()
random_author['id']

Or if you have a specific entity in mind, you can use the client using one of the entity's IDs via the get_single_<entity> method:

specific_work = openalex.get_single_work("https://doi.org/10.1364/PRJ.433188", "doi")
specific_work['display_name']

If you are interested in entities grouped into facets, use the get_groups_of_<entities> method:

grouped_institutions = openalex.get_groups_of_institutions("type")
for group in grouped_institutions['group_by']:
    group['key']

And last but not least you can get multiple entities from a type in a list by using the get_list_of_<entities> method. Note that this method uses pagination, either basic paging or cursor paging depending on whether the pages parameter is supplied:

# if no `pages` parameter is supplied, we use cursor paging
pages = None
# if `pages` parameter is supplied, we use basic paging
pages = [1, 2, 3]

filters = {"is_oa": "true",
           "works_count": ">15000"}
pages_of_venues = openalex.get_list_of_venues(filters=filters, pages=pages)

for page in pages_of_venues:        # loop through pages
    for venue in page['results']:   # loop though list of venues
        venue['id']

Bonus: If you want to retrieve all works connected to another entity, you may use the entity's works_api_url property with the get_works_by_api_url method:

works_api_url = "https://api.openalex.org/works?filter=author.id:A1969205032"
pages_of_works = openalex.get_works_by_api_url(works_api_url)

for page in pages_of_works:
    for work in page['results']:
        work['display_name']

The Polite Pool

It's a good idea to use OpenAlex polite pool which offers faster response times for users providing an email address. If you would like to use it, simply initialize the client with your email address.

from diophila import OpenAlex

openalex = OpenAlex("your-email@address.com")

Rate limits

The API currently doesn't have rate limits. However, if you need more than 100,000 calls per day, please drop the OpenAlex team a line at team@ourresearch.org or alternatively look into using a snapshot.

Citation

If you are using OpenAlex in your research, the OpenAlex team kindly asks you to cite https://doi.org/10.48550/arXiv.2205.01833

Metadata

Release files for diophila 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for diophila 0.4.0
File Size Uploaded
diophila-0.4.0.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for diophila 0.4.0
File Interpreter ABI Platform
diophila-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / diophila-0.4.0.tar.gz

Download URL diophila-0.4.0.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6fcc04c9d707a601ab6b447d6616de9e6fee118fdf4bc4d9e08bf6c4132704e3
BLAKE2b-256 checksum
How to use checksums
a044402da824c41f1cd95c5718fedef14a39789c8af15e73d2c18f0c9cbf825b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.13

Release files / diophila-0.4.0-py3-none-any.whl

Download URL diophila-0.4.0-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2dab4464026efe1a7b3384b5bfe94c2f29436e0a70643ec842644bf649c2044
BLAKE2b-256 checksum
How to use checksums
0ba92092e732a65cc5d8e2e71c4db5a2c62e41103f307f7543be1196399adfe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.13

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page