Advanced API Design: how an awesome API can attract friends, make you rich, and change the world
103
Advanced API Design How an awesome API can attract friends, make you rich, and change the world Jon Dahl @jondahl [email protected]Monday, May 23, 2011
Advanced API Design: how an awesome API can attract friends, make you rich, and change the world
POST /api/user HTTP/1.1Accept: application/jsonContent-Type: application/json
{ "api_key" : "A23B92F281CC" "strength" : 18}
Monday, May 23, 2011
HTTP/1.1 400 Bad Request
Monday, May 23, 2011
HTTP/1.1 400 Bad Request
{ "errors": [ "JSON is not valid. Syntax error, unexpected TSTRING, expecting '}' at line 2" ]}
Monday, May 23, 2011
JSON + XML
Monday, May 23, 2011
Monday, May 23, 2011
Monday, May 23, 2011
POST /api/user HTTP/1.1Accept: application/jsonContent-Type: application/json
{ "api_key" : "A23B92F281CC" "strength" : 18}
Monday, May 23, 2011
params[:strength] # 18
Monday, May 23, 2011
respond_to do |wants| wants.json { render :json => @jobs.to_json } wants.xml { render :xml => @jobs.to_xml } end
Monday, May 23, 2011
Document it
Monday, May 23, 2011
Zencoder::API.define_setting :audio_channels, :section => section do |z| z.tip = "The number of audio channels: 1 or 2." z.description = %Q{ <p>The number of audio channels to use: 1 (mono) or 2 (stereo).</p> <p>Note that mono AAC audio sometimes erroneously self-reports as stereo when inspected. We recommend using iTunes to get the true number of channels for AAC audio.</p> } z.data_type = "Integer" z.valid = "1 or 2" z.default = "1 if the original file is mono; otherwise, 2." z.example = "1" z.see_also = [:audio_bitrate, :audio_quality]end
Monday, May 23, 2011
Monday, May 23, 2011
Libraries
Monday, May 23, 2011
Support it
Monday, May 23, 2011
APIs are scary.
Monday, May 23, 2011
Make it fast
Monday, May 23, 2011
Rate limiting
Monday, May 23, 2011
Log requests
Monday, May 23, 2011
Monday, May 23, 2011
Monday, May 23, 2011
Request builder
Monday, May 23, 2011
Monday, May 23, 2011
Monday, May 23, 2011
GET /api/ideas
Monday, May 23, 2011
1. Make friends
Monday, May 23, 2011
Monday, May 23, 2011
Awesomeness is noticed
Monday, May 23, 2011
(Assymetrical reward curve)
Monday, May 23, 2011
value
quality
Monday, May 23, 2011
value
quality
Monday, May 23, 2011
value
quality
Monday, May 23, 2011
Bus Driving
quality
value
Monday, May 23, 2011
Bus Drivingvalue
quality
Monday, May 23, 2011
Monday, May 23, 2011
Sportsvalue
quality
Monday, May 23, 2011
API designvalue
quality
Monday, May 23, 2011
"I know the following statement is going to sound dramatic, but it's the truth. Zencoder seriously uplifted my entire day.
The API is really well designed and has documentation for not only what each value should be but also what an example input/output would look like using the value. I had spent the earlier part of the day working with a web service that is the complete opposite of those things.
So when I started digging into Zencoder I felt like I was witnessing a double rainbow. Then when I found the API Builder, it went beyond a double rainbow to a level I can only imagine is equal to witnessing a unicorn birth.”