Defining API Keys
Define API keys, and learn the difference between required keys and extracted keys.
We'll cover the following
Global API keys
In order to use the API onboarding feature, we first need to define all the keys that the course will use in any of its lessons. This is done in the “API Keys” section of the course editor page.
Here, you can find the section on “API Keys”, as shown in the image below:
Key (Required): The API key name that will be required for any API to function.
Value (Optional): This is the default value of the key if the learner does not give the value of the key (this will be empty in most cases).
Help Text (Optional): This field can provide learners guidance about the API key’s value. The help text can be some steps on how to get the key’s value or some URL.
Help text will be shown to users when they click on the help icon:
Save/Delete icons: The author may save or delete each key
Types of keys
There are two types of keys:
- Required keys
- Extracted keys
Let’s discuss each of these briefly.
Required keys
Some APIs in code playgrounds require variables to be specified before execution. To do this, the author needs to select the “required keys” that a particular playground will require before execution. Required keys are not always derived or extracted from previous lessons or playgrounds. Sometimes a learner might have to enter them manually to run a playground.
Extracted keys
These are the variables defined by the author and then extracted from the console output of a playground using “Output Transform” (explained in a later section). An example of extracted keys is an API generating a key that is to be used by another API. These can then be used in subsequent widgets in any lesson.