A full fledged facts API, one of the best in the world. Get random facts based on a category, drawn from hundreds of thousands of fact entries in our database. To provide finer granularity subcategory is also supported. You can store private facts and retrive them back. On this day style historic facts are supported too.
Looking for a simple yet powerful way to add engaging content to your app, website, or chatbot? The Fun Facts API delivers an endless supply of intriguing, surprising, and entertaining facts across a variety of categories. Whether you're building an educational app, a social media bot, or a daily fun-fact feature, this API has you covered!
✅ Developers – Enhance apps with bite-sized, interesting content.
✅ Marketers – Increase engagement on social media and newsletters.
✅ Educators – Make learning more fun and interactive.
✅ Chatbot Creators – Keep users entertained with automated fun facts.
The end point for connecting : If you subscribe directly from us use this endpoint.
https://api.fungenerators.com
GET /fact/random
If you are using curl the request will look something like this. The parameters categroy and subcategory are optional.
curl -X GET "http://api.fungenerators.com/fact/random?category=Countries&subcategory=USA" -H "accept: application/json" -H "Authorization: Bearer <api_key>"
The above should generate a response like below
{
"success": {
"total": 1
},
"contents": {
"fact": "The most iconic donut shop in Hollywood is Randy's Donuts. It has appeared in many movies including Crocodile Dundee and Iron Man 2.",
"id": "VbUC4jKvaxzHNgs2FRUthweF",
"category": "Food ",
"subcategory": "Donuts "
}
}
GET /fact/search
If you are using curl the request will look something like this. The parameter 'query' is mandatory while the parameters categroy and subcategory are optional.
curl -X GET "http://api.fungenerators.com/fact/search?query=Amazon" -H "accept: application/json" -H "Authorization: Bearer <api_key>"
The response will have the structure like below.
{
"success":{"total":1},
"contents":{
"fact":"There are more than 1,100 known tributaries flowing into the Amazon River. Tributaries are sources of water such as a small river, stream or other water flow that reaches the river.",
"id":"LCN5KlSn6BMpcm3ruXhfGweF",
"category": "Rivers",
"subcategory": "Amazon River"
}
}
Use put on /fact end point to create a new fact entry. This will be your in your private collection and you can retrieve it later.
PUT /fact
curl -X PUT "http://api.fungenerators.com/fact?fact=January%2020th%20is%20the%20day%20in%201941%20that%20a%20Nazi%20officer%20is%20murdered%20in%20Bucharest%2C%20Romania%2C%20sparking%20a%20rebellion%20and%20pogrom%20by%20the%20Iron%20Guard%2C%20killing%20125%20Jews%20and%2030%20soldiers.&category=Numbers&subcategory=Date&tags=numbers%2C%20historical" -H "accept: application/json" -H "Authorization: Bearer api_key"
Upon success the id of the newly created fact is returned in the response.
{
"success": {
"total": 1
},
"contents": {
"id": "62D6iKM9GSlJxK5nrMf9XwrE"
}
}
GET /fact
curl -X GET "http://api.fungenerators.com/fact?id=LCN5KlSn6BMpcm3ruXhfGweF" -H "accept: application/json" -H "Authorization: Bearer <api_key>"
If there is a fact entry with the id in the system, it will be returned in the response.
{
"success":{"total":1},
"contents":{
"fact":"There are more than 1,100 known tributaries flowing into the Amazon River. Tributaries are sources of water such as a small river, stream or other water flow that reaches the river.",
"id":"LCN5KlSn6BMpcm3ruXhfGweF",
"category": "Rivers",
"subcategory": "Amazon River"
}
}
DELETE /fact
In curl this request will look something like this
curl -X DELETE "http://api.fungenerators.com/fact?id=uHBbOfP7ECfVkeQrE" -H "accept: application/json" -H "Authorization: Bearer <api_key>"
{
"success": {
"total": 1
},
"contents": {
"mesg": "Fact uHBbOfP7ECfVkeQrE is deleted"
}
}
To get a random hsitoric event on a given day ( defaults to current day ) use the following endpoint.
GET /fact/onthisday/event
The above call should produce something like the following
{
"success": {
"total": 1
},
"contents": {
"id": "KVlPpVL119DtLFtphgOxqQeF",
"day": "26",
"month": "8",
"year": "1883",
"date": "1883-8-26",
"event_type": "event",
"event": "The Indonesian island of Krakatoa erupts in the largest explosion recorded in history, heard 2,200 miles away in Madagascar."
}
}
Some of our API calls may be public(requires free API key) , while others requires paid subscription. To maintain our serice levels both public and private API endpoints are ratelimited. Please consult your specific plan that you subscribed to for the rate limit details.
Currently we support API Key based authentication. Please set your Autorization Bearer request header with value of your API key. Alternatively you can also pass api_key= as a request parameter, though we strongly discourage this mode of passing the key, since it will allow others to see your key.
In curl this would mean sending the Authorization header like below.
curl -i <url> -H "Authorization: Bearer <api_key>"
If you are using PHP.
$authorization = "Authorization: Bearer <api_key>";
$ch = curl_init('<url>'); // Initialise cURL
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $authorization ));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); // OR GET
$result = curl_exec($ch);
curl_close($ch);
In javascript you can use headers key to add the authorization header
$.ajax({
url: '<url>'
type: 'GET',
contentType: 'application/json'
headers: {
'Authorization': 'Bearer <api_key>'
},
success: function (result) {
// CallBack(result);
},
error: function (error) {
}
});
The following are the API calls you can make. You can try out / test the calls right from this page. Please note, javascript needs to be enabled to see the documentation below.
We understand that every customer is unique, which is why we offer a variety of pricing plans tailored to fit different needs and budgets. Whether you're a small business owner, a growing startup, or a large enterprise, we have a plan that will provide you with the features and support you need to succeed. Explore our plans below and find the one that's right for you!