Install
raily:
Quickstart
Raily(...)
The client holds no session state — construct it once and reuse it.
search(query, limit=3)
Returns a
list[SearchHit] — or a SearchResult when explain=True (see
Debugging empty results).
Debugging empty results
A search can legitimately return nothing — and a bare[] doesn’t say why. Pass
explain=True to get the endpoint’s own message plus a hint:
SearchHit
Working with fields
fields is a flat {name: value} map of the display fields configured on your source —
e.g. title, text, author, published_date. Read a value by name:
", ". To see what your source exposes, print
the whole map once:
hit.raw.
Errors
RailyAuthError is a subclass of RailyError, so catch it first.
Async
AsyncRaily has the same surface with await:
Recipe: a search endpoint with FastAPI
Troubleshooting
No results came back (empty list)
No results came back (empty list)
An empty list is a valid answer, not an error. The usual causes, in order:
- The query is too generic. Category words like
"articles","news", or"posts"carry no topical signal, so nothing matches strongly enough to return. Search a specific topic ("battery recycling", not"articles"). - A freshness filter. Queries that imply recency (
"latest","news") apply apublished_datecutoff — if your source’s data is older, that can remove everything. Drop the recency words or widen the range. - Your source has no data yet. A brand-new source may not have finished indexing yet. Search a term you know is in the data; if that’s also empty, confirm the source has finished indexing in the Raily app.
explain=True to see which it is:“API key was rejected for this endpoint” (RailyAuthError)
“API key was rejected for this endpoint” (RailyAuthError)
The key is missing, wrong, expired, or was issued for a different endpoint. A key only
works against the endpoint it was created on. Re-check
RAILY_API_KEY and RAILY_ENDPOINT.Searches are slow or time out
Searches are slow or time out
Raise the
timeout (seconds) and retry. Reuse one client rather than constructing one
per request.