Skip to main content

Install

Python 3.10+. The import name is raily:

Quickstart

Get the endpoint URL and key from your endpoint’s API access panel — see the SDK 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:
Or have the client log a one-line hint on every empty result during development:

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:
A field with multiple values is joined with ", ". To see what your source exposes, print the whole map once:
Need the full original result (every field, untrimmed)? It’s on hit.raw.

Errors

RailyAuthError is a subclass of RailyError, so catch it first.

Async

AsyncRaily has the same surface with await:
Run many searches concurrently:

Recipe: a search endpoint with FastAPI

Troubleshooting

An empty list is a valid answer, not an error. The usual causes, in order:
  1. 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").
  2. A freshness filter. Queries that imply recency ("latest", "news") apply a published_date cutoff — if your source’s data is older, that can remove everything. Drop the recency words or widen the range.
  3. 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.
Use explain=True to see which it is:
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.
Raise the timeout (seconds) and retry. Reuse one client rather than constructing one per request.