Skip to content

Submit Entire Sitemap to the IndexNow API#

submit_sitemap_to_index_now()#

Submit a sitemap to the IndexNow API of a search engine.

Parameters:

Name Type Description Default
authentication IndexNowAuthentication

Authentication credentials for the IndexNow API.

required
sitemap_url str

The URL of the sitemap to submit, e.g. https://example.com/sitemap.xml.

required
contains str | None

Optional filter for URLs. Can be simple string (e.g. "section1") or regular expression (e.g. r"(section1)|(section2)"). Ignored by default and if set to None.

None
skip int | None

Optional number of URLs from the sitemap to be skipped. Ignored by default and if set to None.

None
take int | None

Optional limit of URLs from the sitemap to taken. Ignored by default and if set to None.

None
endpoint SearchEngineEndpoint | str

Select the search engine you want to submit to or use a custom URL as endpoint.

INDEXNOW
Example

After adding your authentication credentials to the IndexNowAuthentication class, you can now submit an entire sitemap to the IndexNow API:

Python
from index_now import submit_sitemap_to_index_now, IndexNowAuthentication

authentication = IndexNowAuthentication(
    host="example.com",
    api_key="a1b2c3d4",
    api_key_location="https://example.com/a1b2c3d4.txt",
)

sitemap_url = "https://example.com/sitemap.xml"

submit_sitemap_to_index_now(authentication, sitemap_url)

If you want to submit to a specific search engine, alternatively customize the endpoint:

submit_sitemap_to_index_now(authentication, sitemap_url,
    endpoint="https://www.bing.com/indexnow")

If you want to only upload a portion of the sitemap URLs, alternatively use the skip and take parameters:

Python
from index_now import submit_sitemap_to_index_now, IndexNowAuthentication

authentication = IndexNowAuthentication(
    host="example.com",
    api_key="a1b2c3d4",
    api_key_location="https://example.com/a1b2c3d4.txt",
)

sitemap_url = "https://example.com/sitemap.xml"

submit_sitemap_to_index_now(authentication, sitemap_url,
    skip=100, take=50)

How to target URLs with a specific pattern by using the contains parameter:

submit_sitemap_to_index_now(authentication, sitemap_url,
    contains="section1")

The contains parameter also accepts regular expressions for more advanced filtering:

submit_sitemap_to_index_now(authentication, sitemap_url,
    contains=r"(section1)|(section2)")

Or combine the contains, skip, and take parameters to filter the URLs even further:

submit_sitemap_to_index_now(authentication, sitemap_url,
    contains=r"(section1)|(section2)",
    skip=100, take=50)