BookOps Python wrapper around NYPL Platform API
Requries Python 3.8 & up.
bookops-nypl-platform client provides a Python interface for the internal NYPL Platform API. It provides functionality relevant to BookOps and is not a full implementation of the NYPL Platform API.
0.5.0
Install via pip:
python -m pip install git+https://github.com/BookOps-CAT/bookops-nypl-platform
Access Token
>>>from bookops_nypl_platform import PlatformToken
>>>token=PlatformToken("my_client_id", "my_client_secret", "oauth_server")
>>>print(token)
"<token: token_string_here, expires_on: 2019-01-01 17:59:59, token_request_response: {'access_token': 'token_string_here', 'expires_in': 3600, 'token_type': 'Bearer', 'scope': 'scopes_here', 'id_token': 'token_string_here'}>"
Retrieve bibs by ISBN
>>>from bookops_nypl_platform import PlatformSession
>>>session = PlatformSession(authorization=token, agent="my_client")
>>>response = session.search_standardNos(keywords=["9780316230032", "0674976002"])
>>>print(response.status_code)
200
>>>print(response.json())
{
"data": [
{
"id": "21790265",
"nyplSource": "sierra-nypl",
"nyplType": "bib",
"updatedDate": "2019-07-30T13:38:44-04:00",
"createdDate": "2019-04-24T16:27:41-04:00",
"deletedDate": null,
"deleted": false,
"locations": [
{
"code": "mal",
"name": "SASB - Service Desk Rm 315"
},
{
"code": "mal",
"name": "SASB - Service Desk Rm 315"
}
],
"suppressed": false,
"lang": {
"code": "eng",
"name": "English"
},
"title": "Blueprint : the evolutionary origins of a good society",
"author": "Christakis, Nicholas A. author.",
"materialType": {
"code": "a",
"value": "BOOK/TEXT"
},
}
],
"count": 1,
"totalCount": 0,
"statusCode": 200,
"debugInfo": []
}
Retrieve bibs by control numbers
context manager:
with PlatformSession(authorization=token) as session:
response = session.search_controlNos([["1089804986", "1006480637"]])
0.5.0 - 2024-11-25
.flake8
file to ignore line length and unused import errors in tests- Python versions 3.11, 3.12, and 3.13 to GitHub Actions
BookopsPlatformError
as top level importpy.typed
file so applications usingbookops-nypl-platform
will use annotations from this package- added type annotations where they were missing and fixed them where they were incomplete or inaccurate
- type annotations to variables in
PlatformSession
methods where needed - Dev dependencies:
exceptiongroup
(1.2.2)
- updated GitHub checkout and setup actions in automated tests (
unit-tests.yaml
) if type() is
type check syntax changed toisinstance
type checks- target python version in
pyproject.toml
now 3.8-3.13 - Updated dependencies:
certifi
(2024.8.30)charset-normalizer
(3.4.0)idna
(3.10)requests
(2.32.3)urllib3
(2.2.3)
- Updated dev dependencies:
black
(24.8.0)coverage
(7.6.1)packaging
(24.2)pathspec
(0.12.1)platformdirs
(4.3.6)pluggy
(1.5.0)pytest-cov
(5.0.0)pytest-mock
(3.14.0)pytest
(8.3.3)tomli
(2.1.0)typing-extensions
(4.12.2)
- default value for
PlatformToken.timeout
andPlatformSession.timeout
is now(3,3,)
. Removed conditional check from__init__.py
for both classes that set thetimeout
value iftimeout
wasNone
- typo in docstring of
authorize.py
- changed names of variables in
PlatformSession
methods where they were the same as names of a param passed to that method. Certain variables have different types than the params with the same name which caused errors with the type checker. Seekeywords
param/variable inPlatformToken.search_standardNos
andkeyword
/standardNos
variable
- support for Python 3.7
Type
no longer used in type annotations- implicit optional types changed to explicit
Optional
withNone
as default value - Dev dependencies:
mike
mkdocs
mkapi
pytest.ini
file. Moved topytest.ini_options
inpyproject.toml
0.4.0 - 2023-12-28
conftest.py
updated path to credentials- dependencies:
- certifi (2023.11.17)
- requests (2.31.0)
- dev dependencies:
- black (22.12.0)
- mike (0.5.5)
- mkapi (1.0.14)
- mkdocs (1.5.3)
- pytest (6.2.5)
- pytest-cov (2.12.1)
- pytest-mock (3.11.1)
0.3.0 - 2022-02-05
- Dependencies update:
- requests to 2.27.1
- urllib3 to 1.26.8
- dev dependencies update
- CI moved to Github-Actions
- adds Python 3.10
0.2.1 - 2021-10-29
- Metadata fixes in pyproject.toml to indicate the client supports Python 3.7
- Dependencies updates
0.2.0 - 2020-10-27
- /v0.1/items
get_item_list
a method to retrieve a list of item records