aletheca 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {aletheca-0.2.0 → aletheca-0.2.2}/PKG-INFO +14 -6
  2. {aletheca-0.2.0 → aletheca-0.2.2}/README.md +12 -4
  3. aletheca-0.2.2/pyproject.toml +139 -0
  4. aletheca-0.2.0/pyproject.toml → aletheca-0.2.2/pyproject.toml.orig +2 -2
  5. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/constants.py +0 -1
  6. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/endpoints.py +64 -14
  7. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/dehydrated.py +1 -3
  8. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/resources/_standard.py +29 -7
  9. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/resources/works_client.py +1 -4
  10. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/__init__.py +0 -0
  11. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/_helpers.py +0 -0
  12. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/client.py +0 -0
  13. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/config.py +0 -0
  14. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/__init__.py +0 -0
  15. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/author.py +0 -0
  16. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/award.py +0 -0
  17. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/base.py +0 -0
  18. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/common.py +0 -0
  19. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/funder.py +0 -0
  20. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/ids.py +0 -0
  21. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/institution.py +0 -0
  22. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/keyword.py +0 -0
  23. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/publisher.py +0 -0
  24. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/safe_types.py +0 -0
  25. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/source.py +0 -0
  26. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/topic.py +0 -0
  27. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/models/work.py +0 -0
  28. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/py.typed +0 -0
  29. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/queries.py +0 -0
  30. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/resources/__init__.py +0 -0
  31. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/resources/authors_client.py +0 -0
  32. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/resources/awards_client.py +0 -0
  33. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/resources/funders_client.py +0 -0
  34. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/resources/institutions_client.py +0 -0
  35. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/resources/keywords_client.py +0 -0
  36. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/resources/publishers_client.py +0 -0
  37. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/resources/sources_client.py +0 -0
  38. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/resources/topics_client.py +0 -0
  39. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/session.py +0 -0
  40. {aletheca-0.2.0 → aletheca-0.2.2}/src/aletheca/unwrapper.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aletheca
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Python interface for the OpenAlex API, built on top of the bibliofabric framework.
5
5
  Author: Samuel Mok
6
6
  Author-email: Samuel Mok <s.mok@utwente.nl>
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3.12
11
11
  Classifier: Programming Language :: Python :: 3.13
12
12
  Classifier: Framework :: AsyncIO
13
13
  Classifier: Typing :: Typed
14
- Requires-Dist: bibliofabric>=0.4.2,<0.5.0
14
+ Requires-Dist: bibliofabric>=0.5.1,<0.6.0
15
15
  Requires-Dist: polars ; extra == 'analysis'
16
16
  Requires-Dist: duckdb>=1.3.0 ; extra == 'analysis'
17
17
  Requires-Dist: matplotlib>=3.8.0 ; extra == 'analysis'
@@ -69,14 +69,14 @@ async def main():
69
69
  # Iterate all works by an author (cursor-based auto-pagination)
70
70
  async for work in session.works.iterate(
71
71
  filters={"authorships.author.id": "A1234567890"},
72
- page_size=200,
72
+ page_size=100,
73
73
  ):
74
74
  print(work.title)
75
75
 
76
76
  asyncio.run(main())
