Getting Started with a new 3rd Party API
Sep 9, 2013 · Comments3rd party APIs offer tons of creative possibilities for developers. Despite that, getting up and running with a new one can be painful, as each provider seems to implement either authentication or request handling slightly differently.
When working with a new API, I like to approach it in the following way:
- If the API will be an integral part of your application, start by exploring it first, before designing or implementing any other functionality. If for some reason you get stuck (lack of support or clear examples, beta APIs that are constantly changing), you want to minimize wasted effort. Read documentation and see samples of the data you can receive. Some providers even have online tools that allow you to run requests in the browser – these are especially handy.
- The two main areas of a new API to figure out are authentication and making requests:
- You would think that authentication would be straightforward, since every app needs to do it. However, everyone still manages to do something different each time! Thus, I like to start from the top (authenticating) and work my way down (retrieving one resource) to ensure all gotcha’s are found in the process. Retrieving a basic API endpoint via GET request (such as logged-in user details) is simplest. Also (especially for auth standards like OAuth) using a well-established library instead of rolling your own can save a ton of headaches.
- Making requests is far easier than authentication. The main nuance to be aware of is whether the provider wants request details (auth tokens, POST’d data) in the header or the body of the request. Additionally, watch for unique keywords that have to be sent, as these can vary (auth_token=XXXX vs. token=XXXX).
- If you get stuck at any point, then it’s time to reach out to other developers whom have worked on the API, developer forums (StackOverflow), or even the service provider directly.