formerly cdixon.posterous.com

coding

I grew up coding. From about the ages of 10-25 that’s how I spent a lot of my time. While other kids were playing baseball I was trying to create computer baseball games. I was never a great programmer. I was mostly just a hacker in the original sense of the word. I didn’t like to plan out my code and the code I produced was rarely commented or elegant. I did a fair amount of object oriented programming later on (C++ & Java) but was always suspicious of objects and basically anything except C, assembly, text files, and ever using code in my programs I didn’t write myself. I was really turned off my the Microsoft programming model which felt more like shopping than creating. I mostly quit programming after doing some initial coding on my last company, SiteAdvisor. I guess I was burnt out.

This past Thursday night after a long day of business meetings (seems like that’s all I’ve done for the past few years) I thought I’d try coding again – partly for fun and partly because my company (Hunch) has an API that is central to our strategy and I felt like I needed to use the API first hand to truly understand it. So Thurs night I made a simple Youtube + Hunch mashup and put it on a domain I’ve been sitting on for a while – Forage.com. It’s a very simple program but taught me a lot about our API. The Hunch API is much more powerful when you require the user to oauth (login to Hunch) but I wanted to avoid that in the first hack. So the recommendations aren’t as good but there is very little friction for the user – just put in a twitter name and press go (plus you can “cross dress” as other users which is fun). (Personally I’ve been really digging mixes when you type in twitter name = cdixon, genre = hip hop, version = experimental).

This weekend I wanted to try some authenticated (oauth) hacks so built two more little demos. One of them suggests people you should do things with (http://forage.com/u.php). It really only works if your Hunch account is linked to Twitter or FB and there is no error handling so if you want to try it, login to Hunch, connect to Twitter/FB (go to your profile, edit, services) and then try it. The other one I wrote uses Yipit’s API (Yipit is a daily deal aggregator – great company and founders) to find daily deals. It then cross references the venues with your predicted hunch preferences and finds the daily deal that day you’ll like the most. (I’m also working on adding a feature that will suggest 5-10 friends who would also like the deal so you could invite them along but it isn’t working yet).

In the process I had to learn about “signing” you URLs (apparently to defend against man-in-middle attacks – not sure how common those really are). Kind of a poor man’s SSL. See http://hunch.com/developers/v1/docs/auth/. Turns out we had Python code samples on Hunch but no PHP code samples (yes, I prefer PHP – I’m old school). So I had to figure out my own code signing function in PHP. Here it is :

// Finally re-build the URL with the proper string and include the Signature $url = “{$urlparts[‘scheme’]}://{$urlparts[‘host’]}{$urlparts[‘path’]}?$canonical&auth_sig=”.rawurlencode($signature); return $url; } ?>

We are going to add this code (most likely a prettier version) to the Hunch API docs for PHP programmers (also need to add Ruby code). I think we’ll also make URL signing optional as only some apps really need it and it seems like a barrier to development.

One thing I noticed is how much more fun it is programming these days with so many great APIs out there. YouTube’s API was a joy to use, as was Yipit’s. Because of all these great APIs, someone with minimal programming skills (like me) can hack together interesting stuff really quickly. I do wish the APIs were more standardized. Having a SQL interface for every API would be awesome. But still now that everyone is using similar authentication, JSON, etc it is pretty easy.

People in the startup world say it’s a good practice to “dogfood” – use your own software – and if one of your products is an API you should use that too, which means doing some simple programming. The stuff I hacked together over the past few days are not meant to be real products. This is no “pivot” in Hunch’s strategy. Hunch has two official and I think really great products coming out soon – one web-based and one mobile. And if you think Forage.com is good or bad, just wait until you see the music recommendations we are developing with a major music provider. Their data + our data + our algorithms = truly incredible results.

Could you explain which Hunch API call you used to identify recommendations for a Twitter user name without using oauth (like you did with your first hack)? Without oauth, I only see how to get my own recommendations or recommendations for my friends (using the get-recommendations method). Can you show an example of the call you made for the first hack?

hey joe – i put the full forage.com code here if you are interested. http://forage.com/code.txt (excuse crappiness of coding style!!)for unauthed calls you can just do:http://api.hunch.com/api/v1/get-recommendations/?user_id=tw_cdixon&topic_ids=…and insert any twitter name where cdixon is (and any other other topic for topic_ids etc). we could do this for fb too but don’t allow it for privacy reasons (even though we are just showing predictions so even if we did it wouldn’t be a privacy violation but we want to be super careful not to be creepy).

Thanks Chris! I was missing the user_id parameter. It might help to show that field in the API console. I didn’t realize you could query by Twitter name without oauth till I saw this post. For what it’s worth, I bet you would get a lot more developer usage with some simple changes to the API docs. In addition to the user_id field not being visible, I had a hard time making sense of a few of the other parameters and calls. For example, I couldn’t find a lookup table for the “sites” parameter, so I’m not sure if there are other values than fb or hn… the two shown in the console help tip. I should probably mention, though, that I’m not a developer. I just play around with API’s from time to time to better understand them from a product / marketing perspective. It’s entirely possible that I’m just missing some things that are obvious to more technical folks. I love what you all are working on. Recommendations are the next big thing for the web and you all are doing some of the most interesting work in that area. Keep up the awesome work!