Latest 0.0.2
License MIT
Platforms ios 10.2

Open Weather Map API Consumer fully Unit Tested, being able to get current weather and 3-hourly forecast 5 days for your city. Helpful stats, temperature, clouds, pressure, wind around your location… This API is a consumer of Open Weather Map and the description of the api may be found here

Note: In the consumer has been implemented just the free version of the API. In order to start using it, please register and get the API Key Sign up

[![CI Status]( Luis Cardosa/OpenWeatherMapAPIConsumer.svg?style=flat)]( Luis Cardosa/OpenWeatherMapAPIConsumer)


To run the example project, clone the repo, and run pod install from the Example directory first.


Basically, the example makes use of the CLLocationManager to obtain the current coordenates, and then make a request to our API to get all the displayed information. All the code is located in View Controller


  • iOS 10.2
  • Swift 3
  • Xcode 8


OpenWeatherMapAPIConsumer is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "OpenWeatherMapAPIConsumer"


Import the pod in your file

import OpenWeatherMapAPIConsumer

Setup the api key

// Type by default OpenWeatherMapType.Current
let weatherAPI = OpenWeatherMapAPI(apiKey: "YOUR_API_KEY")

// Type forecast
let weatherAPI = OpenWeatherMapAPI(apiKey: "YOUR_API_KEY", forType: OpenWeatherMapType.Forecast)

Set the location using

public func weather(byLatitude latitude : Double, andLongitude longitude : Double)

public func weather(byCityName cityName : String)

public func weather(byCityName cityName : String, andCountryCode countryCode: String)

// List of city ids may be found here:
public func weather(byCityId cityId : Int)

API Options

public func setSearchAccuracy(searchAccuracy : SearchAccuracyType)

public func setLimitationOfResult(in limitation : Int)

public func setTemperatureUnit(unit : TemperatureFormat)

public func setMultilingualSupport(language : Language)

Perform request

public func performWeatherRequest(completionHandler: @escaping (Data?, URLResponse?, Error?) -> Swift.Void)

weatherAPI.performWeatherRequest(completionHandler:{(data: Data?, urlResponse: URLResponse?, error: Error?) in
    if (error != nil) {
        //Handling error
    } else {
        do {
            let responseWeatherApi = try CurrentResponseOpenWeatherMap(data: data!)
        } catch let error as Error {
            //Handling error

Response classes

The response classes are parsers, that give you a better use of the api response

  • CurrentResponseOpenWeatherMap(data : Data)
  • ForecastResponseOpenWeatherMap(data : Data)

func getCoord() -> CLLocationCoordinate2D

func getTemperature() -> Float

func getPressure() -> Float

func getHumidity() -> Float

func getTempMax() -> Float

func getTempMin() -> Float

func getCityName() -> String

func getIconList() -> IconList

func getDescription() -> String

func getWindSpeed() -> Float

func getDate() -> Date


Jose Luis Cardosa, [email protected]


OpenWeatherMapAPIConsumer is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "OpenWeatherMapAPIConsumer",
    "version": "0.0.2",
    "summary": "Get current weather and 3-hourly forecast 5 days for your city. Helpful stats, temperature, clouds, pressure, wind around your location.",
    "description": "Access current weather data for any location on Earth including over 200,000 cities! Current weather is frequently updated based on global models and data from more than 40,000 weather stations. Also 5 day forecast is available at any location or city. It includes weather data every 3 hours. Data is available in JSON Format.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Jose Luis Cardosa": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.0.2"
    "platforms": {
        "ios": "10.2"
    "source_files": "OpenWeatherMapAPIConsumer/Classes/**/*",
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This