# `ouro-py`
[![Version](https://img.shields.io/pypi/v/ouro-py?color=%2334D058)](https://pypi.org/project/ouro-py)
The Ouro Python library provides convenient access to the Ouro REST API from any Python 3.7+
application. Visit [Ouro](https://ouro.foundation) to learn more about the Ouro platform.
## Documentation
The REST API documentation can be found on [ouro.foundation/docs/developers/api](https://ouro.foundation/docs/developers/api).
## Installation
```sh
# install from PyPI
pip install ouro-py
```
## Usage
Generate an API key from your account settings by going to [ouro.foundation/settings/api-keys](https://ouro.foundation/settings/api-keys).
Set your Ouro environment variables in a dotenv file, or using the shell:
```bash
export OURO_API_KEY="your_api_key"
```
Init client:
```python
import os
from ouro import Ouro
api_key = os.environ.get("OURO_API_KEY")
ouro = Ouro(api_key=api_key)
```
Use the client to interface with the Ouro framework.
### Create a dataset
```python
data = pd.DataFrame(
[
{"name": "Bob", "age": 30},
{"name": "Alice", "age": 27},
{"name": "Matt", "age": 26},
]
)
res = ouro.datasets.create(
data=data,
name="your_dataset_name",
description="your_dataset_description",
visibility="private",
)
```
### Read a dataset
```python
id = "3d82308b-0747-45e4-8045-c8f7d2f6c0a6" # penguins dataset
# Retrieve a dataset
dataset = ouro.datasets.retrieve(id)
# Option 1: Load dataset's data as json using the table name
data = ouro.datasets.load("penguins")
# Option 2: Load dataset's data using the PostgREST client
data = ouro.database.table("penguins").select("*").limit(1).execute()
# Option 3: Read dataset's data as a Pandas DataFrame
df = ouro.datasets.query(id)
```
### Update a dataset
```python
id = "3d82308b-0747-45e4-8045-c8f7d2f6c0a6"
data_update = pd.DataFrame([
{"name": "Bob", "age": 30},
{"name": "Alice", "age": 27},
{"name": "Matt", "age": 26},
])
update = {
"visibility": "private",
"data": data_update,
}
data = ouro.datasets.update("018f86da-b1be-7099-9556-fe88fb6882c3", **update)
```
### Create a post
```python
content = ouro.posts.Editor()
content.new_header(level=1, text="Hello World")
content.new_paragraph(text="This is a paragraph written in code.")
post = ouro.posts.create(
content=content,
name="Hello World",
description="This is a post from the Python SDK",
visibility="private",
)
```
### Read a post
```python
id = "b9ff1bfd-b3ae-4e92-9afc-70b1e1e2011a" # The post id
post = ouro.posts.retrieve(id)
```
### Update a post
```python
id = "b9ff1bfd-b3ae-4e92-9afc-70b1e1e2011a" # The post id
new_content = ouro.posts.Editor()
new_content.new_header(level=1, text="Hello World")
new_content.new_paragraph(text="This is a paragraph, but different this time.")
update = {
"name": "Hello World",
"visibility": "public",
"content": new_content,
}
post = ouro.posts.update(id, **update)
```
Read the full API docs at [ouro.foundation/docs/developers/api](https://ouro.foundation/docs/developers/api).
## Contributing
Contributing to the Python library is a great way to get involved with the Ouro community. Reach out to us on our [Github Discussions](https://github.com/orgs/ourofoundation/discussions) page if you want to get involved.
## Set up a Local Development Environment
### Clone the Repository
```bash
git clone git@github.com:ourofoundation/ouro-py.git
cd ouro-py
```
### Create and Activate a Virtual Environment
We recommend activating your virtual environment. Click [here](https://docs.python.org/3/library/venv.html) for more about Python virtual environments and working with [conda](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment) and [poetry](https://python-poetry.org/docs/basic-usage/).
Using venv (Python 3 built-in):
```bash
python3 -m venv env
source env/bin/activate # On Windows, use .\env\Scripts\activate
```
Using conda:
```bash
conda create --name ouro-py
conda activate ouro-py
```
### PyPi installation
Install the package (for > Python 3.7):
```bash
# with pip
pip install ouro-py
```
### Local installation
You can also install locally after cloning this repo. Install Development mode with `pip install -e`, which makes it so when you edit the source code the changes will be reflected in your python module.
## Badges
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?label=license)](https://opensource.org/licenses/MIT)
[![Python](https://img.shields.io/pypi/pyversions/ouro-py)](https://pypi.org/project/ouro-py)
[![Last commit](https://img.shields.io/github/last-commit/ourofoundation/ouro-py.svg?style=flat)](https://github.com/ourofoundation/ouro-py/commits)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/ourofoundation/ouro-py)](https://github.com/ourofoundation/ouro-py/commits)
[![Github Stars](https://img.shields.io/github/stars/ourofoundation/ouro-py?style=flat&logo=github)](https://github.com/ourofoundation/ouro-py/stargazers)
[![Github Forks](https://img.shields.io/github/forks/ourofoundation/ouro-py?style=flat&logo=github)](https://github.com/ourofoundation/ouro-py/network/members)
[![Github Watchers](https://img.shields.io/github/watchers/ourofoundation/ouro-py?style=flat&logo=github)](https://github.com/ourofoundation/ouro-py)
[![GitHub contributors](https://img.shields.io/github/contributors/ourofoundation/ouro-py)](https://github.com/ourofoundation/ouro-py/graphs/contributors)
Raw data
{
"_id": null,
"home_page": null,
"name": "ouro-py",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "ouro",
"author": null,
"author_email": "Matt Moderwell <matt@ouro.foundation>",
"download_url": "https://files.pythonhosted.org/packages/92/35/928203a1ab970327ecfcd7120ee0d685ff8c5ed34488055b2c924588dd43/ouro_py-0.2.16.tar.gz",
"platform": null,
"description": "# `ouro-py`\n\n[![Version](https://img.shields.io/pypi/v/ouro-py?color=%2334D058)](https://pypi.org/project/ouro-py)\n\nThe Ouro Python library provides convenient access to the Ouro REST API from any Python 3.7+\napplication. Visit [Ouro](https://ouro.foundation) to learn more about the Ouro platform.\n\n## Documentation\n\nThe REST API documentation can be found on [ouro.foundation/docs/developers/api](https://ouro.foundation/docs/developers/api).\n\n## Installation\n\n```sh\n# install from PyPI\npip install ouro-py\n```\n\n## Usage\n\nGenerate an API key from your account settings by going to [ouro.foundation/settings/api-keys](https://ouro.foundation/settings/api-keys).\n\nSet your Ouro environment variables in a dotenv file, or using the shell:\n\n```bash\nexport OURO_API_KEY=\"your_api_key\"\n```\n\nInit client:\n\n```python\nimport os\nfrom ouro import Ouro\n\napi_key = os.environ.get(\"OURO_API_KEY\")\nouro = Ouro(api_key=api_key)\n```\n\nUse the client to interface with the Ouro framework.\n\n### Create a dataset\n\n```python\ndata = pd.DataFrame(\n [\n {\"name\": \"Bob\", \"age\": 30},\n {\"name\": \"Alice\", \"age\": 27},\n {\"name\": \"Matt\", \"age\": 26},\n ]\n)\n\nres = ouro.datasets.create(\n data=data,\n name=\"your_dataset_name\",\n description=\"your_dataset_description\",\n visibility=\"private\",\n)\n```\n\n### Read a dataset\n\n```python\nid = \"3d82308b-0747-45e4-8045-c8f7d2f6c0a6\" # penguins dataset\n\n# Retrieve a dataset\ndataset = ouro.datasets.retrieve(id)\n\n# Option 1: Load dataset's data as json using the table name\ndata = ouro.datasets.load(\"penguins\")\n\n# Option 2: Load dataset's data using the PostgREST client\ndata = ouro.database.table(\"penguins\").select(\"*\").limit(1).execute()\n\n# Option 3: Read dataset's data as a Pandas DataFrame\ndf = ouro.datasets.query(id)\n```\n\n### Update a dataset\n\n```python\nid = \"3d82308b-0747-45e4-8045-c8f7d2f6c0a6\"\ndata_update = pd.DataFrame([\n {\"name\": \"Bob\", \"age\": 30},\n {\"name\": \"Alice\", \"age\": 27},\n {\"name\": \"Matt\", \"age\": 26},\n])\n\nupdate = {\n \"visibility\": \"private\",\n \"data\": data_update,\n}\ndata = ouro.datasets.update(\"018f86da-b1be-7099-9556-fe88fb6882c3\", **update)\n```\n\n\n### Create a post\n\n```python\ncontent = ouro.posts.Editor()\ncontent.new_header(level=1, text=\"Hello World\")\ncontent.new_paragraph(text=\"This is a paragraph written in code.\")\n\npost = ouro.posts.create(\n content=content,\n name=\"Hello World\",\n description=\"This is a post from the Python SDK\",\n visibility=\"private\",\n)\n```\n\n### Read a post\n\n```python\nid = \"b9ff1bfd-b3ae-4e92-9afc-70b1e1e2011a\" # The post id\n\npost = ouro.posts.retrieve(id)\n```\n\n### Update a post\n\n```python\nid = \"b9ff1bfd-b3ae-4e92-9afc-70b1e1e2011a\" # The post id\n\nnew_content = ouro.posts.Editor()\nnew_content.new_header(level=1, text=\"Hello World\")\nnew_content.new_paragraph(text=\"This is a paragraph, but different this time.\")\n\nupdate = {\n \"name\": \"Hello World\",\n \"visibility\": \"public\",\n \"content\": new_content,\n}\npost = ouro.posts.update(id, **update)\n```\n\nRead the full API docs at [ouro.foundation/docs/developers/api](https://ouro.foundation/docs/developers/api).\n\n\n## Contributing\n\nContributing to the Python library is a great way to get involved with the Ouro community. Reach out to us on our [Github Discussions](https://github.com/orgs/ourofoundation/discussions) page if you want to get involved.\n\n## Set up a Local Development Environment\n\n### Clone the Repository\n\n```bash\ngit clone git@github.com:ourofoundation/ouro-py.git\ncd ouro-py\n```\n\n### Create and Activate a Virtual Environment\n\nWe recommend activating your virtual environment. Click [here](https://docs.python.org/3/library/venv.html) for more about Python virtual environments and working with [conda](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment) and [poetry](https://python-poetry.org/docs/basic-usage/).\n\nUsing venv (Python 3 built-in):\n\n```bash\npython3 -m venv env\nsource env/bin/activate # On Windows, use .\\env\\Scripts\\activate\n```\n\nUsing conda:\n\n```bash\nconda create --name ouro-py\nconda activate ouro-py\n```\n\n### PyPi installation\n\nInstall the package (for > Python 3.7):\n\n```bash\n# with pip\npip install ouro-py\n```\n\n### Local installation\n\nYou can also install locally after cloning this repo. Install Development mode with `pip install -e`, which makes it so when you edit the source code the changes will be reflected in your python module.\n\n## Badges\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?label=license)](https://opensource.org/licenses/MIT)\n[![Python](https://img.shields.io/pypi/pyversions/ouro-py)](https://pypi.org/project/ouro-py)\n[![Last commit](https://img.shields.io/github/last-commit/ourofoundation/ouro-py.svg?style=flat)](https://github.com/ourofoundation/ouro-py/commits)\n[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/ourofoundation/ouro-py)](https://github.com/ourofoundation/ouro-py/commits)\n[![Github Stars](https://img.shields.io/github/stars/ourofoundation/ouro-py?style=flat&logo=github)](https://github.com/ourofoundation/ouro-py/stargazers)\n[![Github Forks](https://img.shields.io/github/forks/ourofoundation/ouro-py?style=flat&logo=github)](https://github.com/ourofoundation/ouro-py/network/members)\n[![Github Watchers](https://img.shields.io/github/watchers/ourofoundation/ouro-py?style=flat&logo=github)](https://github.com/ourofoundation/ouro-py)\n[![GitHub contributors](https://img.shields.io/github/contributors/ourofoundation/ouro-py)](https://github.com/ourofoundation/ouro-py/graphs/contributors)\n",
"bugtrack_url": null,
"license": null,
"summary": "The official Python library for the Ouro API",
"version": "0.2.16",
"project_urls": {
"Homepage": "https://github.com/ourofoundation/ouro-py",
"PyPI": "https://pypi.org/project/ouro-py",
"Repository": "https://github.com/ourofoundation/ouro-py"
},
"split_keywords": [
"ouro"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "37be0d3a6bc3521e2e90eea3e64af2ec6c537f83ab8018fa445ee82c8b008433",
"md5": "9364acae009d45036269d34da423f7bf",
"sha256": "7156b791e63410cbba909adbe0ca78445df69ff579f066f93045ff2bd671ab51"
},
"downloads": -1,
"filename": "ouro_py-0.2.16-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9364acae009d45036269d34da423f7bf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 28195,
"upload_time": "2024-12-21T12:07:32",
"upload_time_iso_8601": "2024-12-21T12:07:32.150774Z",
"url": "https://files.pythonhosted.org/packages/37/be/0d3a6bc3521e2e90eea3e64af2ec6c537f83ab8018fa445ee82c8b008433/ouro_py-0.2.16-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9235928203a1ab970327ecfcd7120ee0d685ff8c5ed34488055b2c924588dd43",
"md5": "0a61411b89395bcc35fc8619f915bc0f",
"sha256": "b07b1f0d10d43b54774b707d45c0fb76440c1bbf55f1a41cbc3b12f528c208cb"
},
"downloads": -1,
"filename": "ouro_py-0.2.16.tar.gz",
"has_sig": false,
"md5_digest": "0a61411b89395bcc35fc8619f915bc0f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 21583,
"upload_time": "2024-12-21T12:07:34",
"upload_time_iso_8601": "2024-12-21T12:07:34.556187Z",
"url": "https://files.pythonhosted.org/packages/92/35/928203a1ab970327ecfcd7120ee0d685ff8c5ed34488055b2c924588dd43/ouro_py-0.2.16.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-21 12:07:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ourofoundation",
"github_project": "ouro-py",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "supabase",
"specs": []
},
{
"name": "python-dotenv",
"specs": []
},
{
"name": "postgrest",
"specs": []
},
{
"name": "httpx",
"specs": [
[
"==",
"0.16.1"
]
]
},
{
"name": "python-socketio",
"specs": []
}
],
"lcname": "ouro-py"
}