Are you concerned about search engine optimization (SEO)? Do you want to make sure your website is indexed frequently by Bing, Yandex, DuckDuckGo, and other search engines?
IndexNow for Python is a lightweight, yet powerful Python package that makes it easy to submit URLs or entire sitemaps to the IndexNow API of various search engines, so your pages can be indexed faster.
Ready to try? Learn how to install and find tutorials in the user guide.
Firstly, ensure that you have an API key for IndexNow. Hereafter, add your authentication credentials to the IndexNowAuthentication
class, which will be used throughout the examples. You can now submit individual URLs to the IndexNow API:
from index_now import submit_url_to_index_now, IndexNowAuthentication
authentication = IndexNowAuthentication(
host="example.com",
api_key="a1b2c3d4",
api_key_location="https://example.com/a1b2c3d4.txt",
)
submit_url_to_index_now(authentication, "https://example.com/page1")
Important
Instances of authentication = IndexNowAuthentication(...)
below refer to this section:
authentication = IndexNowAuthentication(
host="example.com",
api_key="a1b2c3d4",
api_key_location="https://example.com/a1b2c3d4.txt",
)
How to submit multiple URLs in bulk to the IndexNow API:
from index_now import submit_urls_to_index_now, IndexNowAuthentication
authentication = IndexNowAuthentication(...)
urls = ["https://example.com/page1", "https://example.com/page2", "https://example.com/page3"]
submit_urls_to_index_now(authentication, urls)
How to submit an entire sitemap to the IndexNow API:
from index_now import submit_sitemap_to_index_now, IndexNowAuthentication
authentication = IndexNowAuthentication(...)
sitemap_location = "https://example.com/sitemap.xml"
submit_sitemap_to_index_now(authentication, sitemap_location)
How to use the default SearchEngineEndpoint
options or a custom endpoint:
from index_now import submit_url_to_index_now, IndexNowAuthentication, SearchEngineEndpoint
authentication = IndexNowAuthentication(...)
endpoint_bing = SearchEngineEndpoint.BING
endpoint_custom = "https://example.com/indexnow"
for endpoint in [endpoint_bing, endpoint_custom]:
submit_url_to_index_now(authentication, "https://example.com/page1", endpoint)
If you find this project helpful, please consider supporting its development. Your donations will help keep it alive and growing. Every contribution, no matter the size, makes a difference.
Thank you for your support! π
If you have suggestions or changes to the module, feel free to add to the code and create a pull request.
If you encounter any issues, you can report them as bugs or raise issues.