To generate and use an IndexNow API key, follow these steps:
-
Generate the API Key
- Visit the official Microsoft Bing IndexNow key generation page at bing.com/indexnow/getstarted to generate a unique API key automatically.
- Alternatively, you can create your own API key by generating a random string of 8 to 128 hexadecimal characters (letters a-z, A-Z, numbers 0-9, and dashes). For example, using Node.js or Python code to generate a 32-character key is common.
-
Host the API Key File on Your Website
- Create a UTF-8 encoded text file named exactly as your API key with a
.txtextension (e.g.,yourapikey.txt). - Upload this file to the root directory of your website (e.g.,
https://www.example.com/yourapikey.txt). - This step verifies ownership of your domain to search engines using IndexNow.
- Create a UTF-8 encoded text file named exactly as your API key with a
-
Submit URLs to IndexNow API
- Use the API key and the URL of the hosted key file to submit URLs that you want search engines to index or update.
- You can submit URLs individually or in bulk via HTTP requests to the IndexNow API endpoint (
https://api.indexnow.org/IndexNow), including parameters for your host, key, keyLocation (URL of the key file), and the list of URLs to submit. - Example JSON payload for bulk submission:
{ "host": "www.example.com", "key": "yourapikey", "keyLocation": "https://www.example.com/yourapikey.txt", "urlList": [ "https://www.example.com/page1", "https://www.example.com/page2" ] } -
Verify Submission
- Use tools like Bing Webmaster Tools to confirm that your URLs have been received and processed by search engines.
Additional Notes:
- Keep your API key secret; only you and the search engines should know it.
- The API key is required every time you submit URLs to authenticate your requests.
- If you prefer, you can generate the key programmatically using code snippets in Node.js or Python, which is useful for automation.
This process ensures that search engines like Bing and Yandex can quickly discover and index your updated or new web pages via the IndexNow protocol.
