thestorygraph-client
A Simple Python Client for TheStoryGraph.com
Sync and async clients as well as a model abstraction layer for the website.
Since no public API is available, this library parses HTML via BeautifulSoup4
and loads the data into model objects.
Installation
pip install thestorygraph-client
Examples
Search for books (sync)
Find and print books related to 'SPQR':
from tsg.client import SyncTSGClient
def print_search_result(search_text: str) -> None:
client = SyncTSGClient()
book_list = client.search(text=search_text)
for book in book_list:
print(f'{book.authors[0].name} - {book.title}')
print_search_result('SPQR')
Search for books (async)
Same as above, but using the asynchronous client:
import asyncio
from tsg.client import AsyncTSGClient
async def print_search_result(search_text: str) -> None:
client = AsyncTSGClient()
book_list = await client.get_browse(text=search_text)
for book in book_list:
print(f'{", ".join(book.author_names)} - {book.title}')
asyncio.run(print_search_result('SPQR'))
The two clients have identical APIs (beside the fact that the latter is async).
Get a book by ID
import asyncio
from tsg.client import AsyncTSGClient
async def print_book_by_id(book_id: str) -> None:
client = AsyncTSGClient()
book = await client.get_book(id=book_id)
print(f'{book.title} by {", ".join(book.author_names)}')
asyncio.run(print_book_by_id('79b894b0-df12-4bb6-89d7-40288f28acc1'))
Development and Testing
Configuring the test environment
Install
pip install -Ue .[testing]
Testing
Run the tests:
pytest tests
And always validate typing:
mypy src/tsg
Or simply
make test
(it will run all test commands)
Links
Homepage on GitHub: https://github.com/altvod/thestorygraph-client
Project's page on PyPi: https://pypi.org/project/thestorygraph-client/
TheStoryGraph: https://thestorygraph.com/
Metadata
Release files for thestorygraph-client 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| thestorygraph-client-0.1.6.tar.gz | 5.7 kB | Without provenance | Details for thestorygraph-client-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| thestorygraph_client-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for thestorygraph_client-0.1.6-py3-none-any.whl |
Total release size: 13.4 kB
Release files / thestorygraph-client-0.1.6.tar.gz
| Download URL | thestorygraph-client-0.1.6.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f372bb63f5e172d69cec4a588a74ce16cd97212936847d668b75d4eff4c33be4
|
|
BLAKE2b-256 checksum How to use checksums |
39136a25628fab2107ad864efa653262c6fd72d2019baaf8c3a6d99902f39d26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Release files / thestorygraph_client-0.1.6-py3-none-any.whl
| Download URL | thestorygraph_client-0.1.6-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c1afa730a3a1d659cea86f147df0bb840c3fae8b22e5c3a3fa21295100d122e
|
|
BLAKE2b-256 checksum How to use checksums |
ba05ceee7f560d16413ee4c375eaa3f6167ab43e9ed6ae533411999f256078d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Security for thestorygraph-client 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.