Make Wolfram Language functions available as cloud APIs that can be called from other programming languages or embedded on webpages.

Create an APIFunction

Create an APIFunction that returns the distance between two cities. In this example, TravelDistance returns a Quantity. Applying QuantityMagnitude to that result extracts just the numeric value, which is easier for an external program to process than a Quantity:

Deploy the APIFunction to the Wolfram Cloud

Deploy the function to the cloud with Permissions->"Public" to make the API available to anyone:

Test the API from a browser

Verify that an API works as you expect it to by calling it from a browser. To construct a URL that calls the API, right-click the URL in the CloudObject output of CloudDeploy and choose Copy Address:

Paste the address into a browser search field and append a question mark (?) followed by the names and values of the parameters separated by ampersands (&)for example, "?city1=Chicago&city2=Miami":

Call the API from a non-Wolfram language

Get the code for calling the API from Python:

Paste the embed code into a Python script:

Run the Python script:

$ ./APITest.py 
1378.25516483735

Notes

Calls to APIs deployed in your account use your Cloud Credits.
Parameters can be any Interpreter type, including countries, currencies, colors, dates and email addresses.
You can specify what format the API should use when returning its results:
To call an API function programmatically from the Wolfram Language, use URLExecute, giving the API arguments in a list:
To give an API a more mnemonic URL, specify a CloudObject name in the deployment:
You can substitute your Wolfram Cloud account name for user-xxxxxxxx-...-xxxxxxxxxxxx in the URL to make it even easier to remember and type:
To give an API a short URL, use URLShorten:
The short URL functions just like the original:
A deployed APIFunction can be embedded in a webpage so that what it returns is inserted in the page when it is rendered.
Make an APIFunction that returns a clock face showing the local time in a city:
Get the embed code for calling the API from HTML (the default):
Insert the embed code into an HTML document and add APIFunction parameters after _embed=iframe:
The resulting webpage:
An API can allow parameters that place limits on computational resources, specify different export formats or return debugging information using AllowedCloudExtraParameters.
An API can allow a variety of sources and different syntaxes for inputs using AllowedCloudParameterExtensions.