Index

An API Is an Agreement


The concept of an application programming interface (API) has been around a long time, and it's a simple concept.

For API's -- think agreement.

Two programmers (coders) meet to try to agree on implementing and using the function for a mathematical square root.

One coder will consume (use) the function, and the other will provide the function.
Square Root
The two coders agree on the interface (method header) shown.

These coder's are using Java syntax but this applies to any language, or may be language independent as we'll see below with the web API
double sqrt(double x)
/*Where:
	the function receives one number as input "x"
	the function returns the square root (a number)
	double means floating point number*/
The API provider codes up the logic to satisfy the agreement (e.g. computes the square root of a number).
double sqrt(double x) {
	//The coding magic done by the provider
}
The API consumer codes up the function call that will be used to call the API provider.
double result = Math.sqrt(49);
A Web API follows the same pattern -- only the syntax differs.
https://www.mathy.com/sqrt?x=49

/sqrt -- effectively the function name
x=49 -- is the input


API Purpose


Generally we code some logic and then we (or our team) codes a view (e.g. website) uses that logic.

But how would you like to make your logic available to developers across the entire www? Or, similarly, use logic coded by developers anywhere on the www.

Here is just one API listing to get an idea of what is available.