Christian Heilmann

Author Archive

Dear API Developers, this is what I would like to have

Wednesday, November 7th, 2007

Jonathan Boutelle of Slideshare reacted to my slideshare show widget and liked how I hacked around the API by re-using the RSS feed. He now asked in the comments what I’d like to see from an API. Well, here goes:

  1. Allow for “hackable” URLs, with definition of the output. Flickr and Del.icio.us are good examples, especially the del.icio.us option of defining a callback for the JSON: http://del.icio.us/feeds/json/codepo8 gets me a JSON data wrapped in a Delicious object, http://del.icio.us/feeds/json/codepo8?raw gets me the raw JSON data and http://del.icio.us/feeds/json/codepo8?raw&callback=foo wraps it in a function call to foo(). This rocks! The same goes for defining the output as the last parameter. Flickr does that well – http://api.flickr.com/...format=json for JSON, http://api.flickr.com/...format=rss for RSS, http://api.flickr.com/...format=lol for LOLCAT
  2. make sure that the JSON output is easy to use and does not have any annoying bits (encoded HTML or namespaced attributes – the description property in the flickr JSON to me is pointless weight for example)
  3. make the URL as logical as possible, I don’t like to have to use the user ID in flickr for example when the readable user name would be easier to do.
  4. it’d be great if you could send a unique ID as a parameter as that would allow you to match returned data to calls (as both dynamically created script nodes and Ajax calls may return in any order)

However, all of this does not replace the real API, which should

  1. allow me to define only the data bits that I need (and cut down to the smallest possible feed – no twitter, 150kb JSON is not good!)
  2. give me extras when I go through a developer ID. How about offering me free stats (even as an own API) when I build a widget that uses my ID - we do this now to throttle usage anyways. In a second phase this could also be used for a revenue sharing program.
  3. offer things like enforced authentication (you know the photos you don’t want to show your mother)
  4. allow for local caching methods (deliver the data gzipped for example)
  5. allow me access to things that the open REST calls don’t (my sets, my favourites, my contacts, my profile settings)
  6. be read and write – I want to build widgets that allow data entry from my blog to your systems, without leaving it.

Anything else?

[tags]API,wishlist,REST,JSON,slideshare[/tags]

Sending objects as parameters – good or bad?

Wednesday, November 7th, 2007

One of the differences I keep seeing in functions and methods lately is that people seem to go away from the strict pattern of expecting parameters in a certain form. If you look back some years you might remember functions like the following:


function doLayerFloat(id,start,end,direction,speed,fade,whatelse,Iforgot){
...
}

This, at least to me is rather annoying as I am terrible at remembering the order the parameters need to be sent in (conditioning in PHP confusion probably). The other issue I kept seeing with this was that if you didn’t want to provide some of the parameters but one of the last ones you had to send empty strings or even null values:


doLayerFloat('myDIV',0,30,null,null,true,null,null){
...
}
// or
doLayerFloat('myDIV',0,30,'','','','',''){
...
}

This is both confusing and convoluted. Other scripts I have seen work around the issue by using the arguments array, which at least allows a flexible amount of arguments to be sent.


function doLayerFloat(id){
var args = arguments;
for(var i = 1; i < args.length; i++) {
...
}
}

However, my favourite these days is functions that actually take a few defined parameters (or a single one), allow for it to be several things and allow you to send an object as the properties:


function doLayerFloat(id, props){
var elm = typeof id !== 'string' ? id : document.getElementById(id);
for (var i in props){
...
}
}

This allows the id to be either an element reference or a string and takes an object as the second parameter in which I can define the order and amount any which way I like (provided the method then tests for each of them and their correct values):


doLayerFloat('x',{start:20,end:30,fade:true});
// or
doLayerFloat(myElm,{fade:true,direction:'right'});

This also allows you to define default values should the properties not be set, something you can do in PHP but not in JavaScript. In PHP, this works:


function foo($bar=2,$baz='foo'){
}

In JavaScript that can’t be done, but if you use an object you can predefine if the properties are not set:


function doLayerFloat(id, props){
var elm = typeof id !== 'string' ? id : document.getElementById(id);
props = props || {};
props.start = props.start || 100;
props.fade = props.fade || false;
}

Do you agree? Or is the object literal syntax still too tricky?

[tags]javascript,syntax,parameters,object literal,objectliteral,arguments,codestyle,webdevtrick[/tags]

Sky is dishing out £10k for widgets using their RSS feeds

Tuesday, November 6th, 2007

Well, in a competition, not just directly. I like the idea of Sky News’ Developer Competition where they offer all in all £10k in prize money for widget and badge implementations of the content of their RSS feeds.

Talented developers can use the feeds to create their own applications. The brains with the best ideas will be invited to a Dragons’ Den-style judgment day at the Sky News studios.

A bit of a shame is that they haven’t got an API yet, but I pointed them to Yahoo! Pipes to offer developers as a workaround to use the RSS feeds in an easier manner.

The deadline is 30th of November and the Dragon’s Den shootout is on the 20th of December in the Sky offices. So if you want to have a go, get coding :) Make also sure you check the Terms and Conditions of the competition.

[tags]sky,competition,10k,RSS,news,pipes,UK[/tags]

So what is the deal with the new gmail crashing my Firefox (or stalling it)

Tuesday, November 6th, 2007

I am a big fan of gmail (and a lot of colleagues scowl at me for it). With the massive amount of emails I get daily and me working on 3 computers there is just no other way to get around them.

Until the latest update of gmail though. Now my two laptops (both Windows) get stuck and I have to shoot down Firefox 5 times a day to be able to work. Sorry Google, but what happened? I turned off Firebug as you asked me to and yet it messes up. I also tried switching to the “older interface” but my setting does not get stored (yes, cookies are enabled).

I also tried to turn off sounds of the chat inside gmail but yet it keeps crashing. Don’t make me change because of superfluous bells and whistles, I have too many good contacts in your system.

[tags]Google,gmail,googlemail,firefox,crashes,annoyance,wtf[/tags]

PlugLondon – let there be talk, let there be beers and let there be London developers shape the event

Monday, November 5th, 2007

Once in a while you realize that a lot of people are like you. When I joined a big internet corporation a lot of people asked me if I will shut up about bad things on my blog or if I will become a company drone now. The joke never gets old and I told some other people in the same situation about it. Well, we drank some beers, chatted and now it is time to take action:

PlugLondon is a meetup for developers in London in December sponsored by ebay, Yahoo, Skype and Paypal.

The catch? All of the people involved agreed on leaving both HR and PR out the door and do the thing ourselves. So on the 8th of December we want all the London people who drive software innovation to show up, chat with us about their products, how they use our APIs, get info from our experts and of course have several beers and food.

We are planning on repeating the exercise every half year and basically want to show that London can be as cool as the Valley but not as annoying to get to for UK folks.

The event has no branding yet and we invite people to give us logo ideas. The audience at the first meetup will choose which is the best and we go from there.

So come around, check out the different parts:

See you there,

Chris
[tags]pluglondon,social,meetup,event,london,uk,newmedia,yahoo,skype,paypal,ebay[/tags]