An asynchronous wrapper for the Open Trivia DB API.
Project description
OpenTriviaDB
An asynchronous wrapper for the Open Trivia DB API.
This is an unofficial wrapper, and is not affiliated with PIXELTAIL GAMES LLC.
Installation
To install the latest stable version of OpenTriviaDB, use the following command:
pip install opentriviadb
You can also install the latest development version using the following command:
pip install git+https://github.com/parafoxia/opentriviadb
You may need to prefix these commands with a call to the Python interpreter depending on your OS and Python configuration.
Usage
Before you can pull questions from the API, you first need to create a client:
from opentriviadb import Client
client = Client()
# You can also use the client via a context manager.
async with Client() as client:
...
To prevent duplicate questions being pulled, request a session token:
await client.request_token()
You can now run a round of trivia!
Questions are yielded one at a time when needed, though you can use the list()
built-in function if you need them all available at once.
See the Question
docs for more information.
async for q in client.round():
# Yields `Question` objects.
...
Once you're done, you need to tear the client down:
await client.teardown()
If you use the client via the context manager, the teardown method is called automatically.
Contributing
Contributions are very much welcome! To get started:
- Familiarise yourself with the code of conduct
- Have a look at the contributing guide
License
The OpenTriviaDB module for Python is licensed under the BSD 3-Clause License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file opentriviadb-0.1.0.tar.gz
.
File metadata
- Download URL: opentriviadb-0.1.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 736bf22b6bd36cc610f3b5efff817c9bb99e2efc282c216f28fddd9e741a030f |
|
MD5 | 3c39b3b30e72498a99075bca25e813d9 |
|
BLAKE2b-256 | 80670dc3a990a7e39e62931c10ae5367437da77ff2822bcc400b67f417f1421e |
File details
Details for the file opentriviadb-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: opentriviadb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | caced55629aba025816d5b70c25a74cfeec2f4f3d3dca982991dbd564ec6c7cd |
|
MD5 | 85dc74beb8e5424ee3306b8a75285297 |
|
BLAKE2b-256 | 8293351d9242a18d81377af9d56361e9107b97eed96d5a3687776790724f9dac |