IRKFDB.IN

API Docs

General Usage of API

The facts about Rajinikanth are available at:

    https://api.irkfdb.in/facts

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": ["api.icndb.com", "api.chucknorris.io"]
        }, ....
        ],
        "first_page_url": "http:\/\/api.irkfdb.in\/facts?page=1",
        "from": 1,
        "last_page": 18,
        "last_page_url": "http:\/\/api.irkfdb.in\/facts?page=18",
        "next_page_url": "http:\/\/api.irkfdb.in\/facts?page=2",
        "path": "http:\/\/api.irkfdb.in\/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.

https://api.irkfdb.in/facts/random

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.

https://api.irkfdb.in/facts?callback=someJsFunction

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.

https://api.irkfdb.in/facts?firstName=Chuck&lastName=Norris
https://api.irkfdb.in/facts/random?firstName=Chuck&lastName=Norris

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.

https://api.irkfdb.in/facts?limit=5
https://api.irkfdb.in/facts/random // 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

https://api.irkfdb.in/facts?limit=5 // first 5 facts - 0 to 5
https://api.irkfdb.in/facts?limit=5&page=2 // next 5 facts - 6 to 10

Categories & Facts filtered by categories

To fetch the categories under which the facts are mapped to

https://api.irkfdb.in/facts/categories

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

https://api.irkfdb.in/facts?limitFactsTo=geeky
https://api.irkfdb.in/facts?limitFactsTo=geeky,religion

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

https://api.irkfdb.in/facts?excludeFactsFrom=nsfw