How to Generate API Keys for IndexNow#
Why Use an API Key?#
To use the IndexNow API, you need to set an API key on your website to verify ownership of your domain. This should be kept secret and is required every time you submit a URL to the IndexNow API.
Generating Custom API Keys#
If you don't want to use the API key generator from Microsoft Bing, you can create your own API key.
Requirements#
According to the IndexNow documentation, the requirements are:
IndexNow API Key Requirements
Your-key should have a minimum of 8 and a maximum of 128 hexadecimal characters. The key can contain only the following characters: lowercase characters (a-z), uppercase characters (A-Z), numbers (0-9), and dashes (-).
Basic Usage#
In this example, we will generate a random 32 character hexadecimal string as an API key using the generate_api_key()
method:
Python | |
---|---|
1 2 3 4 5 |
|
This will print a random API key of 32 characters. Example:
5017988d51af458491d21ecab6ed1811
Custom Length#
The generate_api_key()
method can also generate API keys of different lengths. Simply adjust the length
parameter:
Python | |
---|---|
1 2 3 4 5 6 7 |
|
This will print two random API keys of 16 and 64 characters. Example:
5017988d51af4584
5017988d51af458491d21ecab6ed18115017988d51af458491d21ecab6ed1811