Skip to content
This repository was archived by the owner on Mar 25, 2020. It is now read-only.

Basic Usage

Tom Wilson edited this page Apr 20, 2017 · 5 revisions

When the fatsecretR library is loaded, a fatsecret (S4) object will be assigned into the global environment. This object helps to manage essential parameters when making API requests.

> library(fatsecretR)
> ls()
[1] "fatsecret"

> class(fatsecret)
[1] "fatsecret"
attr(,"package")
[1] "fatsecretR"

> slotNames(fatsecret)
[1] "ConsumerKey"     "SharedSecret"    "oauthConsumer"   "RESTURL"        
[5] "httpMethod"      "signatureMethod" "oauthVersion"    "timestamp"      
[9] "nonce"

The object show method will inform you if API keys have been added and when the object was last 'Timestamped' and thus; used in an API request.

> fatsecret

fatsecret S4 object 
 
For more details, please visit https://github.com/wilsontom/fatsecretR/wiki 
 
No API ConsumerKey has been added yet
 
No API SharedSecret has been added yet
 
Last timestamp: 
no timestamp available

Your API keys can be then be added to the object;

> APIkeys(fatsecret, token = "api_token", secret = "api_secret")

> fatsecret
fatsecret S4 object 
 
For more details, please visit https://github.com/wilsontom/fatsecretR/wiki 
 
API ConsumerKey available
 
API SharedSecret available
 
Last timestamp: 
no timestamp available

The main method is 'fatsecretR'. This method will allow you to execute the implemented API requests. The fatsecret developers website; gives an API method reference. The names of API methods are not like-for-like in fatsecretR.

The methods slot in fatsecret gives a description of currently available methods;

> fatsecret@methods
       RESTful                 method       oauth_param signature
1      getFood           foods.search search_expression         1
2    getFoodID               food.get           food_id         1
3 getFoodMonth food_entries.get_month              date         2
4 getFoodEntry       food_entries.get              date         2
5   getProfile            profile.get                           1
6  makeProfile         profile.create           user_id         1

method is the API method as described in the fatsecret API method reference and RESTful is the name of it's implementation in fatsecretR. oauth_param

Clone this wiki locally