Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Great APIs

1,008 views

Published on

My lightning talk on one aspect of what I think makes a great API. Given at IPRUG in March 2013.

  • Be the first to comment

  • Be the first to like this

Great APIs

  1. 1. Great APIs @ChrisSinjoIPRUG – 05/03/2013
  2. 2. A piece of a larger talk
  3. 3. Caution: Opinions ahead
  4. 4. What is “great”?Spend most time here Nice high level APIsGo here when I’m doing Powerful, underlying something awesome toolset
  5. 5. Git calls this “porcelain” and “plumbing”
  6. 6. Example: get something over HTTP
  7. 7. In my mind (psuedocode)# Gives me the response contents as a stringprint HttpLibrary.get(http://ifconfig.me/ip).body
  8. 8. In Ruby (with HTTParty)puts HTTParty.get(http://ifconfig.me/ip).body
  9. 9. Caution: Serious, heavy-duty, enterprise language for people with beards ahead
  10. 10. In Java (with commonly recommended HttpClient)HttpClient httpclient = new DefaultHttpClient();HttpGet httpget = new HttpGet("http://ifconfig.me/ip");HttpResponse response = httpclient.execute(httpget);HttpEntity entity = response.getEntity();if (entity != null) { InputStream myIpStream = entity.getContent(); try { BufferedReader reader = new BufferedReader( new InputStreamReader(myIpStream, Charset.forName("UTF-8"))); String nextLine; while ((nextLine = reader.readLine()) != null) { System.out.println(nextLine); } } finally { myIpStream.close(); }}
  11. 11. In Java (with fluent-hc wrapper)String ip = Request.Get("http://ifconfig.me/ip") .execute().returnContent().asString();System.out.println(ip);
  12. 12. This isn’t a language thingAt least not entirely (syntactic flexibility aside)
  13. 13. Community focus? Broadly: Java: ↑ plumbing Ruby: ↑ porcelain
  14. 14. There is more to great APIs than this
  15. 15. Questions?

×