QuizBang
The quiz question database anyone can edit.
about
contact
privacy
question stats
forums
daily quiz (rss)


Quizbang Web Services

QuizBang's Web Services (QWS) allow direct access to QuizBang's database from virtually any other internet-connected device. In time, you will be able to use our web services to retrieve questions and answers, retrieve tags, check answers, and more... but for now, you can either retrieve questions and answers, a list of active tags. There's no need to register first, QuizBang's database is open for any use.

All QWS services are accessed from the URL http://www.quizbang.co.uk/cgi-bin/fetch.pl, but don't try that on its own - you need to add extra information in the form of parameters on the URL. The most important parameter is 'command' which tells QWS which particular web service you want to access. Depending on the command you specify, you'll probably want to specify extra parameters too.

An important parameter is 'format' which specifies how you'd like the data returned to you. This defaults to XML but can also be set to JSON; other formats may become available in the future, so let us know if you have a preference.

Example

To retrieve ten questions (and their answers) at random from the QuizBang database, use the command 'questions' and the additional parameter 'num' set to '10':

http://www.quizbang.co.uk/cgi-bin/fetch.pl?command=questions&num=10

You can click that link to retrieve a random set of ten questions right now!

In general, you won't retrieve that URL yourself in a browser, you'll use it in some other software to retrieve the questions and use them for your own purposes. Describing how to do that in all the myriad possible ways is beyond the scope of this article, but if you're reading this you probably already know what your next steps should be.

For more information, you could start with this Wikipedia article on web services.

Reference

For now, QWS only supports three commands, but many more will be added soon so please check back.

CommandParametersDescription
help None Returns a brief message (in the 'response' tag) directing users to this page.
questions num: Number of questions to retrieve.
Example: 10
Default: 9999.

tags: A dot-delimited list of valid QuizBang tags; only questions tagged with all supplied tags will be retrieved.
Example: us.sport
Default: null

format: Selects the format for the returned data; supported values are XML and JSON. Case-insensitive.
Example: json
Default: xml
Returns a random selection of (no more than) num questions, and their answers, from the database. For each question, the first answer is the correct one.

Only questions matching tags will be returned; note that for many tags, or combinations of tags, the returned set may contain fewer than num questions.

Multiple tags should be separated with a dot, so the three-tag combination 'music', 'uk' and '80s' would be passed as 'tags=music.uk.80s'.

The questions will be returned in either XML or JSON format, according to the setting of 'format'. XML is the default.
tags None Returns the list of active tags - there is at least one question in the database for each tag in this list. The returned tags can be used alone or in combination on a 'commands=questions' request.


Site design and programming by Oceanview Consultancy Ltd.