Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mat1g3r/python-trivia-api
An API wrapper for https://opentdb.com/
https://github.com/mat1g3r/python-trivia-api
api api-wrapper trivia trivia-game trivia-quiz trivia-quiz-game
Last synced: 30 days ago
JSON representation
An API wrapper for https://opentdb.com/
- Host: GitHub
- URL: https://github.com/mat1g3r/python-trivia-api
- Owner: MaT1g3R
- License: mit
- Created: 2017-05-15T04:36:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-15T10:10:35.000Z (over 7 years ago)
- Last Synced: 2024-11-19T00:48:34.959Z (about 1 month ago)
- Topics: api, api-wrapper, trivia, trivia-game, trivia-quiz, trivia-quiz-game
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 6
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
"""
```