Skip to main content

ouro-py

Version Python License: MIT

The official Python SDK for Ouro.

Use it to work with datasets and files, publish results, collaborate with teams, and run APIs shared on Ouro.

Install

pip install ouro-py

ouro-py requires Python 3.10 or later.

Quickstart

Create a Personal Access Token in your Ouro settings, then export it:

export OURO_API_KEY="your-api-key"

Create a client and start using the API:

from ouro import Ouro

ouro = Ouro()

dataset = ouro.datasets.create(
    name="experiment-results",
    visibility="private",
    data=[
        {"sample": "A", "score": 0.82},
        {"sample": "B", "score": 0.91},
    ],
)

results = ouro.datasets.query(dataset.id)
print(results)

The client reads OURO_API_KEY from your environment or a .env file. You can also pass it directly with Ouro(api_key="...").

Common workflows

Find assets

Datasets, posts, files, services, routes, and quests are all assets. Search across them with ouro.assets:

results = ouro.assets.search(
    "battery materials",
    asset_type="dataset",
    scope="global",
    limit=10,
)

asset = ouro.assets.retrieve(results[0]["id"])

Search scope can be personal, org, global, or all.

Query a dataset

Dataset queries return pandas DataFrames by default:

df = ouro.datasets.query(dataset_id)

summary = ouro.datasets.query(
    dataset_id,
    """
    select category, avg(score) as mean_score
    from {{table}}
    group by category
    """,
)

SQL queries are read-only. Use {{table}} as the dataset table placeholder.

Upload a file

file = ouro.files.create(
    name="Crystal structure",
    file_path="./structure.cif",
    visibility="private",
)

Download any supported asset through the shared asset interface:

download = ouro.assets.download(file.id, output_path="./downloads")
print(download["path"])

Publish a post

Pass markdown directly or build richer content with the editor:

editor = ouro.posts.Editor()
editor.new_header(level=1, text="Experiment summary")
editor.new_paragraph(text="The best sample reached a score of 0.91.")
editor.new_inline_asset(dataset.id, asset_type="dataset", view_mode="preview")

post = ouro.posts.create(
    name="Experiment summary",
    content=editor,
    visibility="private",
)

You can also use content_markdown="..." or content_path="./report.md".

Run an API

Ouro services expose individual endpoints as routes:

action = ouro.routes.execute(
    "organization/route-name",  # a route slug or UUID
    body={"text": "hello"},
)

print(action.status)
print(action.final_data)

Routes can take Ouro assets directly:

action = ouro.routes.execute(
    route_id,
    input_assets={"structure": file.id},
)

Synchronous and asynchronous routes use the same interface. Pass wait=False to return immediately, then use ouro.routes.poll_action(action.id) when you are ready for the result.

API overview

Resources are organized under one client:

Namespace Use it for
ouro.assets Search, retrieve, share, download, and inspect lineage
ouro.datasets Create, query, update, and visualize tabular data
ouro.files Upload, retrieve, update, and search files
ouro.posts Publish markdown and embedded assets
ouro.routes Execute APIs and inspect actions
ouro.services Publish an API from an OpenAPI specification
ouro.quests Create work, submit entries, and review results
ouro.organizations / ouro.teams Manage workspaces, channels, and membership
ouro.comments / ouro.conversations Discuss assets and send messages
ouro.users / ouro.notifications Work with profiles and notifications
ouro.money Check balances, transactions, and paid access

See the REST API reference for the underlying API.

Organizations, teams, and visibility

Every asset belongs to an organization and a team. When creating one, pass org_id and team_id to choose where it appears:

dataset = ouro.datasets.create(
    name="shared-results",
    data=rows,
    visibility="public",
    org_id=org_id,
    team_id=team_id,
)

If you omit them, Ouro uses your global organization's catch-all team.

Visibility can be public, private, or monetized. Private assets remain private until you share them explicitly:

ouro.assets.share(asset_id, user_id, role="read")

Configuration

Variable Default Purpose
OURO_API_KEY required Personal Access Token
OURO_BACKEND_URL https://api.ouro.foundation Ouro API base URL

For local development:

export OURO_BACKEND_URL="http://localhost:8003"

You can also pass api_key and base_url directly to Ouro(...).

Error handling

All SDK exceptions inherit from OuroError:

from ouro import NotFoundError, OuroError

try:
    asset = ouro.assets.retrieve(asset_id)
except NotFoundError:
    print("Asset not found")
except OuroError as exc:
    print(f"Ouro request failed: {exc}")

Development

git clone git@github.com:ourofoundation/ouro-py.git
cd ouro-py
pip install -e .
pytest

Questions and ideas are welcome in GitHub Discussions.

License

MIT

Download files

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

Source Distribution

ouro_py-0.11.1.tar.gz (67.7 kB view details)

Uploaded Source

Built Distribution

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

ouro_py-0.11.1-py3-none-any.whl (87.2 kB view details)

Uploaded Python 3

File details

Details for the file ouro_py-0.11.1.tar.gz.

File metadata

  • Download URL: ouro_py-0.11.1.tar.gz
  • Upload date:
  • Size: 67.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ouro_py-0.11.1.tar.gz
Algorithm Hash digest
SHA256 4fb5e7616cb1b2f08833cdda47aa0e36fe1456065714c1e3c848bb8ebc2682d8
MD5 db31361e8041c63c101b3c1aa7dc2c1f
BLAKE2b-256 d258582b5013f343f19098dba08d74ba532c16eb99b9342d9940241c90b37994

See more details on using hashes here.

File details

Details for the file ouro_py-0.11.1-py3-none-any.whl.

File metadata

  • Download URL: ouro_py-0.11.1-py3-none-any.whl
  • Upload date:
  • Size: 87.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ouro_py-0.11.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab47412e8bd77490da84b887a661c32c12aea5899fa10c953370a19aeb3aedb9
MD5 c2e44acddc81da531f78fe6af74a5cda
BLAKE2b-256 eeeea126df6ebadb63d25c8efe821e12958681380b99c7d6d59d8aa2d6fc4c0d

See more details on using hashes here.

Release history Release notifications | RSS feed

0.11.16

2 files

0.11.15

2 files

0.11.14

2 files

0.11.13

2 files

0.11.12

2 files

0.11.11

2 files

0.11.10

2 files

0.11.9

2 files

0.11.8

2 files

0.11.7

2 files

0.11.6

2 files

0.11.5

2 files

0.11.4

2 files

0.11.3

2 files

0.11.2

2 files

This release

0.11.1 This release

2 files

0.11.0

2 files

0.10.8

2 files

0.10.7

2 files

0.10.6

2 files

0.10.5

2 files

0.10.4

2 files

0.10.2

2 files

0.10.1

2 files

0.10.0

2 files

0.9.4

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.0

2 files

0.7.1

2 files

0.6.0

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.19

2 files

0.3.18

2 files

0.3.17

2 files

0.3.16

2 files

0.3.15

2 files

0.3.14

2 files

0.3.13

2 files

0.3.12

2 files

0.3.11

2 files

0.3.10

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.18

2 files

0.2.17

2 files

0.2.16

2 files

0.2.15

2 files

0.2.14

2 files

0.2.13

2 files

0.2.12

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page