Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Great APIs

Great APIs

My lightning talk on one aspect of what I think makes a great API. Given at IPRUG lightning talks, and later at a work event.

Chris Sinjakli

March 05, 2013

More Decks by Chris Sinjakli

Other Decks in Programming


  1. What is “great”? Nice high level APIs Powerful, underlying toolset

    Spend most time here Go here when I’m doing something awesome
  2. In my mind (psuedocode) # Gives me the response contents

    as a string print HttpLibrary.get('http://ifconfig.me/ip').body
  3. 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(); } }