Plannedscape Postings

Image

What's An API (Part 4)
Web Services and APIs

Posted by Charlie Recksieck on 2019-10-31
(Click here to read the overview, Part 1 of What’s An API?.)

Author’s Note: This series is intended for a more general audience to understand broad concepts, not a how-to for developers. Although hopefully it is of use to developers to contemplate the nature of these terms too.

* * *

Now we’re cooking. In Part 2 we discussed operating system APIs which are so basic to computing and programming that they are almost not worth thinking of as APIs (but they are). In Part 3 we explored how developers can use other apps/developers’ APIs in their own code.

APIs on Web

Despite what we’ve illustrated above and previously about some types of true APIs in in locally-run applications, here in 2019 when you hear talk of "APIs" people are more frequently talking about web APIs.

So when we’re talking about APIs now, we would be talking about calling them in websites, either in HTML or server-side languages like PHP, ASP.NET, C#.NET, etc. It really helps to have a technical background in coding to fully wrap your head around non-web (operating service APIs and application APIs). Yet when we talk about web APIs, things get a little easier. We’re talking about HTML and even pretty easy copy-and-paste plugins for your website that call APIs.

Let’s say you’re embedding a YouTube video in your side. Basically, all you have to do is copy this in your HTML iframe src="http://www.youtube.com/embed/l-T11erq_kI"
width="560" height="315" frameborder="0" allowfullscreen>/iframe
. By the way, you’re welcome for this YouTube video of David Letterman & Michael Keaton singing and dancing

Embedding that doesn’t seem like sophisticated programming, but you truly are using an API.

Remember our definition from a couple weeks back: An API is an interface that software code can use to execute a command or retrieve a set of data.

Whether you’re calling a video or showing some tweets with a code snippet or calling a web service to retrieve data in more complex back-end, server-side code, you are using an API. Maybe now is the time to ask a symantic question: Are you using a "web service"?

Web Services

So what’s a web service?

In the web portion of our Part 1 API series, the high-level overview, we mentioned that "all web services really are APIs, not all APIs are web services. Also, ’web’ services happen over the web - that could still be within a network, but let's just say they are in a spot where you could hit them in a browser (being hosted like a web page is hosted)."

An API can be much more interactive, where the back-end code in your page can have extended interactions with the API over many lines of code. Web services usually mean that you’ll call a specific URL and just get back an XML-formatted result of data in one shot.

To see an example of a web service, let’s again look at a web service giving vehicle data. You supply the VIN number to the National Highway Traffic Safety Administration website for a car and it comes out like this: here are the results from NHTSA.

Some Web Service Particulars

You’ll find that bona fide web-based APIs usually are very well-documented, whereas you’re probably not going to be very lucky with documentation for web service results. Hopefully a web service has its parameters that you can send well-documented. For example, if I’m using a weather web service, I’d like to know if I send it longitude/latitude coordinates, city names, zip codes, or could be a any one of those.

Web services do have specific protocols (REST and SOAP being the most prevalent for a while now; neither one is not hard to master; if you need to hire somebody to work with your SOAP web services, don't worry that his/her experience is more with RESTful services). I mention this just to clue you in to think of web services if you hear "REST" or "SOAP" being discussed.

There are plenty of great helping apps or Visual Studio plugs in help you create a web service, should you need to. But it’s more likely that you might need an app to help you test hitting somebody’s web service and seeing what the results are. I can’t recommend Restlet Client enough, it’s available as a Google Chrome plugin. You can hit a web service, see real results, and also see some things that might help when the service doesn’t give a lot of documentation ... all without having to write any code.

You very likely might use web services completely internally - they don’t have to be public on the web and can always require security credentials in the request for info. It’s often the best way for you to allow your company’s internal apps to access centralized data.

Popular APIs, Plugin, Snippets

Here’s a list of some of the most popular web APIs out there in the hopes that it gives you additional context for what a web API really is:

* Twitter: Their main API allows so much great access to core Twitter data. There are hundreds of Twitter apps you can find in your App Store that basically are just putting a friendly front end on data from this API.
* YouTube: As mentioned above, it lets you embed YouTube videos into sites (or apps) but also lets you leverage YouTube data and analytics.
* SoundCloud: Think of it just like the YouTube ones except with audio instead of video.
* Amazon: We were just working on an audit, tune-up and upgrade of an online store and were blown away by the quality of the Amazon APIs.
* Google Maps: So many websites use this popular embedded app in JavaScript or Flash to give you an interactive map; also looks great on mobile.
* Flickr: A variety of photo-friendly functions to show, organize your photos in Flickr.
* Yahoo Finance: While Yahoo’s position vs. Google has generally collapsed, Yahoo Finance’s APIs have been around forever and do a great job.

The Takeaways For Non-Developers

It’s so helpful to you on the business or non-tech side of a company to be aware of web services. Knowing how many are out there (and how traditionally easy they are to use) should really let you come up with new ideas. Nothing really should impossible; the data you want is most likely out there, you just have to think of a use for it that your customers will want.

Also, remember the now almost-interchangeability of the terms "web service" and "API" these days.

If you hear "REST" or "SOAP", somebody’s talking about web services.

Now go out there and see where you can apply this newfound knowledge to your company or your web site!