Web APIs - Getting Started

Mar10
By Albert Zaballero, Senior Web Developer

A big plus for web developer these days is the abundance of web APIs that can introduce functionality to your web site that under many circumstances would be difficult to achieve.

When you think about the things you can do on the web like search, use a map, find a review or even post an update to your favorite social-network, you would normally go to the web site or application that lets you do that. But, what if you want to use some of those features on your own web site or application? As it turns out, popular services like Google, Facebook, LinkedIn, Yelp and many more offer web APIs of their platforms that almost anyone can use.

Although the specifics for each API varies, they generally have things in common:
  • Provide REST or JavaScript versions of their APIs
  • Return standardized data in JSON or XML formats
  • Have APIs that support popular web programming languages (PHP, ASP.NET, etc.)
  • Are free (see their licensing for rules and restrictions)

Getting started typically involves the following:
  • Register yourself and your application with the service you'll be using
  • If applicable, use the service's API console to enable the API(s) you'll be using
  • Generate an OAuth token (this may occur automatically when you register your application)
  • Find and read the documentation on how to load and use the API
  • Test drive the API by trying it out on a "Hello World" application
  • Once you have a grasp of how the API works, start developing with it

Some tips:

  • Learn to navigate and understand the documentation -- It varies from good to bad, from too much to too little, as well as the developer's own knowledge and expertise. More often than not the documentation will contain the information needed to get it to work correctly.
  • Authentication is required for RESTful API calls -- It can be as simple as passing an API key as a parameter when making the API request, while some require OAuth. Again, the documentation will specify which method to use and instructions or code examples on how.
  • For some social-network APIs, additional permission settings are required depending on how the API will be used. For example, permissions to read a timeline are different than permissions to write to a timeline.
  • Understand what the API throttle limits are -- All APIs have throttle limits usually based on the number of requests per day. Similar to exceptions, be sure your application handles this in an acceptable manner should this occur. Often times APIs will reset their throttle limits every 24 hours so that they're renewed everyday. However, be aware that some APIs do use some other scheduling method to reset their numbers, sometimes monthly.

There's always more to it of course and as the old adage goes -- results vary. But, with the right planning and when used correctly APIs can greatly enhance what your application can do and more importantly what your users can do!

Dev

Back To Feed