An API is pre-written code.

You can read about APIs and not understand them. This is especially true if you don't use them and don't program. Even knowing the term API does little for you. It's the equivalent of knowing CIA. You can understand the words, but you don't really know how it works.

If I write an equation 2 + 2 = 4, you'll know I'm starting out slow. If we remove the 2 and put in a letter that could be any number, we call that a variable. The letter is X, a favorite in beginning Algebra. Our new equation is x + x = ___  

What do you put in the blank? If X is 3, you get 6. If X is 4, you get 8. The new formula could be written, x + x = y.

In a computer program, I could write this equation and print the result on the screen. To re-use the formula, however, I can label the code. Anytime I want to use that code in the future, I'll use the label and the values I want the code to work on.

Labeling an equation in code is called writing a function. To use a function you type in the name of the function and include the values the code needs to do work. 

A function is an API. 

When you use functions written by other people — you're calling an API. That's it. Calling an API is the code (words, numbers and punctuation) you type to use pre-written code. The code could be previously written by you or somebody else. That's an API.


In JavaScript - this could be a function that returns the addition of the values 2 and 7. Anywhere in my code I call this, I can expect the number 9 to be used.

If I call this API on a list of pairs of numbers, I can do lots of sums very fast. This is the value of an API.

I like this explanation, but it leaves me wondering why I always see "API" mentioned in the context of different websites "talking" to each other. Do coders use the term API for all kinds of different things, and I just happen to see it only in this one context?
2021-03-30 19:14:43