# OpenTriviaDB
An asynchronous wrapper for the [Open Trivia DB](https://opentdb.com/) API.
This is an unofficial wrapper, and is not affiliated with [PIXELTAIL GAMES LLC.](https://www.pixeltailgames.com/)
## Installation
To install the latest stable version of OpenTriviaDB, use the following command:
```sh
pip install opentriviadb
```
You can also install the latest development version using the following command:
```sh
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:
```py
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:
```py
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`](./questions) docs for more information.
```py
async for q in client.round():
# Yields `Question` objects.
...
```
Once you're done, you need to tear the client down:
```py
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](https://github.com/parafoxia/opentriviadb/blob/main/CODE_OF_CONDUCT.md)
* Have a look at the [contributing guide](https://github.com/parafoxia/opentriviadb/blob/main/CONTRIBUTING.md)
## License
The OpenTriviaDB module for Python is licensed under the [BSD 3-Clause License](https://github.com/parafoxia/opentriviadb/blob/main/LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/parafoxia/opentriviadb",
"name": "opentriviadb",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.0,<3.13",
"maintainer_email": "",
"keywords": "",
"author": "Ethan Henderson",
"author_email": "ethan.henderson.1998@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/80/67/0dc3a990a7e39e62931c10ae5367437da77ff2822bcc400b67f417f1421e/opentriviadb-0.1.0.tar.gz",
"platform": null,
"description": "# OpenTriviaDB\n\nAn asynchronous wrapper for the [Open Trivia DB](https://opentdb.com/) API.\n\nThis is an unofficial wrapper, and is not affiliated with [PIXELTAIL GAMES LLC.](https://www.pixeltailgames.com/)\n\n## Installation\n\nTo install the latest stable version of OpenTriviaDB, use the following command:\n\n```sh\npip install opentriviadb\n```\n\nYou can also install the latest development version using the following command:\n\n```sh\npip install git+https://github.com/parafoxia/opentriviadb\n```\n\nYou may need to prefix these commands with a call to the Python interpreter depending on your OS and Python configuration.\n\n## Usage\n\nBefore you can pull questions from the API, you first need to create a client:\n\n```py\nfrom opentriviadb import Client\n\nclient = Client()\n\n# You can also use the client via a context manager.\nasync with Client() as client:\n ...\n```\n\nTo prevent duplicate questions being pulled, request a session token:\n\n```py\nawait client.request_token()\n```\n\nYou can now run a round of trivia!\nQuestions 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.\nSee the [`Question`](./questions) docs for more information.\n\n```py\nasync for q in client.round():\n # Yields `Question` objects.\n ...\n```\n\nOnce you're done, you need to tear the client down:\n\n```py\nawait client.teardown()\n```\n\nIf you use the client via the context manager, the teardown method is called automatically.\n\n## Contributing\n\nContributions are very much welcome!\nTo get started:\n\n* Familiarise yourself with the [code of conduct](https://github.com/parafoxia/opentriviadb/blob/main/CODE_OF_CONDUCT.md)\n* Have a look at the [contributing guide](https://github.com/parafoxia/opentriviadb/blob/main/CONTRIBUTING.md)\n\n## License\n\nThe OpenTriviaDB module for Python is licensed under the [BSD 3-Clause License](https://github.com/parafoxia/opentriviadb/blob/main/LICENSE).\n",
"bugtrack_url": null,
"license": "BSD 3-Clause 'New' or 'Revised' License",
"summary": "An asynchronous wrapper for the Open Trivia DB API.",
"version": "0.1.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "85dc74beb8e5424ee3306b8a75285297",
"sha256": "caced55629aba025816d5b70c25a74cfeec2f4f3d3dca982991dbd564ec6c7cd"
},
"downloads": -1,
"filename": "opentriviadb-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "85dc74beb8e5424ee3306b8a75285297",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.0,<3.13",
"size": 11179,
"upload_time": "2022-12-01T16:03:38",
"upload_time_iso_8601": "2022-12-01T16:03:38.231100Z",
"url": "https://files.pythonhosted.org/packages/82/93/351d9242a18d81377af9d56361e9107b97eed96d5a3687776790724f9dac/opentriviadb-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "3c39b3b30e72498a99075bca25e813d9",
"sha256": "736bf22b6bd36cc610f3b5efff817c9bb99e2efc282c216f28fddd9e741a030f"
},
"downloads": -1,
"filename": "opentriviadb-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "3c39b3b30e72498a99075bca25e813d9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.0,<3.13",
"size": 9470,
"upload_time": "2022-12-01T16:03:40",
"upload_time_iso_8601": "2022-12-01T16:03:40.337599Z",
"url": "https://files.pythonhosted.org/packages/80/67/0dc3a990a7e39e62931c10ae5367437da77ff2822bcc400b67f417f1421e/opentriviadb-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-01 16:03:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "parafoxia",
"github_project": "opentriviadb",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "opentriviadb"
}