Skip to content

Submit Multiple URLs in Bulk to the IndexNow API#

submit_urls_to_index_now()#

Submit a list of URLs to the IndexNow API of a search engine.

Parameters:

Name Type Description Default
authentication IndexNowAuthentication

Authentication credentials for the IndexNow API.

required
urls list[str]

List of URLs to submit. For example: ["https://example.com/page1", "https://example.com/page2", "https://example.com/page3"]

required
endpoint SearchEngineEndpoint | str | Sequence[SearchEngineEndpoint | str]

Select the search engine you want to submit to or use a custom URL as endpoint. If a list or tuple of endpoints is given, they are tried in order until one accepts the submission. The submission falls back to the next endpoint on connection errors, server errors, 429 Too Many Requests and 403 Forbidden, but not on other client errors such as 400 Bad Request.

INDEXNOW
retries int

Number of times to retry a request on connection errors, timeouts, 429 Too Many Requests and server errors, with exponential backoff. Defaults to 0, i.e. no retries. If a list or tuple of endpoints is given, each endpoint is retried before falling back to the next one.

0

Returns:

Name Type Description
int int

The status code of the response, e.g. 200 for success, 202 for accepted, 400 for bad request, etc. If a list or tuple of endpoints is given and all of them fail, the last response status is returned if any endpoint responded; otherwise, the final connection error or timeout is raised.

Example

After adding your authentication credentials to the IndexNowAuthentication class, you can now submit multiple URLs to the IndexNow API:

Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from index_now import submit_urls_to_index_now, IndexNowAuthentication

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

urls = ["https://example.com/page1", "https://example.com/page2", "https://example.com/page3"]

submit_urls_to_index_now(authentication, urls)

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

11
12
submit_urls_to_index_now(authentication, urls,
    endpoint="https://www.bing.com/indexnow")

Or provide a list of endpoints as fallback in case an endpoint is unavailable or rejects the submission. The endpoints are tried in order until one succeeds:

11
12
13
14
15
16
17
endpoints_with_fallback = [
    "https://www.bing.com/indexnow",
    "https://yandex.com/indexnow",
    "https://search.seznam.cz/indexnow",
]

submit_urls_to_index_now(authentication, urls, endpoint=endpoints_with_fallback)