Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Topics #35

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pip install pyalex
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), [Funders](https://docs.openalex.org/api-entities/funders), and [Autocomplete](https://docs.openalex.org/how-to-use-the-api/get-lists-of-entities/autocomplete-entities).

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

### The polite pool
Expand Down Expand Up @@ -77,7 +77,7 @@ config.retry_http_codes = [429, 500, 503]

### Get single entity

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

```python
Expand All @@ -99,7 +99,7 @@ Works()["W2741809807"]["open_access"]
{'is_oa': True, 'oa_status': 'gold', 'oa_url': 'https://doi.org/10.7717/peerj.4375'}
```

The previous works also for Authors, Venues, Institutions and Concepts
The previous works also for Authors, Venues, Institutions, Concepts and Topics

```python
Authors()["A2887243803"]
Expand All @@ -108,14 +108,15 @@ Authors()["https://orcid.org/0000-0002-4297-0502"] # same

#### Get random

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).
Get a [random Work, Author, Source, Institution, Concept, Topic, 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()
Topics().random()
Publishers().random()
Funders().random()
```
Expand Down Expand Up @@ -158,7 +159,7 @@ Works().count()
For lists of entities, you can return the result as well as the metadata. By default, only the results are returned.

```python
results, meta = Concepts().get(return_meta=True)
results, meta = Topics().get(return_meta=True)
```

```python
Expand Down
16 changes: 16 additions & 0 deletions pyalex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
from pyalex.api import Publishers
from pyalex.api import Source
from pyalex.api import Sources
from pyalex.api import Domain
from pyalex.api import Domains
from pyalex.api import Field
from pyalex.api import Fields
from pyalex.api import Subfield
from pyalex.api import Subfields
from pyalex.api import Topic
from pyalex.api import Topics
from pyalex.api import Venue
from pyalex.api import Venues
from pyalex.api import Work
Expand All @@ -44,6 +52,14 @@
"Institution",
"Concepts",
"Concept",
"Domains",
"Domain",
"Fields",
"Field",
"Subfields",
"Subfield",
"Topics",
"Topic",
"People",
"Journals",
"autocomplete",
Expand Down
32 changes: 32 additions & 0 deletions pyalex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,38 @@ class Concepts(BaseOpenAlex):
resource_class = Concept


class Domain(OpenAlexEntity):
pass


class Domains(BaseOpenAlex):
resource_class = Domain


class Field(OpenAlexEntity):
pass


class Fields(BaseOpenAlex):
resource_class = Field


class Subfield(OpenAlexEntity):
pass


class Subfields(BaseOpenAlex):
resource_class = Subfield


class Topic(OpenAlexEntity):
pass


class Topics(BaseOpenAlex):
resource_class = Topic


class Publisher(OpenAlexEntity):
pass

Expand Down
9 changes: 9 additions & 0 deletions tests/test_pyalex.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pyalex import Institutions
from pyalex import Publishers
from pyalex import Sources
from pyalex import Domains, Fields, Subfields, Topics
from pyalex import Work
from pyalex import Works
from pyalex import autocomplete
Expand All @@ -37,6 +38,14 @@ def test_meta_entities():
assert "count" in m
_, m = Sources().get(return_meta=True)
assert "count" in m
_, m = Domains().get(return_meta=True)
assert "count" in m
_, m = Fields().get(return_meta=True)
assert "count" in m
_, m = Subfields().get(return_meta=True)
assert "count" in m
_, m = Topics().get(return_meta=True)
assert "count" in m
_, m = Works().get(return_meta=True)
assert "count" in m
_, m = Funders().get(return_meta=True)
Expand Down
Loading