/api/search/{uuid} currently responds with a 302 HTML redirect to the typed endpoint (/api/items/{slug} or /api/vehicles/{slug}). That works for browsers, but it makes the endpoint hard to use from API consumers that need a kind-discriminator step before doing a typed fetch with includes/locale.
Specifically:
-
Query string is not preserved through the redirect. A request to /api/search/{uuid}?locale=en_EN&include=related_items,blueprints,vehicles lands at /api/items/{slug} with no params, so the response carries description as a {en_EN, de_DE, ...} map and the related_items / blueprints / vehicles includes are null. Callers can't combine kind discovery and data fetch in one round-trip.
-
Server-side HTTP clients without redirect-following can't extract the kind. The useful information (kind + canonical slug) lives in the Location: header. Clients that don't expose response headers (e.g., MediaWiki's Apiunto extension, which is what the Star Citizen Wiki uses to call this API from Lua) see an empty body and no way to learn what the UUID resolved to.
-
Current workaround (what the wiki does today) is sequential probing: call /api/items/{uuid}, check the response shape, and on miss fall back to /api/vehicles/{uuid}. That's one wasted call on every vehicle page.
Possible directions
No preference — flagging options:
- Return a JSON discriminator instead of a 302:
{"data": {"kind": "vehicles", "slug": "aegs-avenger-stalker", "uuid": "..."}}. Lets callers route to the typed endpoint with the right include/locale params.
- Make
/api/search/{uuid} a real data endpoint that proxies through to the typed handler internally, honoring include and locale. Single round-trip, no caller-side kind logic.
- Preserve the query string across the 302 (helps browser callers but not Apiunto-style clients).
Repro
Search with params, after redirect — params lost:
$ curl -sSL "https://api.star-citizen.wiki/api/search/80ee3b95-5665-4548-9e2d-d2067895c0ac?locale=en_EN&include=related_items" \
| jq '.data | {description_type: (.description|type), related_items_type: (.related_items|type)}'
{ "description_type": "object", "related_items_type": "null" }
Direct typed call — params honored:
$ curl -sS "https://api.star-citizen.wiki/api/items/80ee3b95-5665-4548-9e2d-d2067895c0ac?locale=en_EN&include=related_items" \
| jq '.data | {description_type: (.description|type), related_items_type: (.related_items|type)}'
{ "description_type": "string", "related_items_type": "object" }
Raw redirect (no body content beyond the HTML redirect stub):
$ curl -sSI "https://api.star-citizen.wiki/api/search/97648869-5fa5-42da-b804-4d9314289539" | grep -iE '^(HTTP|location):'
HTTP/2 302
location: https://api.star-citizen.wiki/api/vehicles/aegs-avenger-stalker
/api/search/{uuid}currently responds with a302HTML redirect to the typed endpoint (/api/items/{slug}or/api/vehicles/{slug}). That works for browsers, but it makes the endpoint hard to use from API consumers that need a kind-discriminator step before doing a typed fetch with includes/locale.Specifically:
Query string is not preserved through the redirect. A request to
/api/search/{uuid}?locale=en_EN&include=related_items,blueprints,vehicleslands at/api/items/{slug}with no params, so the response carriesdescriptionas a{en_EN, de_DE, ...}map and therelated_items/blueprints/vehiclesincludes are null. Callers can't combine kind discovery and data fetch in one round-trip.Server-side HTTP clients without redirect-following can't extract the kind. The useful information (kind + canonical slug) lives in the
Location:header. Clients that don't expose response headers (e.g., MediaWiki'sApiuntoextension, which is what the Star Citizen Wiki uses to call this API from Lua) see an empty body and no way to learn what the UUID resolved to.Current workaround (what the wiki does today) is sequential probing: call
/api/items/{uuid}, check the response shape, and on miss fall back to/api/vehicles/{uuid}. That's one wasted call on every vehicle page.Possible directions
No preference — flagging options:
{"data": {"kind": "vehicles", "slug": "aegs-avenger-stalker", "uuid": "..."}}. Lets callers route to the typed endpoint with the rightinclude/localeparams./api/search/{uuid}a real data endpoint that proxies through to the typed handler internally, honoringincludeandlocale. Single round-trip, no caller-side kind logic.Repro
Search with params, after redirect — params lost:
Direct typed call — params honored:
Raw redirect (no body content beyond the HTML redirect stub):