77
77
  ```
78
78
 
79
- No authentication required -- the OpenAlex API works without it. For higher rate limits, see [Authentication](#authentication).
79
+ No authentication required -- the OpenAlex API works without it. For higher rate limits, see [Authentication](https://utsmok.github.io/aletheca/authentication/).
80
80
 
81
81
  ## Examples
82
82
 
@@ -101,6 +101,8 @@ uv run marimo edit examples/simple_example.py
101
101
  | `07_iterator_helpers.py` | `collect()`, `count()`, `first()` from bibliofabric mixins |
102
102
  | `08_safe_types_and_helpers.py` | SafeList, SafeStr, DOI normalization, abstract reconstruction |
103
103
 
104
+ See [`examples/README.md`](examples/README.md) for details on running examples as interactive marimo notebooks.
105
+
104
106
  ## Authentication
105
107
 
106
108
  Aletheca auto-detects the OpenAlex API key from environment variables or `.env` files (prefixed with `ALETHECA_`). No auth is the default if nothing is configured.
@@ -118,6 +120,8 @@ async with AlethecaSession(api_key="your_api_key") as session:
118
120
 
119
121
  With an API key you get faster responses (dedicated pool). Without one, you use the polite pool (slower).
120
122
 
123
+ → **Full guide:** [Authentication](https://utsmok.github.io/aletheca/authentication/)
124
+
121
125
  ## Basic Usage
122
126
 
123
127
  ### Get a single entity
@@ -140,7 +144,7 @@ for work in results.results:
140
144
  ```python
141
145
  async for work in session.works.iterate(
142
146
  filters={"publication_year": 2024, "is_oa": True},
143
- page_size=200,
147
+ page_size=100,
144
148
  ):
145
149
  print(work.title)
146
150
  break # stop when you want
@@ -153,6 +157,8 @@ citations = await session.queries.citing_works("W2741809801")
153
157
  print(f"{len(citations)} citations")
154
158
  ```
155
159
 
160
+ → **Full guide:** [Usage Basics](https://utsmok.github.io/aletheca/usage_basics/) · [Works](https://utsmok.github.io/aletheca/usage/works/) · [All Entities](https://utsmok.github.io/aletheca/api_reference/)
161
+
156
162
  ## Known OpenAlex API Issues
157
163
 
158
164
  Full bug report with reproduction steps: [`OPENALEX_BUG_REPORT.md`](OPENALEX_BUG_REPORT.md).
@@ -161,7 +167,9 @@ Full bug report with reproduction steps: [`OPENALEX_BUG_REPORT.md`](OPENALEX_BUG
161
167
  - **Wrong field names in spec** -- `content_url` (spec) vs `content_urls` (live), `grants_count` (spec) vs `awards_count` (live)
162
168
  - **Undocumented fields** -- `institution_awarded` on Awards is not documented anywhere; 15+ nested Award filters are missing from the docs filter table
163
169
  - **Awards endpoint missing from `llms.txt`** -- the awards endpoint is not listed in the API quick reference
164
- - **`per_page` max is 200, not 100** -- documented as 100 but the API accepts 200
170
+ - **`per_page` max is 100** -- 200 still works but is deprecated legacy behavior, slated for removal (OpenAlex docs, 2026-08); all examples here use 100
171
+ - **Keyword IDs are slug paths, not short IDs** -- live keyword records carry ids like `https://openalex.org/keywords/photosynthesis`, and the single-record route rejects that full-URL form (nested slashes → HTML 404) even though `/works/https://openalex.org/W…` is accepted. `get()` normalizes both forms.
172
+ - **Awards 400 body is the authoritative filter list** -- the awards endpoint rejects several filters its docs summaries suggest (`funder.country_code`, plain `display_name`, `lead_investigator.id`, `from_/to_*_date`) and its 400 error body enumerates all 40 valid filters, which is more complete than any docs table.
165
173
 
166
174
  ## Development
167
175
 
@@ -43,14 +43,14 @@ async def main():
43
43
  # Iterate all works by an author (cursor-based auto-pagination)
44
44
  async for work in session.works.iterate(
45
45
  filters={"authorships.author.id": "A1234567890"},
46
- page_size=200,
46
+ page_size=100,
47
47
  ):
48
48
  print(work.title)
49
49
 
50
50
  asyncio.run(main())
