Overview
Breeze uses the Open-Meteo Geocoding API to enable users to search for cities by name and retrieve their geographic coordinates. This powers the location search functionality throughout the app.Base URL
Endpoints Used
Search Cities by Name
Searches for cities matching a query string and returns up to 5 results. Query Parameters:| Parameter | Type | Description |
|---|---|---|
name | String | City name search query (minimum 2 characters) |
count | Int | Maximum number of results to return (set to 5) |
language | String | Response language (set to "en") |
format | String | Response format (set to "json") |
Response Format
The API returns a JSON response with an array of matching cities:Response Model
Breeze decodes the response into these Swift models:Usage Example
Here’s how Breeze searches for cities:Search Behavior
Minimum Query Length
Breeze requires at least 2 characters before triggering a search to prevent unnecessary API calls and improve user experience.Result Limit
The app requests a maximum of 5 results to keep the search interface clean and focused on the most relevant matches.Display Format
City results are displayed in the format:City, State/Region, Country
Examples:
- “San Francisco, California, United States”
- “Paris, Île-de-France, France”
- “Tokyo, Tokyo, Japan”
Response Fields
| Field | Type | Description |
|---|---|---|
id | Int | Unique identifier for the location |
name | String | City name |
latitude | Double | Geographic latitude |
longitude | Double | Geographic longitude |
country | String? | Country name |
admin1 | String? | First-level administrative division (state/province/region) |
Error Handling
The service handles several error cases:- Empty query or too short: Returns empty array without making API call
- Invalid URL: Throws
URLError(.badURL) - Bad response: Throws
URLError(.badServerResponse) - No results: Returns empty array (when
resultsfield isnil)
Integration Points
The geocoding service is used in:- City Search Interface: User-facing search bar for finding locations
- Location Selection: Converting user input to coordinates
- Dashboard: Displaying selected city information
Rate Limits
Open-Meteo APIs are free and do not require an API key. They have generous rate limits suitable for interactive search experiences.Reference
- Open-Meteo Geocoding API Documentation
- Service Implementation:
BreezeApp/Services/GeocodingService.swift - Data Models:
BreezeApp/Models/City.swift