API

Free Weather Mock REST API Documentation

Free Weather Mock REST API Documentation
117 views
5 min read
#API

The MockX Weather API provides developers with access to a wide range of weather data, including current conditions, forecasts, and air quality indices. Utilize our API to fetch weather information by location, search for specific conditions, and manage weather data entries.

Endpoints Overview

The MockX Weather API includes several endpoints to cater to different data access and manipulation needs:

  • GET /: Retrieve all weather data entries.
  • GET /search: Search for weather data based on query parameters.
  • GET /locations: Get a list of all locations with weather data.
  • GET /:id: Fetch weather data by a unique ID.
  • POST /add: Add a new weather data entry.
  • PUT /:id: Update an entire weather data entry by ID.
  • PATCH /:id: Partially update a weather data entry by ID.
  • DELETE /:id: Delete a weather data entry by ID.

Get All Weathers

Retrieve a list of all weather data entries.

GET https://api.mockx.net/weather

Parameters:

limit: Limit the number of returned entries. skip: Skip a specific number of entries. select: Specify fields to include in the returned entries.

Example Response:

{
  "weathers": [
    {
            "air_quality": {
                "category": "Good",
                "index": 42
            },
            "current_weather": {
                "humidity": 65,
                "icon": "partly_cloudy",
                "temperature": 72,
                "weather_condition": "Partly Cloudy",
                "wind_speed": 10
            },
            "forecast": [
                {
                    "condition": "Sunny",
                    "date": "2024-03-16",
                    "icon": "sunny",
                    "max_temp": 75,
                    "min_temp": 55
                },
                {
                    "condition": "Cloudy",
                    "date": "2024-03-17",
                    "icon": "cloudy",
                    "max_temp": 70,
                    "min_temp": 52
                }
            ],
            "location": {
                "city": "Springfield",
                "coordinates": {
                    "latitude": 39.7817,
                    "longitude": -89.6501
                },
                "country": "USA"
            },
            "id": 926
        },
        ...
  ],
  "total": 100,
  "skip": 0,
  "limit": 10
}

Search Weather

Search for weather data entries based on query parameters.

GET https://api.mockx.net/weather/search?q=sunny

Parameters:

q: Search query (e.g., "sunny", "cloudy"). limit, skip, select: Same as above. Example Response:

{
"weathers": [
   {
            "air_quality": {
                "category": "Good",
                "index": 42
            },
            "current_weather": {
                "humidity": 65,
                "icon": "partly_cloudy",
                "temperature": 72,
                "weather_condition": "Partly Cloudy",
                "wind_speed": 10
            },
            "forecast": [
                {
                    "condition": "Sunny",
                    "date": "2024-03-16",
                    "icon": "sunny",
                    "max_temp": 75,
                    "min_temp": 55
                },
                {
                    "condition": "Cloudy",
                    "date": "2024-03-17",
                    "icon": "cloudy",
                    "max_temp": 70,
                    "min_temp": 52
                }
            ],
            "location": {
                "city": "Springfield",
                "coordinates": {
                    "latitude": 39.7817,
                    "longitude": -89.6501
                },
                "country": "USA"
            },
            "id": 926
        },
        ...
],
"total": 20,
"skip": 0,
"limit": 10
}

Get Weather Locations

Retrieve a list of all unique locations with weather data.

GET https://api.mockx.net/weather/locations

Example Response:

{
  "locations": ["New York", "Los Angeles", "Chicago", "Houston", "Phoenix", ...]
}

Get Weather by ID

Fetch detailed weather information for a specific entry by its unique ID.

GET https://api.mockx.net/weather/{id}

Parameters: id: The unique identifier of the weather data entry. select: Specify fields to include in the returned weather data.

Example Response:

{
    "id": 926,
    "air_quality": {
        "category": "Good",
        "index": 42
    },
    "current_weather": {
        "humidity": 65,
        "icon": "partly_cloudy",
        "temperature": 72,
        "weather_condition": "Partly Cloudy",
        "wind_speed": 10
    },
    "forecast": [
        {
            "condition": "Sunny",
            "date": "2024-03-16",
            "icon": "sunny",
            "max_temp": 75,
            "min_temp": 55
        },
        {
            "condition": "Cloudy",
            "date": "2024-03-17",
            "icon": "cloudy",
            "max_temp": 70,
            "min_temp": 52
        }
    ],
    "location": {
        "city": "Springfield",
        "coordinates": {
            "latitude": 39.7817,
            "longitude": -89.6501
        },
        "country": "USA"
    }
}

Add New Weather Data

Add a new weather data entry to the database.

POST https://api.mockx.net/weather/add

Body: Include all relevant weather data details in the request body.

{
    "air_quality": {
        "category": "Good",
        "index": 42
    },
    "current_weather": {
        "humidity": 65,
        "icon": "partly_cloudy",
        "temperature": 72,
        "weather_condition": "Partly Cloudy",
        "wind_speed": 10
    },
    "forecast": [
        {
            "condition": "Sunny",
            "date": "2024-03-16",
            "icon": "sunny",
            "max_temp": 75,
            "min_temp": 55
        },
        {
            "condition": "Cloudy",
            "date": "2024-03-17",
            "icon": "cloudy",
            "max_temp": 70,
            "min_temp": 52
        }
    ],
    "location": {
        "city": "Springfield",
        "coordinates": {
            "latitude": 39.7817,
            "longitude": -89.6501
        },
        "country": "USA"
    }
}

Example Response:

{
    "id": 101,
    "air_quality": {
        "category": "Good",
        "index": 42
    },
    "current_weather": {
        "humidity": 65,
        "icon": "partly_cloudy",
        "temperature": 72,
        "weather_condition": "Partly Cloudy",
        "wind_speed": 10
    },
    "forecast": [
        {
            "condition": "Sunny",
            "date": "2024-03-16",
            "icon": "sunny",
            "max_temp": 75,
            "min_temp": 55
        },
        {
            "condition": "Cloudy",
            "date": "2024-03-17",
            "icon": "cloudy",
            "max_temp": 70,
            "min_temp": 52
        }
    ],
    "location": {
        "city": "Springfield",
        "coordinates": {
            "latitude": 39.7817,
            "longitude": -89.6501
        },
        "country": "USA"
    }
}

Update Weather Data by ID

Update the details of an existing weather data entry by its ID.

PUT https://api.mockx.net/weather/{id}

Parameters: id: The unique identifier of the weather data entry to be updated. Body: Include the updated weather data details in the request body.

Example Response:

{
    "id": 100,
    "air_quality": {
        "category": "Good",
        "index": 42
    },
    "current_weather": {
        "humidity": 65,
        "icon": "partly_cloudy",
        "temperature": 72,
        "weather_condition": "Partly Cloudy",
        "wind_speed": 10
    },
    "forecast": [
        {
            "condition": "Sunny",
            "date": "2024-03-16",
            "icon": "sunny",
            "max_temp": 75,
            "min_temp": 55
        },
        {
            "condition": "Cloudy",
            "date": "2024-03-17",
            "icon": "cloudy",
            "max_temp": 70,
            "min_temp": 52
        }
    ],
    "location": {
        "city": "Springfield",
        "coordinates": {
            "latitude": 39.7817,
            "longitude": -89.6501
        },
        "country": "USA"
    }
}

Delete Weather Data by ID

Remove a weather data entry from the database by its ID.

DELETE https://api.mockx.net/weather/{id}

Parameters: id: The unique identifier of the weather data entry to be deleted.

Example Response:

{
  "message": "Weather data entry with id '{id}' successfully deleted."
}
MockX offers free, reliable mock APIs for easy testing and development, ideal for developers seeking to enhance their workflow without the complexities of setting up any server.
Copyright © 2024. Made with ♥ by MockX.net