18F/18f.gsa.gov

View on GitHub
_posts/2016-04-22-what-is-an-api.md

Summary

Maintainability
Test Coverage
---
title: "What is an API?"
authors:
- michael-walker
tags:
- api
- data access
excerpt: "An API is like a grocery store, helping you get bananas without having to plant a banana tree."
description: "A description of APIs using a metaphor of a grocery store."
image:
---

If you spend much time around software people, you’ll inevitably hear
the term “API.” But what *is* an API, and why does it seem like they’re
used for *everything*?

API stands for “application program interface”, and it’s essentially a
way for one computer program to make its data and functionality
available for other programs to use. That way, interesting functionality
and data don’t have to live in the same program forever — they can be
reused by other programs to do whole new things.

A metaphor might be a grocery store. A grocery store is an API for food.
You can go to the store to get food without having to know how that food
got there, and the design of the store helps you find the specific food
you want. For example, you go to the produce section for bananas, not the
dairy aisle. You don't have to know how to grow bananas, how to harvest
them, or how to ship them; you only need to know that you want them. The
store "hides" the how so you can focus on what matters to you — getting
some food.

Once you’ve got the food, you can do things with it that the grocery
store wasn’t designed to do. For example, you could make some really
good banana bread, grill some burgers for a cookout, or make sandwiches
for a picnic in the park. You wouldn’t be able to do those things
without the food, and getting the food was easy because the grocery
store was there to do a bunch of things to make the food available.

APIs serve much the same purpose. The [Federal Election Commission has
an API](https://api.open.fec.gov/developers/), for example. That API
lets you get things like the history of elections a candidate has
participated in. Sure, you could go hunt that information down from
various sources yourself, just like you could plant your own banana
tree, but thanks to the API, you don’t have to. The FEC harvested that
data, and now you — and anyone else — can do something interesting with
it!

Interested in seeing what “groceries” you can get from APIs? Check out
[data.gov](https://api.data.gov), a collection of APIs maintained by
the federal government. It’s full of cool stuff, like data from
[NASA](https://api.data.gov/docs/nasa/) or the [National Institutes
of Health](https://api.data.gov/docs/nih/)! Learn more about [APIs in
government](https://www.digitalgov.gov/2013/04/30/apis-in-government/) from DigitalGov.