YWeatherAPI 1.0.7

YWeatherAPI 1.0.7

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release May 2016

Maintained by Nishanth Shanmugham.



A powerful API wrapper for Yahoo Weather for iOS and Mac. Built on top of AFNetworking’s blocks-based architecture, it fetches responses asynchronously without any waiting on the main thread.

This document provides a quick overview. Check out the full documentation.

The Yahoo Weather API does not require an API key.

Contents

Installation

Manual

Clone the repo and add all the files in the Pod/Classes directory to your Xcode target.

Getting Started

Include the header file
#import <YWeatherAPI/YWeatherAPI.h>
Shared Singleton

Use the shared singleton to make requests:

[YWeatherAPI sharedManager];
Example

Getting the current temperature is as simple as:

[[YWeatherAPI sharedManager] temperatureForLocation:@"Redwood City, California"
                                            success:^(NSDictionary* result)
    {
        NSString* temperature = [result objectForKey:kYWAIndex];
        NSLog(@"The temperature is a pleasant %@ F", temperature);
    }
                                            failure:^(id response, NSError* error)
    {
        // Yikes, something went wrong
    }
];
Success result

The result in the success callback in the example is this NSDictionary object:

{
    city = "Redwood City"; 
    country = "United States"; 
    index = 72; // key @"index" (the detail you asked for)
    latitude = "37.5"; 
    longitude = "-122.23"; 
    region = CA; 
    temperatureInC = "22.22";
    temperatureInF = 72;
}

See YWeatherAPI.h for a complete list of keys and data types.

Customizing Defaults

Customize the default weather units to be returned, enable caching of results, set the cache expiry duration, and more.

[YWeatherAPI sharedManager].defaultPressureUnit = MB;
[YWeatherAPI sharedManager].cacheEnabled = YES;
[YWeatherAPI sharedManager].cacheExpiryInMinutes = 10;

Features

  • Caching results, with customizable cache expiry times.
  • Looking up weather data by CLLocation, natural-language location string, and Yahoo WOEID.
  • Looking up weather data in customizable pressure, distance, speed, and temperature units.

Documentation

The full documentation is at CocoaDocs.

FAQs

Do I need an API key?

No, you do not. Yahoo Weather currently does not require an API key to access most of its content, so this API wrapper does not require one either. Please be respectful of this power.

The requirement for an API key may change in the future. If it does, care will be taken to follow semantic versioning rules for backwards compatibility.

Do I need to know YQL (Yahoo Query Language) to use this?

Nope.

Requirements

YWeatherAPI works on Mac OS X 10.8+ and iOS 6.0+.

  • CoreLocation is required to reverse geocode coordinates.
  • AFNetworking ~>2.0 is a dependency and is automatically installed along with YWeatherAPI if it isn't already.

Contributing

  • New features, bug fixes, and additional documentation and tests are welcome! Please fork the repository and request to be merged into the master branch. Yes, I too like to live dangerously.
  • Alternatively, if you have a feature request or find a bug, please let me know here, on Twitter, or email.

License

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