FatSecretKit 0.0.3

FatSecretKit 0.0.3

LangLanguage Obj-CObjective C
License BSD
ReleasedLast Release Mar 2016

Maintained by Adam Kirk, Parker Wightman.

  • By
  • Parker Wightman

iOS Client for the FatSecret API.


Install via CocoaPods by adding this to your Podfile:

pod 'FatSecretKit'

Then import it as necessary

#import <FatSecretKit/FSClient.h>


The toughest part of making your own client is the OAuth negotiation, so this should save you some precious hours. All you need is your OAuth consumer key and secret. Preferred usage is through the sharedClient:

[FSClient sharedClient].oauthConsumerKey = @"12345";
[FSClient sharedClient].oauthConsumerSecret = @"67890";

You should put that in your AppDelegate.m or similar, where it will only run once. You can always create your own clients with the usual [[FSClient alloc] init].

You're all set to use the APIs.

Food Search

[[FSClient sharedClient] searchFoods:term
                          completion:^(NSArray *foods, NSInteger maxResults, NSInteger totalResults, NSInteger pageNumber) {
    // Use data as you will.
    self.foods = foods;
    [self.tableView reloadData];

// A more verbose version of the above, if you want to utilize the full paramters of the API
[[FSClient sharedClient] searchFoods:term
                          completion:^(NSArray *foods, NSInteger maxResults, NSInteger totalResults, NSInteger pageNumber) {
    // Use data as you will.
    self.foods = foods;
    [self.tableView reloadData];

Get Food

[[FSClient sharedClient] getFood:item.identifier
                      completion:^(FSFood *food) {
                          NSLog(@"Name: %@", food.name)

There are also native objects to represent resources returned by the API, including FSFood, which represents a food resource, and FSServing, which represents the servings for each food, returned by the food.get API method (among others).

Limitations (and To-do list)

  • Only supports requests not specific to a user. In other words, it does not currently support Delegated requests.
  • All API methods are not implemented, only a few specific ones that Mysterious Trousers has had need for. Adding support for other APIs is welcome and should be rather trivial. See the Contributing section.


New methods for fetching resources should be added to the FSClient class, and new native objects can be created as necessary. Naming conventions for client methods should follow the same convention:

API: foods.search, iOS: searchFoods

API: food.get, iOS: getFood


New methods/properties on native objects should follow a similar convention

API: trans_fat, iOS: transFat

API: saturated_fat, iOS: saturatedFat


Adding support for new API methods requires creating an appropriately named method inside FSClient, and it should support all required and optional parameters, though convenience methods are also welcome (see searchFoods methods as a reference.) You can always questions on Twitter or through issues, we're nice guys.


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request


Parker Wightman (@parkerwightman)


Thanks to atebits for his OAuthCore library that made this much simpler. Thanks also to Sam Vermette for his execellent SVHTTPRequest library.