Think about your personal experiences using ride-sharing mobile apps like Lyft. You’re able to request a car to your exact geographic coordinates, right down to the street corner. This functionality is possible thanks to application programming interfaces, or APIs.
An API is a platform that allows different pieces of software, or applications, to communicate with one another. The term is used broadly in the context of programming languages, the web, operating systems, etc. For example, Apple publicly shares a number of APIs powered by iOS, its operating system for iPhones and iPads, for an app developer to use. These APIs allow applications like Facebook, Instagram and Snapchat to access a user device’s camera, microphone, and much more.
What Is an API?
APIs can fall into a number of subcategories. Many web and mobile applications, as well as devices (e.g., Amazon Echo), rely heavily on what are known as web APIs, which we’ll focus on in this guide. A web API uses the same underlying technologies as web browsers to allow different applications to communicate with one another. Web APIs allow applications to retrieve data or perform actions beyond their built-in capabilities. Typically, an application, using the internet, requests some data or action from an API. The API provides a response, and the application then adapts and displays it. The API’s code is hosted on a web server, which is essentially a computer connected to the internet. Depending on the functionality the API is providing, there may be an additional layer of security involved, such as sending a unique key.
Let’s consider a mobile weather application like Dark Sky. When you use it to check the weather for a certain zip code, the application makes a request to the API tool asking for the weather in that zip code. The API has access to the weather data and returns it as its response. Then, the application goes through the weather data and selectively displays it as, for example, the temperature in degrees Fahrenheit. The same process occurs if you check the weather in another city or at your current location.
How to Use an API
For any given programming language, there’s usually at least one popular framework — a collection of programs — that can be used to create APIs. Ruby developers, for example, use the Rails framework. Developers can also use packages to add features to their APIs, such as additional layers of security. Any additional necessary programs or packages are usually installed with that language’s package manager, e.g., Ruby’s bundler.
How Does an Internal API Work?
An internal API is one that’s used within a company or organization, although the company can choose to make portions of it accessible to the public. Users within that organization can leverage an internal API to share data and business logic (for example, the company’s rules regarding communication between a user interface and a database) across platforms — i.e., web, iOS, or an Android app. Any company with both web and smartphone apps likely has an internal API.
For example, the food-ordering service, Seamless, has web, iOS, and the Android app. All three platforms use an internal API to request that an action be performed, like placing an order for a client, as well as to request data, like the details of a user’s most recent order. This internal API allows Seamless to internally share data (restaurant information) and business logic (a customer ordering a dish) across different devices.
How Does an External API Work?
Many organizations provide external — albeit sometimes limited — APIs and documentation that allow individuals and companies outside of that organization to develop applications using its services. Depending on the external API, there may be registration, payment, or other limitations involved. For example, The New York Times provides an extensive external API that is free but requires that developers register and follow certain guidelines.
Google Maps also provides APIs that allow developers to embed maps in their websites and applications, as well as access directions and estimated travel times. Lyft, for example, uses Google Maps’ API. Other popular external APIs include Yelp’s Business APIs, which enables the user to find businesses, the OpenWeatherMap API, which retrieves weather data, and the Microsoft Azure Emotion API, which determines emotions in images.
Using external APIs allows developers to create their own mashup applications, like one that uses the Yelp Business API to find top-rated coffee shops in a neighborhood and display them on user interfaces as a map with custom icons via the Google Maps API.
APIs at General Assembly
Meet Our Expert
“Given that more than half the world’s population has internet access, with more to come, now is a great time to learn web development to create applications and reach that audience.”