As you may have read on my LinkedIn or elsewhere, in the last year or so, I started working with APIs fairly regularly at work. A couple of the APIs I’ve used are WishList Member, Mandrill, Stripe, and ActiveCampaign.
At my job, we use APIs to store customer information (name, phone, email, etc.) in various sites (text messaging system, email distribution system, payment system, etc.) from a single form on our sites.
Before I started working with APIs, the closest thing I had done was make a form that dual-submitted to two iframes (based off this example). I hadn’t used AJAX yet, and honestly, I didn’t understand enough of it to realize that I could use it.
The first API I connected to was GetResponse. Since my background isn’t exactly in computer science, I didn’t know any of the terminology, didn’t understand JSON Objects, and thought a “callback” was some sort of telemarketing technique. Needless to say, I had (and still have) a lot to learn. So here is a collection of things I wish I could teach to my slightly younger self about using APIs…
- Know the basics of what an API is.
- Know the terminology.
- Understand JSON and JSON Structure.
First and foremost, API stands for Application Programming Interface. It is a way for an application to connect to and interact with an existing (and probably external) system. I bought a book called PHP Web Services which is a really helpful guide to understanding header requests/responses, when to use JSON/XML, and what REST and SOAP mean. It’s only 104 pages long and I’ve highlighted and bookmarked in every section. I’d highly recommend the book to anyone working with APIs.
There’s this awesome open source project called API Glossary that I would have loved to know about when I started working with APIs. I mostly relied on the documentation from GetResponse to figure out what everything was. And though callbacks and webhooks aren’t a API-specific terms, this was my first exposure to them. So it would have also been helpful to understand what callbacks are and what webhooks are.
The best resource out there is (surprise) JSON.org. They describe JSON as “the fat-free alternative to XML.” Most of us have probably heard about or used XML for dynamic content before, so with just that, we understand so much more about what JSON actually is! The charts show the structure of JSON, which is based off the structure of JavaScript object literals. JSON is language-independent, so you do not need to use JavaScript with it. The structures shown on JSON.org help with parsing especially, and illustrate the differences between arrays and objects.
Connecting to others’ APIs is a great way to enhance your application/site without reinventing the wheel. Now get out there and make your application awesome!
