# PocketBase Python SDK
[![Tests](https://github.com/vaphes/pocketbase/actions/workflows/tests.yml/badge.svg)](https://github.com/vaphes/pocketbase/actions/workflows/tests.yml)
Python client SDK for the <a href="https://pocketbase.io/">PocketBase</a> backend.
This is in early development, and at first is just a translation of <a href="https://github.com/pocketbase/js-sdk">the javascript lib</a> using <a href="https://github.com/encode/httpx/">HTTPX</a>.
---
## Installation
Install PocketBase using PIP:
```shell
python3 -m pip install pocketbase
```
## Usage
The rule of thumb here is just to use it as you would <a href="https://github.com/pocketbase/js-sdk">the javascript lib</a>, but in a pythonic way of course!
```python
from pocketbase import PocketBase # Client also works the same
from pocketbase.client import FileUpload
client = PocketBase('http://127.0.0.1:8090')
# authenticate as regular user
user_data = client.collection("users").auth_with_password(
"user@example.com", "0123456789")
# or as admin
admin_data = client.admins.auth_with_password("test@example.com", "0123456789")
# list and filter "example" collection records
result = client.collection("example").get_list(
1, 20, {"filter": 'status = true && created > "2022-08-01 10:00:00"'})
# create record and upload file to image field
result = client.collection("example").create(
{
"status": "true",
"image": FileUpload(("image.png", open("image.png", "rb"))),
})
# and much more...
```
> More detailed API docs and copy-paste examples could be found in the [API documentation for each service](https://pocketbase.io/docs/api-authentication). Just remember to 'pythonize it' 🙃.
## Development
These are the requirements for local development:
* Python 3.7+
* Poetry (https://python-poetry.org/)
You can install locally:
```shell
poetry install
```
Or can build and generate a package:
```shell
poetry build
```
But if you are using only PIP, use this command:
```shell
python3 -m pip install -e .
```
## Tests
To execute the tests use this command:
```
poetry run pytest
```
## License
The PocketBase Python SDK is <a href="https://github.com/vaphes/pocketbase/blob/master/LICENCE.txt">MIT licensed</a> code.
Raw data
{
"_id": null,
"home_page": "https://github.com/abyesilyurt/pocketbase",
"name": "pocketbasex",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "pocketbase,sdk",
"author": "Aziz Berkay Yesilyurt",
"author_email": "abyesilyurt@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/2e/7b/0bc18ba87429d0942f05d86aedfd437156af7f2deb452f53334b0b7bfba0/pocketbasex-0.8.2.tar.gz",
"platform": null,
"description": "# PocketBase Python SDK\n\n[![Tests](https://github.com/vaphes/pocketbase/actions/workflows/tests.yml/badge.svg)](https://github.com/vaphes/pocketbase/actions/workflows/tests.yml)\n\nPython client SDK for the <a href=\"https://pocketbase.io/\">PocketBase</a> backend.\n\nThis is in early development, and at first is just a translation of <a href=\"https://github.com/pocketbase/js-sdk\">the javascript lib</a> using <a href=\"https://github.com/encode/httpx/\">HTTPX</a>.\n\n---\n\n## Installation\n\nInstall PocketBase using PIP:\n\n```shell\npython3 -m pip install pocketbase\n```\n\n## Usage\n\nThe rule of thumb here is just to use it as you would <a href=\"https://github.com/pocketbase/js-sdk\">the javascript lib</a>, but in a pythonic way of course!\n\n```python\nfrom pocketbase import PocketBase # Client also works the same\nfrom pocketbase.client import FileUpload\n\nclient = PocketBase('http://127.0.0.1:8090')\n\n# authenticate as regular user\nuser_data = client.collection(\"users\").auth_with_password(\n \"user@example.com\", \"0123456789\")\n\n# or as admin\nadmin_data = client.admins.auth_with_password(\"test@example.com\", \"0123456789\")\n\n# list and filter \"example\" collection records\nresult = client.collection(\"example\").get_list(\n 1, 20, {\"filter\": 'status = true && created > \"2022-08-01 10:00:00\"'})\n\n# create record and upload file to image field\nresult = client.collection(\"example\").create(\n {\n \"status\": \"true\",\n \"image\": FileUpload((\"image.png\", open(\"image.png\", \"rb\"))),\n })\n\n# and much more...\n```\n> More detailed API docs and copy-paste examples could be found in the [API documentation for each service](https://pocketbase.io/docs/api-authentication). Just remember to 'pythonize it' \ud83d\ude43.\n\n## Development\n\nThese are the requirements for local development:\n\n* Python 3.7+\n* Poetry (https://python-poetry.org/)\n\nYou can install locally:\n\n```shell\npoetry install\n```\n\nOr can build and generate a package:\n\n```shell\npoetry build\n```\n\nBut if you are using only PIP, use this command:\n\n```shell\npython3 -m pip install -e .\n```\n\n## Tests\n\nTo execute the tests use this command:\n\n```\npoetry run pytest\n```\n\n## License\n\nThe PocketBase Python SDK is <a href=\"https://github.com/vaphes/pocketbase/blob/master/LICENCE.txt\">MIT licensed</a> code.\n",
"bugtrack_url": null,
"license": "",
"summary": "PocketBase SDK for python.",
"version": "0.8.2",
"project_urls": {
"Bug Tracker": "https://github.com/abyesilyurt/pocketbase/issues",
"Homepage": "https://github.com/abyesilyurt/pocketbase",
"Repository": "https://github.com/abyesilyurt/pocketbase"
},
"split_keywords": [
"pocketbase",
"sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "02e91b75f426f03adfefcd442ed55ca483cb94495ba098a4522b5d1a800c9cca",
"md5": "12c6371d2969c3e1aee86d55d5057903",
"sha256": "1ff10ccedb1ac5e7dd2cf894aaf880ca1dbc36a0130b693b5dc7114e1736abe0"
},
"downloads": -1,
"filename": "pocketbasex-0.8.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "12c6371d2969c3e1aee86d55d5057903",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 22738,
"upload_time": "2023-05-29T08:27:39",
"upload_time_iso_8601": "2023-05-29T08:27:39.053815Z",
"url": "https://files.pythonhosted.org/packages/02/e9/1b75f426f03adfefcd442ed55ca483cb94495ba098a4522b5d1a800c9cca/pocketbasex-0.8.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2e7b0bc18ba87429d0942f05d86aedfd437156af7f2deb452f53334b0b7bfba0",
"md5": "fa4071c2b5420928b4f080b7cccc1769",
"sha256": "4d39fc1f19c7582f5b32a37de0f94b75ae749b24bc40dcbb05f19df1fcdb9102"
},
"downloads": -1,
"filename": "pocketbasex-0.8.2.tar.gz",
"has_sig": false,
"md5_digest": "fa4071c2b5420928b4f080b7cccc1769",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 14551,
"upload_time": "2023-05-29T08:27:40",
"upload_time_iso_8601": "2023-05-29T08:27:40.728984Z",
"url": "https://files.pythonhosted.org/packages/2e/7b/0bc18ba87429d0942f05d86aedfd437156af7f2deb452f53334b0b7bfba0/pocketbasex-0.8.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-29 08:27:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "abyesilyurt",
"github_project": "pocketbase",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "pocketbasex"
}