API Docs

General Usage of API

The facts about Rajinikanth are available at:

JSON Response

The default format of the JSON response is as follows. There are 2 keys in the JSON.

  • status - if all good you will get the status as "OK"
  • resultSet - the second key in the JSON consists of multiple keys again out of which
    • data - would have the complete list of facts as an array. Each fact in the data array consists of:
      • id: a unique id for each joke
      • fact: The fact about Rajinikanth
      • categories: The categories to which the fact belongs
      • source: Sources where this fact was found.
    • total_facts - This give the total number of facts which are in the Database. This number ought to be changed since the cleaning of facts and removal of duplicates is in process on a daily basis.
    "status": "OK",
    "resultSet": {
        "current_page": 1,
        "data": [{
            "db_id": 2,
            "fact": "MacGyver can build an airplane out of gum and paper clips. Rajinikanth can kill him and take it.",
            "id": "1374b06cee815c14f370579d43bef434",
            "categories": ["celebrity"],
            "sources": ["", ""]
        }, ....
        "first_page_url": "http:\/\/\/facts?page=1",
        "from": 1,
        "last_page": 18,
        "last_page_url": "http:\/\/\/facts?page=18",
        "next_page_url": "http:\/\/\/facts?page=2",
        "path": "http:\/\/\/facts",
        "per_page": 15,
        "prev_page_url": null,
        "to": 15,
        "total": 266,
        "notes": "The fact belonging to categories \"nsfw\" & \"explicit\" are excluded by default. If you want to get those you will have to send these categories in \"limitFactsTo\"."

Random Fact

You can use the following API call to fetch the random fact of the database. Note: Although this API endpoint returns a single fact, still the data in a resultSet would be an array.

Optional Parameters

All the following optional parameters work when used together for normal API call to fetch the facts or to fetch the random fact or an API call with the callback.

Using callback functions

You can even pass the callback method in the URL and the complete result of the call would be passed to you as an argument.

Changing the name

Although its a foolish idea to replace your name with the Rajinikanth's name, but till he finds it out, you can take benefit of this feature. You can change name by simply passing 2 parameters firstName & lastName. This works for the normal API call to fetch the facts and even for the API call to fetch random facts. For this to work both the parameters firstName & lastName needs to be passed if any of this parameter is missing - Rajinikanth will take over.

Fetching number of facts in a single call

By default the facts API call return 10 facts & the random API call returns single fact. But you can overcome the limitations by passing the optional query parameter to the api call limit. // this wont support returning more than one fact in response

Next "n" number of facts

Once you have fetched the first n number of facts, you can fetch the next n facts by passing the page parameter in combination with the limit parameter // first 5 facts - 0 to 5 // next 5 facts - 6 to 10

Categories & Facts filtered by categories

To fetch the categories under which the facts are mapped to

Response JSON would be in the format as follows

    "status": "OK",
    "resultSet": {
        "data": [..., "geeky", ...]

You can fetch the facts belonging to particular category by passing the optional parameter limitFactsTo and passing the category names comma separated,religion

You can also exclude the facts belonging to particular category by passing the parameter excludeFactsFrom and passing comma separated category names