Structured targets¶
A structured target is the entity a market is "about" — a team, player, candidate, company. Two markets pointing at the same Yankees roster share a structured target id, so you can group markets by underlying entity.
Public — no auth required.
Quick reference¶
| Method | Endpoint |
|---|---|
list(...) / list_all(...) |
GET /structured_targets |
get(structured_target_id) |
GET /structured_targets/{id} |
List structured targets¶
page = client.structured_targets.list(
target_type="team", # spec field "type"; renamed
competition="MLB",
page_size=500, # 1–2000, default 100 — note: not `limit`
ids=["st_abc", "st_def"], # bulk lookup
)
for t in page:
print(t.structured_target_id, t.name, t.target_type)
page_size, not limit
Unlike every other paginated endpoint, this one uses page_size. Range:
1–2000. Default 100. The SDK accepts a cursor for pagination as usual.
target_type is the SDK's name for spec type
Same renaming logic as milestones — avoids shadowing
the Python builtin. The wire still sends type=.
Get one structured target¶
t = client.structured_targets.get("st_abc")
if t is None:
print("not found")
else:
print(t.name, t.target_type)
get() may return None for unknown IDs (the underlying endpoint returns a
404 that's mapped to None rather than KalshiNotFoundError).
Reference¶
kalshi.resources.structured_targets.StructuredTargetsResource ¶
Bases: SyncResource
Sync structured targets API.
The type spec query param is exposed as target_type to avoid
shadowing the Python built-in. page_size keeps the spec name (no
standard limit param on this endpoint — per spec page_size is 1-2000,
default 100).
kalshi.resources.structured_targets.AsyncStructuredTargetsResource ¶
Bases: AsyncResource
Async structured targets API.
list_all ¶
list_all(
*,
ids: list[str] | None = None,
target_type: str | None = None,
competition: str | None = None,
page_size: int | None = None,
max_pages: int | None = None
) -> AsyncIterator[StructuredTarget]
Returns an async iterator — use async for.