Facts API

Access 200+ fascinating facts across six categories with this simple REST API

About Facts API

The Facts API provides developers with access to a comprehensive database of verified and interesting facts across multiple categories. Whether you're building an educational app, a trivia game, or just looking to integrate fascinating facts into your website, our API makes it simple.

API Features:

  • 200+ curated, interesting facts
  • 6 distinct categories: science, history, astronomy, biology, animals, and technology
  • Simple RESTful endpoints
  • Filter by category, verification status, or use search capabilities
  • Each fact includes title, content, source, and year discovered

Get All Facts

Number of facts to return (1-20)

Get Random Fact

GET /api/facts/random

Get Fact by ID

Enter the ID of the fact you want to retrieve

Get Facts by Category

Choose from astronomy, biology, physics, animals, history, or technology

API Documentation

Get All Facts

GET /api/facts?limit=:limit&verified=:verified

Retrieve a collection of facts with optional filtering.

Parameters:

  • limit (optional): Number of facts to return (default: 10)
  • verified (optional): Set to 'true' to get only verified facts

Get Random Fact

GET /api/facts/random

Retrieve a single random fact from the database.

Get Fact by ID

GET /api/facts/:id

Retrieve a specific fact by its unique identifier.

Parameters:

  • id (required): The numeric ID of the fact

Get Facts by Category

GET /api/facts/category/:category

Retrieve all facts belonging to a specific category.

Parameters:

  • category (required): Category name (astronomy, biology, physics, animals, history, or technology)

Search Facts

GET /api/facts/search?q=:query

Search through facts based on a text query.

Parameters:

  • q (required): The search query string

Data Types

Fact Object

interface Fact {
id: number;
category: Categories;
title: string;
fact: string;
verified: boolean;
source: string;
year_discovered: number;
interesting_rating: number;
}

Categories

type Categories =
| "astronomy"
| "biology"
| "physics"
| "animals"
| "history"
| "technology";

Getting Started

Our Facts API is free to use and requires no authentication for basic usage. Follow these simple steps to start integrating facts into your application:

1. Make Your First API Call

// Using fetch API
fetch('https://f-api.ir/api/facts/random')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

2. Handle the Response

Each fact is returned in JSON format with the following structure:

{
"id": 42,
"category": "astronomy",
"title": "Saturn's Rings",
"fact": "Saturn's rings are made mostly of water ice particles, with a small amount of rocky debris and dust.",
"verified": true,
"source": "NASA",
"year_discovered": 1610,
"interesting_rating": 9
}
Go To Top →

Frequently Asked Questions

Is the Facts API free to use?

Yes, the Facts API is completely free.

Are all facts verified?

Most facts in our database are verified. You can use the "verified" parameter to filter only verified facts in your requests.

How often is the database updated?

We add new facts to our database from time to time, ensuring fresh and interesting content for your applications.