What Is Facts API?
As a developer, you often find yourself needing reliable data to test your applications or practice working with REST APIs. Facts API was designed with this in mind—a free and publicly accessible API to help new developers hone their skills, explore how APIs work, and use realistic data for mock projects.
This project isn’t just another trivia source. It’s a curated collection of facts, structured in a developer-friendly way, and perfect for learning API integration, data handling, and backend querying.
Visit Facts API and experiment freely with real-world API functionality.
Why I Created Facts API
When I started learning to work with REST APIs, I struggled to find usable endpoints offering data I could experiment with—most options were either too complex or required authentication, limiting my ability to test freely.
I built Facts API as a practical solution for new developers, students, and anyone trying to:
- Understand how REST APIs work.
- Learn to fetch data, parse JSON responses, and work with structured information.
- Build projects with realistic mock data.
This API is open to the public, free to use, and intentionally simple.
Features
📦 Free Public Access
No authentication, no API keys—just a clean and straightforward way to interact with an API and retrieve data.
📊 Realistic JSON Data
The API delivers structured facts in JSON format, making it easy to handle in web, mobile, or backend applications.
🎯 Multiple Endpoints for Practice
From simple fetch operations to advanced category-based filtration, Facts API offers everything you need to practice working with REST endpoints.
💡 Verified Facts for Fun Learning
The data isn’t just random—it’s intriguing, informative, and verified for credibility. Work with categories like astronomy, history, and technology while honing your development skills.
API Documentation
Endpoints
Here’s what you can do with Facts API:
1. Get All Facts
Retrieve a list of facts to work with:
GET /api/facts?limit=:limit&verified=:verified
Parameters:
-
limit
(optional): Specify the number of results (default is 10, max is 20). -
verified
(optional): A boolean flag to filter for verified facts.
2. Get a Random Fact
For quick testing, fetch one fun fact at random:
GET /api/facts/random
3. Fetch Fact by ID
Retrieve a specific fact using its unique numeric identifier:
GET /api/facts/:id
4. Filter Facts by Category
Some mock projects need data from specific domains like astronomy or biology—this endpoint lets you filter facts by category:
GET /api/facts/category/:category
Categories include: astronomy
, biology
, physics
, animals
, history
, and technology
.
5. Search Facts
Search facts by a text query, such as specific keywords:
GET /api/facts/search?q=:query
This endpoint is great for testing complex filters or implementing search functionality.
JSON Fact Object Structure
Facts API delivers consistent JSON responses, like the structure below:
{
"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
}
How to Use Facts API
- Start Experimenting with Mock Data You can start sending API requests right away without worrying about authentication or setup. For example, fetch a random fact with JavaScript:
fetch('https://f-api.ir/api/facts/random')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Explore JSON Responses
Facts API provides organized, developer-friendly responses that are great for practicing how to handle and display real-world data.Build Your Own Applications
Use the API in your mock projects, such as building trivia apps, dashboards, or even REST API tutorials for others.
Example Use Cases
🖥 Mock Applications
Use Facts API to simulate working with an API in your projects—fetch trivia, display lists, and create basic CRUD operations.
🧑🎓 Learning and Teaching
Perfect for students in bootcamps, tutorials, and workshops, Facts API teaches how REST APIs work with structured data responses that focus on simplicity and clarity.
🔧 Data Retrieval Practice
Learn to fetch, filter, and handle JSON responses in any application, from simple frontends to full-stack environments.
Get Started Today
The Facts API is free, public, and always accessible—giving you a reliable way to practice API calls, experiment with code, and use curated mock data to improve your skills.
Visit Facts API to explore and start coding!
If you use Facts API in your projects or tutorials, let me know—I’d love to see what you create! 🚀 Remember, this project was made for developers like you.
Top comments (0)