51
51
  ```
52
52
 
53
- No authentication required -- the OpenAlex API works without it. For higher rate limits, see [Authentication](#authentication).
53
+ No authentication required -- the OpenAlex API works without it. For higher rate limits, see [Authentication](https://utsmok.github.io/aletheca/authentication/).
54
54
 
55
55
  ## Examples
56
56
 
@@ -75,6 +75,8 @@ uv run marimo edit examples/simple_example.py
75
75
  | `07_iterator_helpers.py` | `collect()`, `count()`, `first()` from bibliofabric mixins |
76
76
  | `08_safe_types_and_helpers.py` | SafeList, SafeStr, DOI normalization, abstract reconstruction |
77
77
 
78
+ See [`examples/README.md`](examples/README.md) for details on running examples as interactive marimo notebooks.
79
+
78
80
  ## Authentication
79
81
 
80
82
  Aletheca auto-detects the OpenAlex API key from environment variables or `.env` files (prefixed with `ALETHECA_`). No auth is the default if nothing is configured.
@@ -92,6 +94,8 @@ async with AlethecaSession(api_key="your_api_key") as session:
92
94
 
93
95
  With an API key you get faster responses (dedicated pool). Without one, you use the polite pool (slower).
94
96
 
97
+ → **Full guide:** [Authentication](https://utsmok.github.io/aletheca/authentication/)
98
+
95
99
  ## Basic Usage
96
100
 
97
101
  ### Get a single entity
@@ -114,7 +118,7 @@ for work in results.results:
114
118
  ```python
115
119
  async for work in session.works.iterate(
116
120
  filters={"publication_year": 2024, "is_oa": True},
117
- page_size=200,
121
+ page_size=100,
118
122
  ):
119
123
  print(work.title)
120
124
  break # stop when you want
@@ -127,6 +131,8 @@ citations = await session.queries.citing_works("W2741809801")
127
131
  print(f"{len(citations)} citations")
128
132
  ```
129
133
 
134
+ → **Full guide:** [Usage Basics](https://utsmok.github.io/aletheca/usage_basics/) · [Works](https://utsmok.github.io/aletheca/usage/works/) · [All Entities](https://utsmok.github.io/aletheca/api_reference/)
135
+
130
136
  ## Known OpenAlex API Issues
131
137
 
132
138
  Full bug report with reproduction steps: [`OPENALEX_BUG_REPORT.md`](OPENALEX_BUG_REPORT.md).
@@ -135,7 +141,9 @@ Full bug report with reproduction steps: [`OPENALEX_BUG_REPORT.md`](OPENALEX_BUG
135
141
  - **Wrong field names in spec** -- `content_url` (spec) vs `content_urls` (live), `grants_count` (spec) vs `awards_count` (live)
136
142
  - **Undocumented fields** -- `institution_awarded` on Awards is not documented anywhere; 15+ nested Award filters are missing from the docs filter table
137
143
  - **Awards endpoint missing from `llms.txt`** -- the awards endpoint is not listed in the API quick reference
138
- - **`per_page` max is 200, not 100** -- documented as 100 but the API accepts 200
144
+ - **`per_page` max is 100** -- 200 still works but is deprecated legacy behavior, slated for removal (OpenAlex docs, 2026-08); all examples here use 100
145
+ - **Keyword IDs are slug paths, not short IDs** -- live keyword records carry ids like `https://openalex.org/keywords/photosynthesis`, and the single-record route rejects that full-URL form (nested slashes → HTML 404) even though `/works/https://openalex.org/W…` is accepted. `get()` normalizes both forms.
146
+ - **Awards 400 body is the authoritative filter list** -- the awards endpoint rejects several filters its docs summaries suggest (`funder.country_code`, plain `display_name`, `lead_investigator.id`, `from_/to_*_date`) and its 400 error body enumerates all 40 valid filters, which is more complete than any docs table.
139
147
 
140
148
  ## Development
141
149
 
