When using API key authentication, the API service is providing an API key for each user – and the user is required to send the API key with each request. Usually this API key is sent in request headers and an exact way is described in the API service documentation.
Let's see, how you can set it up in RESTwithUS:
To set the provider for API key authentication, first select your API provider from the list and open Details:
Set the Authentication field in Login section to No Auth
:
This step is optional, but highly recommended. You can enter the API key value directly into provider headers (see next step), but since this is a sensitive information, it’s better to use provider variables.
To set provider variables, select your API provider from the list and open Related / Variables:
Make a new line, name your variable, enter the API key value and check Hide Value checkbox:
Let’s say your provider requires an API key and you need to send it with each request in the HTTP header called Api-Key
. (Name of this header is usually different for each API service and you can find it in the provider documentation.)
To set provider headers, select your API provider from the list and open Related / Headers:
Now, create the header for the API key and fill in its value:
ApiKey
during the last step and you can now get the value using syntax {{ApiKey}}
for an optional variable or {{!ApiKey}}
for a required variable.Tip: If a provider needs more than one header for authentication, just make a second line in provider headers. All headers in this list will be sent with each provider request.