Fun Generators
Login

Facts API

Fun Generators
Toggle sidebar
Generate random facts for many many categories with a simple API Call.

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.

Engage Your Audience with Fascinating Facts

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!

Why Choose the Fun Facts API?

  • Massive Collection of Facts – Access thousands of unique and interesting facts spanning multiple topics.
  • Instant Integration – Simple RESTful API with JSON responses for seamless implementation.
  • Multiple Categories – Choose from science, history, pop culture, and many more.
  • High-Speed Performance – Get fast and reliable responses to keep your users engaged.
  • Customizable Queries – Retrieve random facts, category-based facts, or specific types of trivia.

How It Works

  1. Sign Up – Get your API key in seconds.
  2. Make a Request – Use a simple GET request to retrieve fun facts.
  3. Integrate Anywhere – Add engaging trivia to your website, app, or chatbot effortlessly.

Who Can Benefit from This API?

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.

API End Points

The end point for connecting : If you subscribe directly from us use this endpoint.

	https://api.fungenerators.com

API Documentation

Get a Random Fact

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 "
  }
}

Search for a random Fact

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"
    
  }
  
}

Create a Fact Enry

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 a Fact entry

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 a Fact

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"
    }
}

Get a random historic event

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."
                }
              } 

API Rate Limiting for Facts API

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.

Authenticating with the Facts API

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) {

   }
});
            
            

API Console

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.

Facts API Pricing Plans

Choose the Perfect Plan for Your Needs

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!

Facts API Starter

$ 9 99 /month
  • 1 API Key
  • No setup, or hidden fees
  • 1000 API Calls
  • Fast support
Get started

Facts API Premium

$ 24 99 /month
  • 1 API Key
  • No setup, or hidden fees
  • 5000 API Calls
  • Fast support
Get started

Facts API Enterprise

$ 49 99 /month
  • 1 API Key
  • No setup, or hidden fees
  • 15000 API Calls
  • Fast support
Get started