Skip to main content

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:

License

The OpenTriviaDB module for Python is licensed under the BSD 3-Clause License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opentriviadb-0.1.0.tar.gz (9.5 kB view hashes)

Uploaded Source

Built Distribution

opentriviadb-0.1.0-py3-none-any.whl (11.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page