Open Trivia DB Bug

First, I commend all those involved in creating/maintaining this API, very cool and works extremely well!

The bug I identified is when an API call is made (without a token) that results in a response code 1, the same API call made WITH a valid token results in a response code 4. This is ambiguous, since resetting a token and trying again will have the same response code 4 (endless loop). A response code 1 could be handled by requesting the user to relax constraints.

– e.g. –
https://opentdb.com/api.php?amount=50&category=9&difficulty=easy&type=boolean
– vs. –
https://opentdb.com/api.php?amount=50&category=9&difficulty=easy&type=boolean&token=VALIDTOKEN

What I expected to happen

A response code of 1

What happened

A response code of 4


Notes / Media

Other misc notes about the bug. Picture or videos would be much appreciated!

2 Likes

Hello.

This is not a bug.

Response Code 1 is only returned when not using a Session Token.
When using a Session Token, Response Code 4 is returned if the request is unable to be satisfied.

The proper loop would be to request questions from the API with a token. If the response code is 4, then a request to reset the Session Token should be executed, followed by another attempt to get questions.

2 Likes