Monday, July 12, 2010

FatSecret Sharp - C# Nutrition and Exercise Tracking Services

I started looking into's REST API this weekend after wondering how hard it would be to make a Food Tracking App for Win Phone 7.

My first step was to take a look at their REST API Documentation, which shows a list of their available methods and how to authenticate using OAuth. It turns out, the hardest part of being able to get data from their services is the OAuth stuff.

OAuth Primer

Basically, OAuth works like this; You get a Consumer Key and a Consumer Secret from their API. You use these to "Sign" your requests. The "Signature" is built up using 3 components joined by an "&"; The method you are using to request (POST or GET), the uri of the service (Url Encoded), and the query parameters (ordered alphabetically by key, then value, then Url Encoded).



Final Version:


Then you make your request and hope everything matches up on their side.

FatSecret C# Service Wrappers

The end result of digging into the API was a library to wrap the nutrition and exercise services. Now there is an easy way to search for nutrition information in C#. Visit the FatSecretSharp project on codeplex for examples and code. I'm hoping to start making a Win Phone 7 Application for Food Tracking in the next couple weeks.

Now Playing: Weird Al - Fat

No comments:

Post a Comment