Skip to content
This repository was archived by the owner on Feb 25, 2023. It is now read-only.

Commit 74751c2

Browse files
committed
Handle 404 from OpenAlex and prepare 0.0.1-alpha3
1 parent 6d3da6d commit 74751c2

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

openalexapi/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class OpenAlex(BaseModel):
1515
email: Optional[str]
1616
base_url = "https://api.openalex.org/"
1717

18-
def get_single_work(self, id):
18+
def get_single_work(self, id) -> Optional[Work]:
1919
"""This models the single work entity endpoint
2020
2121
:parameter id can be and OpenAlex ID e.g. "W123" or a namespace ID like "doi:10.123"
@@ -33,5 +33,7 @@ def get_single_work(self, id):
3333
response = requests.get(url, headers=headers)
3434
if response.status_code == 200:
3535
return Work(**response.json())
36+
elif response.status_code == 404:
37+
return None
3638
else:
3739
raise ValueError(f"Got {response.status_code} from OpenAlex")

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = openalexapi
3-
version = 0.0.1-alpha2
3+
version = 0.0.1-alpha3
44
author = Dennis Priskorn
55
author_email = dp_public@riseup.net
66
description = Libray for accessing the OpenAlex API

0 commit comments

Comments
 (0)