The API key consists of randomly generated characters of alphabets and numbers. You associate a specific API key with a specific API client. Since API usage is essentially one software module talking to another, the keys are associated with different software modules or applications that want to talk to your API.
When an application sends API requests, the process works as follows:
- The API server validates the requestor's authenticity with the unique API key
- If the API key doesn't match any of the permitted ones, the server declines the API call and sends a rejection message
- If the API key matches, the server fulfills the request and returns the expected response
This way, API keys allow the API server to identify the origin of each API call. The server can then perform subsequent validations to authorize access to the API's data and services.
Limiting API calls
API providers can use the API key to regulate varying degrees of access to their API services. Upon validating a request, the API server can check some parameters before allowing further access to its services.
Extent of service
The server determines the extent of services it could grant to the requesting application. For example, some API keys permit the requestor to add, delete, and read information from the API's data storage. Others might limit API calls to reading information only.
Choice of functions
The server determines and imposes the scope of the API call to customize their API services. For example, you can use API keys to limit an ecommerce application to searching product data in specific countries. You can also associate specific API keys to certain database parametric filters, such as books and apparel.
Number of calls
API providers also use API keys to tightly regulate API access. Some providers apply time or request limits to their APIs. In such cases, the client application can only use the API for the stipulated duration or up to a capped number daily. Once the limits are exceeded, the server declines any requests from the associated API keys.