|
1 | | -# QBreader Python API wrapper module |
2 | | -Accessing the QBreader API with a python wrapper module. |
3 | | - |
4 | | -## Documentation |
5 | | - |
6 | | -#### Get a list of sets from the QBreader database |
7 | | - |
8 | | -``` |
9 | | - set_list() |
10 | | -``` |
11 | | - |
12 | | -This function gets a list of sets from the QBreader database. |
13 | | - |
14 | | -#### Search the QBreader database |
15 | | - |
16 | | -``` |
17 | | - query() |
18 | | -``` |
19 | | -This function searches the QBreader database for questions that match the parameters specified. |
20 | | - |
21 | | -| Parameter | Type |Values| Description | |
22 | | -| :-------- | :------- |:----------|:------------------------- | |
23 | | -| `questionType` | `string` |`tossup`, `bonus`, `all`| The type of question to search for. Defaults to "all". If one of the three is not set, returns a 400 Bad Request. | |
24 | | -| `searchType` | `string` |`question`, `answer`| The type of search to perform. Defaults to "all". If one of the three is not set, returns a 400 Bad Request. | |
25 | | -| `queryString` | `string` |Any string.| The string to search for. Defaults to "". | |
26 | | -| `regex` | `bool` |`True`, `False`| Whether or not to use regular expressions for the queryString. Defaults to "False". | |
27 | | -| `randomize` | `bool` |`True`, `False`| Whether or not to randomize the order of the results. Defaults to "False". | |
28 | | -| `setName` | `string` |Any string| The difficulties to search for. Defaults to []. Leave as an empty list to search all. Must be a list of ints from 1 to 10. | |
29 | | -| `difficulties` | `list`|`[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]`| The string to search for. Defaults to "". | |
30 | | -| `categories` | `list` |See https://pastebin.com/McVDGDXg for a full list.| The categories to search for. Defaults to []. Leave as an empty list to search all. | |
31 | | -| `subcategories` | `list` |See https://pastebin.com/McVDGDXg for a full list.| The subcategories to search for. Defaults to []. Leave as an empty list to search all. | |
32 | | -| `maxQueryReturnLength` | `int` |Any integer. | The maximum number of questions to return. Defaults to None. Leave blank to return 50. Anything over 200 will not work. | |
33 | | - |
34 | | - |
35 | | -#### Get a random question from the QBreader database |
36 | | - |
37 | | -``` |
38 | | - random_question() |
39 | | -``` |
40 | | -This function gets a random question from the QBreader database. |
41 | | - |
42 | | -| Parameter | Type |Values| Description | |
43 | | -| :-------- | :------- |:----------| :------------------------- | |
44 | | -| `questionType` | `string` |`tossup`, `bonus`| The type of question to search for (tossup or bonus). If one of the two is not set, returns a 400 Bad Request. | |
45 | | -| `difficulties` | `list` |`[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]`| The string to search for. Defaults to "". | |
46 | | -| `categories` | `list` |See https://pastebin.com/McVDGDXg for a full list.| The categories to search for. Defaults to []. Leave as an empty list to search all. | |
47 | | -| `subcategories` | `list` |See https://pastebin.com/McVDGDXg for a full list.| The subcategories to search for. Defaults to []. Leave as an empty list to search all. | |
48 | | -| `number` | `int` |Any integer. | The number of questions to return. Defaults to None. Leave blank to return 1.| |
49 | | - |
50 | | -#### Generate a random name |
51 | | - |
52 | | -``` |
53 | | - random_question() |
54 | | -``` |
55 | | -This function Generates an adjective-noun pair (used in multiplayer lobbies) |
56 | | - |
57 | | -#### Get questions from a packet from the QBreader database |
58 | | - |
59 | | -``` |
60 | | - packet() |
61 | | -``` |
62 | | -This function gets questions from a packet from the QBreader database. |
63 | | - |
64 | | -| Parameter | Type | Values |Description | |
65 | | -| :-------- | :------- | :---------|:------------------------- | |
66 | | -| `setName` | `string` |Names of sets can be obtained by running set_list()| The name of the set to search. Can be obtained from set_list().| |
67 | | -| `packetNumber` | `int` |Any integer that corresponds to a packet number, usually from 1-11.|The number of the packet to search for.| |
68 | | - |
69 | | -#### Get a packet's tossups from the QBreader database |
70 | | - |
71 | | -``` |
72 | | - packet_tossups() |
73 | | -``` |
74 | | -This function gets a packet's tossups from the QBreader database. Twice as fast as using packet(). |
75 | | - |
76 | | -| Parameter | Type | Values |Description | |
77 | | -| :-------- | :------- | :---------|:------------------------- | |
78 | | -| `setName` | `string` |Names of sets can be obtained by running set_list()| The name of the set to search. Can be obtained from set_list().| |
79 | | -| `packetNumber` | `int` |Any integer that corresponds to a packet number, usually from 1-11.|The number of the packet to search for.| |
80 | | - |
81 | | -#### Get a packet's bonuses from the QBreader database |
82 | | - |
83 | | -``` |
84 | | - packet_bonuses() |
85 | | -``` |
86 | | -This function gets a packet's bonuses from the QBreader database. Twice as fast as using packet(). |
87 | | - |
88 | | -| Parameter | Type | Values |Description | |
89 | | -| :-------- | :------- | :---------|:------------------------- | |
90 | | -| `setName` | `string` |Names of sets can be obtained by running set_list()| The name of the set to search. Can be obtained from set_list().| |
91 | | -| `packetNumber` | `int` |Any integer that corresponds to a packet number, usually from 1-11.|The number of the packet to search for.| |
92 | | - |
93 | | -#### Get the number of packets in a set from the QBreader database |
94 | | - |
95 | | -``` |
96 | | - packet_bonuses() |
97 | | -``` |
98 | | -This function gets the number of packets in a set from the QBreader database |
99 | | - |
100 | | -| Parameter | Type | Values |Description | |
101 | | -| :-------- | :------- | :---------|:------------------------- | |
102 | | -| `setName` | `string` |Names of sets can be obtained by running set_list()| The name of the set to search. Can be obtained from set_list().| |
103 | | - |
104 | | - |
105 | | -#### Report a question from the QBreader database |
106 | | - |
107 | | -``` |
108 | | - report_question() |
109 | | -``` |
110 | | -This function reports a question from the QBreader database. |
111 | | - |
112 | | -| Parameter | Type |Values| Description | |
113 | | -| :-------- | :------- |:------| :------------------------- | |
114 | | -| `_id` | `string` |Can be obtained from the `query()`, `random_question`, `packet()`, `packet_bonuses`, or `packet_tossups`.| The ID of the question to report.| |
115 | | -| `reason` | `string` |N/A| The reason for reporting the question. Defaults to None. | |
116 | | -| `description` | `string` |N/A| A description of the reason for reporting the question. Defaults to None.| |
117 | | - |
118 | | -#### Get a list of rooms from the QBreader database |
119 | | - |
120 | | -``` |
121 | | - room_list() |
| 1 | +# qbreader/python-module |
| 2 | + |
| 3 | +[](https://pypi.org/project/qbreader/) |
| 4 | +[](https://pypi.org/project/qbreader/) |
| 5 | +[](https://pypi.org/project/qbreader/) |
| 6 | +[](https://github.com/qbreader/python-module/actions/workflows/test.yml) |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## Introduction |
| 11 | + |
| 12 | +`qbreader` is a Python wrapper to the qbreader API as well as a general quizbowl library. It provides |
| 13 | +both asynchronous and synchronous interfaces to the API along with functionality for representing questions. |
| 14 | + |
| 15 | +```py |
| 16 | +>>> from qbreader import Sync as qbr # synchronous interface |
| 17 | +>>> tossup = qbr.random_tossup()[0] |
| 18 | +>>> tossup.question |
| 19 | +'Tim Peters wrote 19 “guiding principles” of this programming language, which include the maxim “Complex is better than complicated.” The “pandas” library was written for this language. Unicode string values had to be defined with a “u” in version 2 of this language. Libraries in this language include Tkinter, Tensorflow, (*) NumPy (“numb pie”) and SciPy (“sigh pie”). The framework Django was written in this language. This language uses “duck typing.” Variables in this language are often named “spam” and “eggs.” Guido van Rossum invented, for 10 points, what programming language named for a British comedy troupe?' |
| 20 | +>>> tossup.answer |
| 21 | +'Python' |
| 22 | +>>> tossup.category |
| 23 | +<Category.SCIENCE: 'Science'> |
| 24 | +>>> tossup.subcategory |
| 25 | +<Subcategory.OTHER_SCIENCE: 'Other Science'> |
| 26 | +>>> tossup.difficulty |
| 27 | +<Difficulty.HS_HARD: '4'> |
| 28 | +>>> tossup.set |
| 29 | +'2022 Prison Bowl' |
| 30 | +>>> (tossup.packet_number, tossup.question_number) |
| 31 | +(4, 20) |
122 | 32 | ``` |
123 | | -This function gets a list of rooms from the QBreader database. |
0 commit comments