Code Monkey home page Code Monkey logo

python-trivia-api's Introduction

Python Trivia API

Install

pip install Python-Trivia-API

Example usage

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

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
    """

python-trivia-api's People

Contributors

mat1g3r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.