Tips and Tricks - Using Web APIs

Tips and Tricks - Using Web APIs

December 6, 2016

Using third party APIs (Application Program Interface) has become a cornerstone of modern day web development. Developers use APIs to retrieve tweets, Facebook updates, and other powerful data for their apps. With simple REST interfaces and JSON payloads, companies are allowing developers to easily tap into their data at little to no cost. APIs make it possible for application developers to aggregate and derive information from the most widely used platforms worldwide. What's not to love?

APIs do have their limits, and quite literally! Sure it's great to display tweets on your site, but you will hit walls fast if you don't understand request rate limits beforehand. Developers often get too wrapped up in whats available to them without thinking about how their app will ultimately consume the data. Here are some tips and tricks to effectively using third party data in your web apps.

What are you doing with the data?

You may just want to display a user's last 5 tweets. You may want to save these tweets to your own database for future use or modification. Let's say you want to create your own data objects from a user's Facebook status. In this case, you would want to both pull in the user's information and create a data object for your own data store. Maybe you just want to analyze the data or write it to a file? It's important to understand what you will be doing with the data because it can dictate the architectural choices you make (across the entire stack).

Are There Data Limits?

Every API is different. Facebook doesn't have a publicly available chart showing you any official limits, but if your requests get out of hand, they will stop you. Twitter is far more transparent. They give you a detailed break down of each request and the rate limits associated with it. They also operate on a 15 minute window timer so you will see things like 15 requests per window. This really means you can't make more than a request a minute for that particular endpoint. Additionally, Twitter differentiates between 'application' requests and 'user' requests and the limits can vary for each.

Even with such limitations, data is largely available. If you are just getting started with third party APIs, then you'll be surprised at just how much you can retrieve. Remember that companies/platforms typically want you using their data just as much as you want it from them!

Authentication

Most popular APIs use some version of Oauth to authenticate calls. This can sometimes be more complicated than it needs to be. With community rich platforms like Node and RoR, there are plenty of modules/wrappers for more easily handling OAuth related tasks. Be sure to fully understand the authentication process and resources available beforehand before using any particular API.

Other Costs

Sadly enough, APIs aren't always free. Many times third party vendors will give you a taste of their data reservoir but then charge you for more detailed information. Companies like Plaid and Yodlee allow developers to get financial institution data but at a steep cost. Some of these are only available as 'enterprise solutions'. It's important to understand the potential cost of using such an interface. Be sure to know the details behind what data you need and charges you may incur beforehand.

Conclusion

There really isn't anything bad to say about APIs. They are getting increasingly easier to use and provide developers with endless opportunities. Just be sure to really think about the end goal before jumping in. Analyze the costs and be sure you are correctly harnessing the power of these great resources.


Join the conversation...



Submit

twitter does have their rate limits and you will get caught if you try and abuse the twitter REST api. i had an account that I was sending out hundreds of tweets with and they suspended my account. make sure you are aware of rate limits when using apis and understand all costs involved etc.
Posted by Steve Jermaine on April 23, 2017


More by the stackchief