Skip to main content

Official Python SDK for the Raily search API.

Project description

Raily Python SDK

Official Python client for the Raily search API — search your own sources from your app with a typed, one-call client.

Documentation · Source

Install

pip install raily-ai

Quickstart

from raily import Raily

client = Raily(api_key="rly_...", endpoint="https://<your-endpoint-url>")

for hit in client.search("anti-aging serum", limit=5):
    print(hit.score, hit.fields.get("title"))

Async

from raily import AsyncRaily

client = AsyncRaily(api_key="rly_...", endpoint="https://<your-endpoint-url>")
hits = await client.search("anti-aging serum", limit=5)

Authentication

Create an API key in your Raily workspace (Identities → API keys) and pass it as api_key. The endpoint is your endpoint's URL. A key is scoped to one workspace and to the endpoint it was issued for — using it elsewhere is rejected.

import os
client = Raily(api_key=os.environ["RAILY_API_KEY"], endpoint=os.environ["RAILY_ENDPOINT"])

Results

search() returns a list of SearchHit:

field type meaning
score float | None relevance score
fields dict[str, str] flat {name: value} map of the source's display fields, e.g. hit.fields["title"]
text str | None a rendered text summary
source_collection str | None the source the hit came from
id str | None stable result id
raw dict the full original result, for anything not surfaced above

fields is a flat dict, so you read a value by name:

hit.fields["title"]              # e.g. "Anti-Aging Vitamin C Serum"
hit.fields.get("published_date") # None if this source doesn't expose it

The exact keys come from the source's configured display fields (e.g. title, author, published_date). Print one hit's fields to see what your source exposes.

Debugging empty results

A bare [] doesn't say why. Pass explain=True for the endpoint's message plus a hint:

res = client.search("articles", explain=True)
print(res.info.count, res.info.message, res.info.note)  # note is set only when empty

Most empty results are a too-generic query ("articles" matches nothing — search a topic), a freshness filter, or an unindexed corpus. Or construct with debug=True to log a hint on every empty result.

Errors

from raily import RailyError, RailyAuthError

try:
    client.search("query")
except RailyAuthError:
    ...  # key missing / invalid / expired / not authorized for this endpoint
except RailyError:
    ...  # everything else (network, server, protocol)

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raily_ai-0.4.0.tar.gz (108.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raily_ai-0.4.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file raily_ai-0.4.0.tar.gz.

File metadata

  • Download URL: raily_ai-0.4.0.tar.gz
  • Upload date:
  • Size: 108.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for raily_ai-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7ad9dcd476d361b7312fd7a4ae1ca36dac678b94fce48c34242452e671bdeb12
MD5 18539641738e9a2b83ca0a634d7cabd6
BLAKE2b-256 b6a4e5558f3d433953ef190b53bc3bc6d1f14b8d9dafa06d915e22be44f3519c

See more details on using hashes here.

File details

Details for the file raily_ai-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: raily_ai-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for raily_ai-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dea45600e7aea1538a78274f0e8f3bbea74e56ed45f9c3d11577606747852259
MD5 a18d56272ddf7cf9e89af6e91f39fb42
BLAKE2b-256 b16b61fbe2bf339c033a113cccb59e01bca1e9b8169444ef4bd0bf8bd923070c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page