@@ -0,0 +1,139 @@
1
+ [project]
2
+ name = "aletheca"
3
+ version = "0.2.2"
4
+ description = "Python interface for the OpenAlex API, built on top of the bibliofabric framework."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = ["bibliofabric>=0.5.1,<0.6.0"]
8
+ classifiers = [
9
+ "Development Status :: 3 - Alpha",
10
+ "Programming Language :: Python :: 3",
11
+ "Programming Language :: Python :: 3.12",
12
+ "Programming Language :: Python :: 3.13",
13
+ "Framework :: AsyncIO",
14
+ "Typing :: Typed",
15
+ ]
16
+
17
+ [[project.authors]]
18
+ name = "Samuel Mok"
19
+ email = "s.mok@utwente.nl"
20
+
21
+ [project.license]
22
+ text = "MIT"
23
+
24
+ [project.optional-dependencies]
25
+ analysis = [
26
+ "polars",
27
+ "duckdb>=1.3.0",
28
+ "matplotlib>=3.8.0",
29
+ "rich>=13.0.0",
30
+ "pandas>=2.1.0",
31
+ "numpy>=1.26.0",
32
+ "pyarrow>=14.0.0",
33
+ ]
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/utsmok/aletheca"
37
+
38
+ [dependency-groups]
39
+ dev = [
40
+ "pytest>=8.3.4",
41
+ "pytest-asyncio>=0.26.0",
42
+ "pytest-cov>=6.1.1",
43
+ "pytest-httpx>=0.35.0",
44
+ "python-dotenv>=1.0.0",
45
+ ]
46
+ docs = [
47
+ "mkdocs~=1.6.0",
48
+ "mkdocs-material~=9.5.0",
49
+ "mkdocstrings[python]",
50
+ ]
51
+ lint = ["ruff>=0.8.0"]
52
+ test = [
53
+ "pytest",
54
+ "pytest-randomly",
55
+ ]
56
+
57
+ [build-system]
58
+ requires = ["uv_build>=0.11.19,<0.12"]
59
+ build-backend = "uv_build"
60
+
61
+ [tool.uv.pip]
62
+ generate-hashes = true
63
+
64
+ [tool.ruff]
65
+ line-length = 88
66
+
67
+ [tool.ruff.format]
68
+ docstring-code-format = true
69
+ docstring-code-line-length = 60
70
+
71
+ [tool.ruff.lint]
72
+ select = [
73
+ "E4",
74
+ "E7",
75
+ "E9",
76
+ "F",
77
+ "I",
78
+ "B",
79
+ "Q",
80
+ "PTH",
81
+ "SIM",
82
+ "RET",
83
+ "PIE",
84
+ "FBT",
85
+ "PERF",
86
+ "PL",
87
+ "UP",
88
+ "FURB",
89
+ ]
90
+ ignore = ["PLR2004"]
91
+
92
+ [tool.ruff.lint.isort]
93
+ combine-as-imports = true
94
+
95
+ [tool.ruff.lint.per-file-ignores]
96
+ "__init__.py" = ["F401"]
97
+ "**/client.py" = [
98
+ "PLR0913",
99
+ "PLR0912",
100
+ "PLR0915",
101
+ "PLC0415",
102
+ ]
103
+ "**/session.py" = ["PLC0415"]
104
+ "**/queries.py" = ["PLC0415"]
105
+ "**/endpoints.py" = ["PLR0913"]
106
+ "examples/**/*.py" = [
107
+ "PLC0415",
108
+ "F821",
109
+ "PERF401",
110
+ "B007",
111
+ "F841",
112
+ ]
113
+ "marimo_checks/**/*.py" = [
114
+ "PLC0415",
115
+ "F821",
116
+ "F841",
117
+ "B905",
118
+ "PLW2901",
119
+ "I001",
120
+ "PLR1711",
121
+ "F404",
122
+ "UP037",
123
+ ]
124
+
125
+ [tool.ruff.lint.pylint]
126
+ max-args = 10
127
+ max-branches = 25
128
+ max-statements = 75
129
+ max-returns = 10
130
+
131
+ [tool.pytest.ini_options]
132
+ pythonpath = ["src"]
133
+ testpaths = ["tests"]
134
+ python_files = "test_*.py"
135
+ python_functions = "test_*"
136
+ asyncio_mode = "auto"
137
+ asyncio_default_fixture_loop_scope = "function"
138
+ markers = ["live_api: marks tests that hit the live OpenAlex API (requires API key, skipped in CI)"]
139
+ addopts = "-m 'not live_api'"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aletheca"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "Python interface for the OpenAlex API, built on top of the bibliofabric framework."
5
5
  authors = [
6
6
  {name = "Samuel Mok", email = "s.mok@utwente.nl"}
@@ -9,7 +9,7 @@ readme = "README.md"
9
9
  license = {text = "MIT"}
10
10
  requires-python = ">=3.12"
11
11
  dependencies = [
12
- "bibliofabric>=0.4.2,<0.5.0",
12
+ "bibliofabric>=0.5.1,<0.6.0",
13
13
  ]
14
14
 
15
15
  classifiers = [
@@ -7,7 +7,6 @@ OPENALEX_API_BASE_URL = "https://api.openalex.org"
7
7
  DEFAULT_TIMEOUT: int = 30
8
8
  DEFAULT_RETRIES: int = 3
9
9
  DEFAULT_PAGE_SIZE: int = 25
10
- ITERATE_PAGE_SIZE: int = 200 # OpenAlex allows up to 200 per_page for cursor pagination
11
10
 
12
11
  try:
13
12
  __version__: str = _get_version("aletheca")
@@ -314,25 +314,75 @@ class FundersFilters(BaseModel):
314
314
 
315
315
 
316
316
  class AwardsFilters(BaseModel):
317
- """Filter model for the Awards endpoint."""
317
+ """Filter model for the Awards endpoint.
318
+
319
+ Aliases follow the live API's valid-filter list, which the API
320
+ enumerates in the 400 error returned for invalid fields.
321
+ ``funder.country_code``, ``lead_investigator.id``,
322
+ ``co_lead_investigator.id``, plain ``funder`` and ``display_name``,
323
+ and ``from_/to_*_date`` range filters are NOT valid on this endpoint
324
+ and are absent here; ``extra="allow"`` still lets callers pass
325
+ anything else.
326
+ """
327
+
328
+ id: str | None = None
329
+ doi: str | None = None
330
+ funder_name: str | None = None
331
+ funder_award_id: str | None = None
332
+ funder_scheme: str | None = None
333
+ funding_type: str | None = None
334
+ provenance: str | None = None
335
+ collection: str | None = None
336
+ currency: str | None = None
337
+ amount: float | None = None
338
+ start_year: int | None = None
339
+ end_year: int | None = None
340
+ funded_outputs: str | None = None
341
+ funded_outputs_count: int | None = None
318
342
 
319
- display_name: str | None = None
320
- funder: str | None = None
321
- funder_award_id: str | None = Field(None, alias="funder_award_id")
322
343
  # Nested filter fields (dot notation via alias)
323
344
  funder_id: str | None = Field(None, alias="funder.id")
324
- funder_country_code: str | None = Field(None, alias="funder.country_code")
325
- lead_investigator_id: str | None = Field(None, alias="lead_investigator.id")
326
- co_lead_investigator_id: str | None = Field(None, alias="co_lead_investigator.id")
345
+ funder_ror: str | None = Field(None, alias="funder.ror")
346
+ funder_doi: str | None = Field(None, alias="funder.doi")
347
+ lead_investigator_orcid: str | None = Field(None, alias="lead_investigator.orcid")
348
+ lead_investigator_given_name: str | None = Field(
349
+ None, alias="lead_investigator.given_name"
350
+ )
351
+ lead_investigator_family_name: str | None = Field(
352
+ None, alias="lead_investigator.family_name"
353
+ )
354
+ lead_investigator_affiliation_name: str | None = Field(
355
+ None, alias="lead_investigator.affiliation.name"
356
+ )
357
+ lead_investigator_affiliation_country: str | None = Field(
358
+ None, alias="lead_investigator.affiliation.country"
359
+ )
327
360
  institution_awarded_id: str | None = Field(None, alias="institution_awarded.id")
361
+ institution_awarded_ror: str | None = Field(None, alias="institution_awarded.ror")
362
+ institution_awarded_country_code: str | None = Field(
363
+ None, alias="institution_awarded.country_code"
364
+ )
365
+ institution_awarded_type: str | None = Field(None, alias="institution_awarded.type")
366
+ institution_awarded_lineage: str | None = Field(
367
+ None, alias="institution_awarded.lineage"
368
+ )
369
+ institution_awarded_continent: str | None = Field(
370
+ None, alias="institution_awarded.continent"
371
+ )
372
+ primary_topic_id: str | None = Field(None, alias="primary_topic.id")
373
+ primary_topic_subfield_id: str | None = Field(
374
+ None, alias="primary_topic.subfield.id"
375
+ )
376
+ primary_topic_field_id: str | None = Field(None, alias="primary_topic.field.id")
377
+ primary_topic_domain_id: str | None = Field(None, alias="primary_topic.domain.id")
378
+ topics_id: str | None = Field(None, alias="topics.id")
379
+ topics_subfield_id: str | None = Field(None, alias="topics.subfield.id")
380
+ topics_field_id: str | None = Field(None, alias="topics.field.id")
381
+ topics_domain_id: str | None = Field(None, alias="topics.domain.id")
382
+
328
383
  # Search filters
329
384
  display_name_search: str | None = Field(None, alias="display_name.search")
385
+ description_search: str | None = Field(None, alias="description.search")
386
+ text_search: str | None = Field(None, alias="text.search")
330
387
  default_search: str | None = Field(None, alias="default.search")
331
- # Date filters
332
- from_awarded_date: str | None = Field(None, alias="from_awarded_date")
333
- to_awarded_date: str | None = Field(None, alias="to_awarded_date")
334
- from_created_date: str | None = Field(None, alias="from_created_date")
335
- to_created_date: str | None = Field(None, alias="to_created_date")
336
- from_updated_date: str | None = Field(None, alias="from_updated_date")
337
- to_updated_date: str | None = Field(None, alias="to_updated_date")
338
388
  model_config = ConfigDict(extra="allow", populate_by_name=True)
@@ -1,7 +1,5 @@
1
1
  """Pydantic models for dehydrated (partial) entity representations."""
2
2
 
3
- from typing import Literal
4
-
5
3
  from pydantic import BaseModel, Field
6
4
  from pydantic.config import ConfigDict
7
5
 
@@ -31,7 +29,7 @@ class DehydratedInstitution(BaseEntity):
31
29
  class RelatedInstitution(DehydratedInstitution):
32
30
  """Dehydrated institution with relationship type."""
33
31
 
34
- relationship: Literal["parent", "child", "related", "successor"] | None = None
32
+ relationship: str | None = None
35
33
 
36
34
 
37
35
  class DehydratedInstitutionWithYear(BaseModel):
@@ -52,6 +52,9 @@ def _normalize_id(raw: str, field: str) -> str:
52
52
  return key
53
53
 
54
54
 
55
+ _OPENALEX_ID_PREFIX = "https://openalex.org/"
56
+
57
+
55
58
  # ── Auto-generated batch method factory ────────────────────────────────────
56
59
 
57
60
 
@@ -64,9 +67,7 @@ def _make_batch_getter(field: str) -> Any:
64
67
  *,
65
68
  batch_size: int = BATCH_GET_SIZE,
66
69
  ) -> dict[str, Any]:
67
- return await self.batch_get(
68
- identifiers, field=field, batch_size=batch_size
69
- )
70
+ return await self.batch_get(identifiers, field=field, batch_size=batch_size)
70
71
 
71
72
  return _batch_get_by
72
73
 
@@ -85,14 +86,33 @@ class AlethecaResourceClient(BaseResourceClient):
85
86
  ``batch_get_by_<name>()`` convenience methods.
86
87
  """
87
88
 
88
- _param_page_size: str = "per_page"
89
- _param_sort: str = "sort"
89
+ _param_page_size: str | None = "per_page"
90
+ _param_sort: str | None = "sort"
91
+ #: API route for the entity; set by concrete subclasses (e.g. ``"works"``).
92
+ _entity_path: str
93
+ _entity_model: type[BaseModel] | None = None
94
+ _search_response_model: type[BaseModel] | None = None
90
95
 
91
96
  #: Override in subclasses. Maps ``method_suffix`` → ``filter_field``.
92
97
  #: For example ``{"doi": "doi", "openalex_id": "openalex"}`` produces
93
98
  #: ``batch_get_by_doi()`` and ``batch_get_by_openalex_id()``.
94
99
  _batch_fields: dict[str, str] = {}
95
100
 
101
+ async def get(self, entity_id: str) -> Any:
102
+ """Retrieve one entity by ID (bare ID or full ``openalex.org`` URL).
103
+
104
+ Entity records carry full-URL ids (``https://openalex.org/W123`` or
105
+ slug-keyed ``https://openalex.org/keywords/photosynthesis``), but the
106
+ single-entity route only accepts the key after the entity path.
107
+ DOI/ORCID/ROR URLs are passed through untouched.
108
+ """
109
+ return await GettableMixin.get(self, self._normalize_entity_id(entity_id))
110
+
111
+ def _normalize_entity_id(self, raw: str) -> str:
112
+ """Reduce an entity URL to its route key."""
113
+ key = str(raw).strip().removeprefix(_OPENALEX_ID_PREFIX)
114
+ return key.removeprefix(f"{self._entity_path}/")
115
+
96
116
  def __init_subclass__(cls, **kwargs: Any) -> None:
97
117
  super().__init_subclass__(**kwargs)
98
118
  for suffix, field in getattr(cls, "_batch_fields", {}).items():
@@ -228,7 +248,9 @@ class AlethecaResourceClient(BaseResourceClient):
228
248
  if raw is None and isinstance(entity, dict):
229
249
  raw = entity.get("id")
230
250
  else:
231
- raw = getattr(entity, field, None) if isinstance(entity, BaseModel) else None
251
+ raw = (
252
+ getattr(entity, field, None) if isinstance(entity, BaseModel) else None
253
+ )
232
254
  if raw is None and isinstance(entity, dict):
233
255
  raw = entity.get(field)
234
256
  if raw is None:
@@ -242,7 +264,7 @@ class AlethecaResourceClient(BaseResourceClient):
242
264
 
243
265
 
244
266
  class StandardResourceClient(
245
- GettableMixin, SearchableMixin, CursorIterableMixin, AlethecaResourceClient
267
+ SearchableMixin, CursorIterableMixin, AlethecaResourceClient
246
268
  ):
247
269
  """Base for standard CRUD resource clients that only differ in class attributes.
248
270
 
@@ -5,7 +5,6 @@ from typing import TYPE_CHECKING
5
5
  from bibliofabric.log_config import logger
6
6
  from bibliofabric.resources import (
7
7
  CursorIterableMixin,
8
- GettableMixin,
9
8
  SearchableMixin,
10
9
  )
11
10
 
@@ -16,9 +15,7 @@ if TYPE_CHECKING:
16
15
  from ..client import AlethecaClient
17
16
 
18
17
 
19
- class WorksClient(
20
- GettableMixin, SearchableMixin, CursorIterableMixin, AlethecaResourceClient
21
- ):
18
+ class WorksClient(SearchableMixin, CursorIterableMixin, AlethecaResourceClient):
22
19
  """Client for the OpenAlex Works API endpoint.
23
20
 
24
21
  Supports GET by ID (including DOI/PMID), search, cursor iteration,
File without changes