Deploy a web API that requires specifying a permissions key to use it.

Create an APIFunction

Create an APIFunction that computes the distance between two cities specified by name:

  • See the workflow Deploy a Web API for complete details about how to deploy a web API.

Deploy the APIFunction to the Wolfram Cloud with a permissions key

Deploy the APIFunction to the cloud, requiring a permissions key to use it:

Test the API from a browser

Verify that an API works as you expect 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 (&) and finally, the permissions key preceded by _key=; for example, "?city1=Chicago&city2=Miami&_key=fish23":

Call the API from a non-Wolfram language

Use EmbedCode to get the code for calling the API from Python. Click Copy to Clipboard to copy the embed code:

Paste the embed code into a Python script and add the permissions key to the cloud call:

Run the Python script:

$ ./APITest.py 
1378.25516483735

Notes

To call an API function with a permissions key programmatically from the Wolfram Language, use URLExecute, specifying the permissions key as a _key argument: