Top 15 Free Web APIs for Developers to Use for Testing Purposes with Sample Code in jQuery
1. JSONPlaceholder
URL: JSONPlaceholder
Description: JSONPlaceholder is a free fake online REST API that you can use for testing and prototyping. It provides a variety of endpoints for posts, comments, albums, photos, users, and more.
Get all request and response HERE.
Use Cases:
- Testing REST API integrations
- Mocking data for frontend development
- Learning how to handle API requests and responses
Sample Code
Request
fetch('https://jsonplaceholder.typicode.com/posts/1')
.then((response) => response.json())
.then((json) => console.log(json));
Response
{
id: 1,
title: '...',
body: '...',
userId: 1
}
2. Reqres
URL: Reqres
Description: Reqres is a hosted REST API that is ready to respond to your AJAX requests. It includes endpoints for user registration, login, and various other resources.
Sample Code Request
$.ajax({
url: "https://reqres.in/api/users",
type: "POST",
data: {
name: "paul rudd",
movies: ["I Love You Man", "Role Models"]
},
success: function(response){
console.log(response);
}
});
Response JSON
{
"name":"paul rudd",
"movies[]":[
"I Love You Man",
"Role Models"
],
"id":"243",
"createdAt":"2014-10-18T12:09:05.255Z"
}
3. Mocky
URL: Mocky
Description: Mocky allows you to create custom HTTP responses for your testing needs. You can define your own response bodies, headers, and status codes.
4. OpenWeatherMap
URL: OpenWeatherMap
Description: OpenWeatherMap provides weather data, including current weather, forecasts, and historical data.
https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}
Response
{
"coord": {
"lon": 10.99,
"lat": 44.34
},
"weather": [
{
"id": 501,
"main": "Rain",
"description": "moderate rain",
"icon": "10d"
}
],
"base": "stations",
"main": {
"temp": 298.48,
"feels_like": 298.74,
"temp_min": 297.56,
"temp_max": 300.05,
"pressure": 1015,
"humidity": 64,
"sea_level": 1015,
"grnd_level": 933
},
"visibility": 10000,
"wind": {
"speed": 0.62,
"deg": 349,
"gust": 1.18
},
"rain": {
"1h": 3.16
},
"clouds": {
"all": 100
},
"dt": 1661870592,
"sys": {
"type": 2,
"id": 2075663,
"country": "IT",
"sunrise": 1661834187,
"sunset": 1661882248
},
"timezone": 7200,
"id": 3163858,
"name": "Zocca",
"cod": 200
}
5. Cat Facts
URL: Cat Facts
Description: This API provides random cat facts.
curl -X 'GET' \
'https://catfact.ninja/fact' \
-H 'accept: application/json' \
-H 'X-CSRF-TOKEN: '
Response
{
"fact": "The first official cat show in the UK was organised at Crystal Palace in 1871.",
"length": 78
}
6. Dog CEO’s Dog API
URL: Dog CEO’s Dog API
Description: The Dog API provides random pictures of dogs and information about different breeds.
Use Cases:
- Developing pet-related applications
- Adding random images to your website
- Practicing API calls with image data
7. PokeAPI
URL: PokeAPI
Description: PokeAPI provides information about Pokémon and related data.
Use Cases:
- Developing Pokémon-themed applications
- Learning how to handle nested JSON data
- Practicing API requests with detailed datasets
8. CoinGecko
URL: CoinGecko API
Description: CoinGecko provides data about cryptocurrencies, including prices, market data, and more.
Use Cases:
- Developing cryptocurrency tracking applications
- Integrating financial data into applications
- Learning how to work with real-time data
9. Open Brewery DB
URL: Open Brewery DB
Description: Open Brewery DB provides information about breweries in the US.
Use Cases:
- Creating applications related to breweries
- Integrating location-based data
- Practicing handling geographical data
10. Public APIs
URL: Public APIs
Description: Public APIs is a collective list of free APIs for various purposes, making it a great resource for developers looking for specific types of APIs.
Use Cases:
- Finding APIs for specific use cases
- Discovering new APIs to integrate
- Expanding knowledge of available free APIs
11. NASA API
URL: NASA API
Description: NASA API provides data related to space and astronomy, including imagery, Mars rover photos, and more.
Use Cases:
- Developing space-themed applications
- Accessing real scientific data
- Practicing handling complex datasets
12. RandomUser
URL: RandomUser
Description: RandomUser provides randomly generated user data, useful for testing purposes.
Use Cases:
- Creating mock user profiles
- Testing user management features
- Generating dummy data for development
13. The Joke API
URL: The Joke API
Description: The Joke API provides random jokes from different categories.
Use Cases:
- Adding humor to your applications
- Practicing API integration with simple and fun data
- Creating entertainment-focused apps
14. Agify.io
URL: Agify.io
Description: Agify.io predicts the age of a person based on their name.
Use Cases:
- Developing applications that use age prediction
- Adding interesting features to user profiles
- Testing API requests with simple inputs
15. Genderize.io
URL: Genderize.io
Description: Genderize.io determines the gender of a person based on their name.
Use Cases:
- Creating applications that use gender prediction
- Enhancing user profile features
- Practicing API calls with name-based data
Conclusion
These free web APIs provide a wide range of data and functionalities that can help developers test and prototype their applications. From simple mock data to complex datasets, these APIs are invaluable tools for any developer looking to enhance their development and testing processes. Whether you’re building a weather app, integrating cryptocurrency data, or just having fun with random cat facts, there’s an API for you.
Hope it Helps