indexnowkit 0.1.0
Build and validate IndexNow submission payloads: key rules, single-host batches, the 10000-URL limit, JSON body and the single-URL GET form.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
indexnowkit
Build and validate IndexNow submission payloads in D.
IndexNow is a small protocol: you POST a JSON body naming a host, a key and a list of changed URLs, and participating search engines pick it up. The failure mode is that a malformed batch simply does nothing — you get an HTTP response and no indication that the payload was wrong. This library refuses to emit a payload it cannot prove is well formed.
Built for the deploy step of aiwebsitepipeline.com, where a static site is generated and then has to announce a few hundred URLs without a human checking each batch.
What it enforces
Straight from the protocol documentation:
- the key is 8–128 characters, drawn only from
a-z,A-Z,0-9and- - every URL in one submission belongs to the same host
- at most 10,000 URLs go in one POST
- the key file, when named, lives on the same host as the URLs
Usage
import indexnowkit;
auto batches = chunkUrls(allUrls, 1_000);
foreach (batch; batches)
{
auto sub = buildSubmission(key, batch,
defaultKeyLocation("https", "example.com", key));
string body_ = toJson(sub);
// POST body_ to https://api.indexnow.org/indexnow
}
Produces exactly the document shape shown in the protocol docs:
{"host":"example.com","key":"abcdef12","urlList":["https://example.com/url1"]}
For the one-off case there is the GET form:
auto url = singleUrlEndpoint("api.indexnow.org", "https://example.com/a b", key);
// https://api.indexnow.org/indexnow?url=https%3A%2F%2Fexample.com%2Fa%20b&key=...
API
| function | what it does |
|---|---|
isValidKey(key) | length and character-set check |
hostOf(url) | host of an absolute http(s) URL, lower-cased, port and userinfo stripped |
buildSubmission(key, urls, keyLocation = "") | validated Submission, or throws |
chunkUrls(urls, batchSize) | batches, never larger than the protocol limit |
defaultKeyLocation(scheme, host, key) | scheme://host/key.txt |
toJson(submission) | the POST body |
singleUrlEndpoint(engineHost, url, key) | the GET form, percent-encoded |
jsonEscape(s) / urlEncode(s) | the escaping the two forms need |
Everything that can fail throws IndexNowException with a message naming the
offending value — a mixed-host batch reports both hosts, for instance — rather
than dropping the bad entry and sending a batch you did not intend.
Tests
dub test --compiler=ldc2
Nine unittest blocks covering key validation, URL host extraction (scheme,
userinfo, port, case), mixed-host rejection, the exact JSON body, escaping of
quotes/backslashes/control characters, and batch chunking that loses nothing.
License
MIT.
- 0.1.0 released 2 days ago
- theluckystrike/indexnowkit-d
- aiwebsitepipeline.com/
- MIT
- Copyright (c) 2026, AI Website Pipeline
- Authors:
- Dependencies:
- none
- Versions:
-
Show all 3 versions0.1.1 2026-Aug-08 0.1.0 2026-Aug-08 ~main 2026-Aug-08 - Download Stats:
-
-
0 downloads today
-
1 downloads this week
-
1 downloads this month
-
1 downloads total
-
- Score:
- 0.0
- Short URL:
- indexnowkit.dub.pm