The HTTP GET method retrieves historical temperature data for a specified city. The city name is provided as a path parameter in the URL.

Request

GET /cities/{city}/temperatures

Request Parameters

ParameterTypeDescriptionRequired
citystringThe name of the city for which to retrieve temperature data.Yes

Response

A successful request will return a JSON array containing temperature data for the specified city. Each object in the array represents a specific timestamp and its corresponding temperature.

Example Response:

[
  {
    "timestamp": "2023-11-22T12:34:56Z",
    "temperature": 15.2
  },
  {
    "timestamp": "2023-11-23T08:00:00Z",
    "temperature": 12.8
  }
]

Response Parameters

The API returns a JSON array containing temperature data for the specified city. Each object in the array has the following properties:

PropertyTypeDescription
timestampstringThe timestamp indicates the time at which the temperature was recorded. The format is ISO 8601.
temperaturenumberThe temperature reading in Celsius.

Error Codes

Status CodeDescription
400 Bad RequestInvalid request format or missing parameters.
404 Not FoundThe specified city was not found.
500 Internal Server ErrorAn unexpected error occurred on the server.