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
image_url str | None the result's image, for image sources
is_relevant bool | None False for an exploratory (below-threshold) hit
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.5.0.tar.gz (12.9 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.5.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: raily_ai-0.5.0.tar.gz
  • Upload date:
  • Size: 12.9 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.5.0.tar.gz
Algorithm Hash digest
SHA256 d8ce0f8b696ecdeda91965ff6203a6185843af7f8fe441760d154e859d430e45
MD5 0fb537db965261d8914fb6ad7916f5dc
BLAKE2b-256 3b94c580b52453efaed1512d0afd04dc8424ab58acf1fdba61c5b94f9f224ec3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raily_ai-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4965f0ea269a90878681eab1295027fcec5599eaecb001a25db98d06533fd94
MD5 f8b7d69992a9f7f62d0fbeeef57b1497
BLAKE2b-256 0d6abc4e4cf1d8d47306cf4d1a3c26ce9020b754baffa9358189c81d7c396b8a

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