randomly.facts

randomly.facts

randomly.facts.generate_random_fact(output_format: str, language: str) Union[str, Dict][source]

Fetch a random fact from the Useless Facts API

Parameters
  • output_format ({"html", "json", "txt", "md"}) – Desired format for the returned fact.

  • language ({"en", "de"}) – Desired language for the fact. “en” (English) and “de” (German) supported.

Returns

fact – The result of the query. If output_format=="json", it returns a dictionary. Otherwise, a string is returned.

Return type

Union[str, Dict]

Raises
  • ValueError – When language is not one of {"en", "de"}.

  • ValueError – When output_format not one of {"html", "json", "txt", "md"}.

  • RequestException – When the request response is anything other than a 200 (success).