Skip to content

Commit

Permalink
Add support for OpenAlex Funders (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
J535D165 authored May 20, 2023
1 parent 37b24d1 commit 2d02c6a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ pip install pyalex

## Getting started

PyAlex offers support for all [Entity Objects](https://docs.openalex.org/api-entities/entities-overview): [Works](https://docs.openalex.org/api-entities/works), [Authors](https://docs.openalex.org/api-entities/authors), [Sources](https://docs.openalex.org/api-entities/sourcese), [Institutions](https://docs.openalex.org/api-entities/institutions), [Concepts](https://docs.openalex.org/api-entities/concepts), and [Publishers](https://docs.openalex.org/api-entities/publishers).
PyAlex offers support for all [Entity Objects](https://docs.openalex.org/api-entities/entities-overview): [Works](https://docs.openalex.org/api-entities/works), [Authors](https://docs.openalex.org/api-entities/authors), [Sources](https://docs.openalex.org/api-entities/sourcese), [Institutions](https://docs.openalex.org/api-entities/institutions), [Concepts](https://docs.openalex.org/api-entities/concepts), [Publishers](https://docs.openalex.org/api-entities/publishers), and [Funders](https://docs.openalex.org/api-entities/funders).

```python
from pyalex import Works, Authors, Sources, Institutions, Concepts, Publishers
from pyalex import Works, Authors, Sources, Institutions, Concepts, Publishers, Funders
```

### The polite pool
Expand All @@ -64,7 +64,7 @@ pyalex.config.email = "mail@example.com"

### Get single entity

Get a single Work, Author, Source, Institution, Concept, or Publisher from OpenAlex by the
Get a single Work, Author, Source, Institution, Concept, Publisher or Funder from OpenAlex by the
OpenAlex ID, or by DOI or ROR.

```python
Expand Down Expand Up @@ -95,14 +95,16 @@ Authors()["https://orcid.org/0000-0002-4297-0502"] # same

#### Get random

Get a [random Work, Author, Source, Institution, Concept, or Publisher](https://docs.openalex.org/how-to-use-the-api/get-single-entities/random-result).
Get a [random Work, Author, Source, Institution, Concept, Publisher or Funder](https://docs.openalex.org/how-to-use-the-api/get-single-entities/random-result).

```python
Works().random()
Authors().random()
Sources().random()
Institutions().random()
Concepts().random()
Publishers().random()
Funders().random()
```

#### Get abstract
Expand All @@ -113,7 +115,7 @@ Only for Works. Request a work from the OpenAlex database:
w = Works()["W3128349626"]
```

All attributes are available like documented under [Works](https://docs.openalex.org/api-entities/works/work-object), as well as `abstract` (only if `abstract_inverted_index` is not None). This abstract made human readable is create on the fly.
All attributes are available like documented under [Works](https://docs.openalex.org/api-entities/works/work-object), as well as `abstract` (only if `abstract_inverted_index` is not None). This abstract made human readable is create on the fly.

```python
w["abstract"]
Expand Down Expand Up @@ -187,6 +189,11 @@ Authors().search_filter(display_name="einstein").get()
Works().search_filter(title="cubist").get()
```

```python
Funders().search_filter(display_name="health").get()
```


#### Sort entity lists

OpenAlex reference: [Sort entity lists](https://docs.openalex.org/api-entities/works/get-lists-of-works#page-and-sort-works).
Expand Down Expand Up @@ -326,7 +333,7 @@ Works() \

```

## Experimental
## Experimental

### Authentication

Expand Down
4 changes: 4 additions & 0 deletions pyalex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from pyalex.api import Authors
from pyalex.api import Concept
from pyalex.api import Concepts
from pyalex.api import Funder
from pyalex.api import Funders
from pyalex.api import Institution
from pyalex.api import Institutions
from pyalex.api import Journals
Expand All @@ -31,6 +33,8 @@
"Author",
"Sources",
"Source",
"Funder",
"Funders",
"Publishers",
"Publisher",
"Venues",
Expand Down
8 changes: 8 additions & 0 deletions pyalex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ class Publisher(OpenAlexEntity):
pass


class Funder(OpenAlexEntity):
pass

# deprecated


Expand Down Expand Up @@ -383,6 +386,11 @@ class Publishers(BaseOpenAlex):
obj = Publisher


class Funders(BaseOpenAlex):

url_collection = config.openalex_url + "/funders"
obj = Funder

# deprecated


Expand Down
4 changes: 3 additions & 1 deletion tests/test_pyalex.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pyalex
from pyalex import Authors
from pyalex import Concepts
from pyalex import Funders
from pyalex import Institutions
from pyalex import Publishers
from pyalex import Sources
Expand Down Expand Up @@ -38,7 +39,8 @@ def test_meta_entities():
assert "count" in m
_, m = Works().get(return_meta=True)
assert "count" in m

_, m = Funders().get(return_meta=True)
assert "count" in m

def test_works_params():

Expand Down

0 comments on commit 2d02c6a

Please sign in to comment.