HomeAPI Usage Guide

API Usage Guide

Welcome to the API Usage Guide! Here, you’ll find everything you need to start using FreeApiHub APIs effectively in your projects.

Making Your First Request

Each API can be accessed using a simple GET request following this URL format:

GET https://freeapihub.onrender.com/api/v1/{api_name}

Example URLs for Each API

Request Format

To make a request, you can use your preferred HTTP client (e.g., Axios or fetch JavaScript, or tools like Postman and cURL). Here’s an example using JavaScript fetch:

import axios from "axios";
 
axios
  .get("https://example.com/api/v1/endpoint")
  .then((response) => {
    console.log("Data:", response.data);
  })
  .catch((error) => {
    console.error("Error fetching data:", error);
  });

Using curl from the Command Line

curl -X GET "https://freeapihub.onrender.com/api/v1/randomusers"

Example Using Postman

Response Format

All responses are returned in JSON format to ensure easy integration. Below is an example of a response from the User API:

{
  "success": true,
  "data": [
    {
      "id": "cm2ivfrdc0002fo4ch5zi0car",
      "gender": "male",
      "firstName": "John",
      "lastName": "Doe",
      "email": "john.doe@example.com",
      "username": "johndoe123",
      "password": "password123",
      "phone": "+1234567890",
      "age": 34,
      "streetNumber": 123,
      "streetName": "Main St",
      "city": "Anytown",
      "state": "California",
      "country": "USA",
      "postcode": 90210,
      "picture": "https://randomuser.me/api/portraits/men/1.jpg",
      "nationality": "American",
      "createdAt": "2024-10-21T10:26:09.061Z",
      "updatedAt": "2024-10-21T10:26:09.061Z"
    }
  ],
  "message": "All users retrieved successfully"
}

Common Fields in Responses

  • id: A unique identifier for the record.
  • success: A boolean value indicating whether the API request was successful (true) or if there was an error (false). This field helps you quickly determine the outcome of your request.
  • message: A string providing context about the response, such as success confirmation or error details. This field can vary by endpoint and offers insights into the nature of the response, making it easier to debug issues or confirm data retrieval.

Swagger API Documentation

To enhance your experience with the FreeApiHub APIs, we provide an interactive Swagger UI that allows you to test the APIs directly from your browser. Swagger makes it easy to explore the available endpoints, view request and response formats, and execute API calls in real-time.

You can access the Swagger documentation here: Swagger Guide.

With Swagger, you can easily understand how to interact with the FreeApiHub APIs and test them without writing any code.

Rate Limiting

To ensure fair use and consistent access, FreeApiHub enforces rate limits on API calls. For most endpoints, the default limit is 50 requests per five minute. If you exceed this limit, you may receive a 429 Too Many Requests error.

Best Practices

Error Handling: Always include error handling to catch unexpected responses or network issues.
Efficient Data Usage: Request only the data you need by using query parameters to minimize payload size.
Rate Limiting: Respect rate limits to prevent access disruptions and maintain reliable API performance.

Next Steps

Explore each API’s details in the sidebar for additional usage examples and parameter options. With FreeApiHub, you have a powerful suite of APIs to integrate and speed up development. Happy coding!