Asset API
Read-only endpoints for third-party clients. No auth, no origin restrictions — just don't hammer it like a CDN.
Endpoints
/api/community/v1/meta~340 B; check version before pulling the full list/api/community/v1/texturesTexture feed, 113 KB / 23 KB gzip — recommended/api/community/v1/assetsFull catalog with id, downloads, community flag/api/community/v1/assets/{id}Single assetAll endpoints support ?category=HUD filtering.
Texture item fields
hstringFirst 12 hex chars of SHA-256; verify the downloaded filenstringDisplay nameastringAuthorcstringCategory, for groupingxstring?Extension, only when not png (currently map)wstring?Preview hash, only on .map entriesustring?Full download URL, only when the CDN prefix is not uniformistring?Full preview URL, only when the URL cannot be derivedBuilding URLs
The response carries a top-level base and suffix; items only give you the hash. These three lines are the whole rule:
file = base + h + "." + (x ?? "png")
image = file + suffix
// 例外:带 w 的条目,预览是另一张图
image = base + w + ".png" + suffixItems carrying u or i bypass the rules — use the given URL. The server verifies these rules item by item when building the feed, and falls back to full URLs if any item breaks them.
Minimal client
// 1) 先问版本,340 字节
const meta = await fetch("https://ddrace.cn/api/community/v1/meta").then(r => r.json());
const v = meta.data.version; // "6e33d91bba111661"
// 2) 和本地缓存比;没变就到此为止,0 字节
if (v === cached.version) return cached.assets;
// 3) 变了再拉,带 ETag,服务端可能回 304
const res = await fetch("https://ddrace.cn/api/community/v1/textures", {
headers: cached.etag ? { "If-None-Match": cached.etag } : {},
});
if (res.status === 304) return cached.assets; // 版本变了但内容一样
const { data } = await res.json();
for (const it of data.assets) {
const file = it.u ?? (data.base + it.h + "." + (it.x ?? "png"));
const image = it.i ?? ((it.w ? data.base + it.w + ".png" : file) + data.suffix);
// it.h 用来校验下载到的文件;it.n 名称,it.a 作者,it.c 分类
}
cached.etag = res.headers.get("ETag");Integrity check
Compute SHA-256 after download and compare the first 12 lowercase hex chars with h — a mismatch means the file is corrupt or was replaced.
This is a 48-bit truncated hash: enough to catch corruption or an accidental CDN replacement, not enough to resist a deliberately constructed collision.
Use WebP for display (often half the size) and the original URL for downloads.
Conventions
- Responses use the envelope
{ code, message, data }— code 0 means success; otherwise message explains why. - Send
If-None-Matchto get a 304. Without it every request returns the full body. - On cold start read the local cache first, then verify via meta. If the API is down, fall back to the static_url from meta.
- Don't enumerate the API: the whole catalog comes in one request, per-item requests just get rate limited.