Skip to main content

An API wrapper for opentdb

Project description

# Python Trivia API
## Install
```
pip install Python-Trivia-API
```

## Example usage
```Python
from pytrivia import Category, Diffculty, Type, Trivia
my_api = Trivia(True)
response = my_api.request(2, Category.Books, Diffculty.Hard, Type.True_False)
print(response)
```

## Full method signature
```Python
def request(self, num_questions: int, category: Category = None,
diffculty: Diffculty = None, type_: Type = None):
"""
Send an api request to https://opentdb.com/
Limitations:
Only 1 Category can be requested per API Call.
To get questions from any category, don't specify a category.
A Maximum of 50 Questions can be retrieved per call.

:param num_questions: the number of questions,
must be between 1 and 50 (inclusive)

:param category: the category of the question. None for any category

:param diffculty: the diffculty of the question. None for any diffculty

:param type_: the type of the question. None for any type

:return: the api call response

:rtype: dict

:raises: ValueError when the num_questions parameter is less than 1
or greater than 50
"""
```

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

Python-Trivia-API-4.0.1.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file Python-Trivia-API-4.0.1.tar.gz.

File metadata

File hashes

Hashes for Python-Trivia-API-4.0.1.tar.gz
Algorithm Hash digest
SHA256 33ed5b719eda2a0ba3f2c333bc73f57ff0708c1f2495b01cdd85e7098b07aeea
MD5 5cf6e66c18f3886dd902fb8c47614421
BLAKE2b-256 1e443b62db3724c72bbaeaa876e9a9abee1b769457fc95766d999f84a7decda1

See more details on using hashes here.

Supported by

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