{"id":50496881,"url":"https://github.com/johind/pydirectus","last_synced_at":"2026-06-02T08:04:32.529Z","repository":{"id":209845034,"uuid":"702979615","full_name":"johind/pydirectus","owner":"johind","description":"Minimalist Python wrapper for the Directus REST API with automatic authentication.","archived":false,"fork":false,"pushed_at":"2023-12-18T18:34:42.000Z","size":59,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-12-19T16:00:06.935Z","etag":null,"topics":["api-wrapper","cms","directus","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-10-10T11:21:12.000Z","updated_at":"2023-12-19T16:00:06.936Z","dependencies_parsed_at":"2023-11-29T13:30:49.304Z","dependency_job_id":"9fa38e93-c5ea-486b-b8cb-8dafdaaf35ec","html_url":"https://github.com/johind/pydirectus","commit_stats":null,"previous_names":["johind/pydirectus"],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/johind/pydirectus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johind%2Fpydirectus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johind%2Fpydirectus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johind%2Fpydirectus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johind%2Fpydirectus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johind","download_url":"https://codeload.github.com/johind/pydirectus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johind%2Fpydirectus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33812208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wrapper","cms","directus","python"],"created_at":"2026-06-02T08:04:31.550Z","updated_at":"2026-06-02T08:04:32.518Z","avatar_url":"https://github.com/johind.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyDirectus: Python API Wrapper for Directus\n\nPyDirectus is a simple and lightweight Python REST API wrapper for [Directus](https://github.com/directus/directus). It provides methods and typed dicts to work with items and files and is easily extensible. It also handles authentication and re-authentication.\n\nThe low-level rest adapter is based on [this series of blog posts](https://www.pretzellogix.net/2021/12/08/how-to-write-a-python3-sdk-library-module-for-a-json-rest-api/) by [@PretzelLogix](https://github.com/PretzelLogix)!\n\n\u003e [!IMPORTANT]\n\u003e Please be aware that PyDirectus is still under active development and some parts may be subject to change in the future!\n\n## Installation\n\n```bash\npip install git+https://github.com/johind/pydirectus\n```\n\n## Getting Started\n\nTo get started with PyDirectus, create an instance of the `DirectusClient` class by providing your Directus instance's hostname. You can also include optional parameters for authentication, SSL verification, and logging.\n\n```python\nfrom pydirectus import DirectusClient\n\ndirectus = DirectusClient(hostname=\"http://0.0.0.0:8055\")\n```\n\n### Authentication\n\nThe authentication process is done automatically, and you have a couple of options to choose from:\n\n- **Static Token:** Provide a static token for simple authentication that bypasses the logic of the authentication process.\n- **Username and Password:** Use your Directus username and password for a more secure authentication.\n\n```python\ndirectus = DirectusClient(\n    hostname=\"http://0.0.0.0:8055\",\n    static_token=\"your_static_token\",\n    # OR\n    username=\"your_username\",\n    password=\"your_password\",\n)\n```\n\n\u003e [!NOTE]\n\u003e If you use both types of authentication, a static token takes precedence.\n\n### Making a request\n\nNow that you have your PyDirectus client set up, making requests is easy. Let's fetch items from a collection:\n\n```python\nitems = directus.read_items(\"articles\")\n```\n\nYou can perform various operations like reading, creating, updating, and deleting items and files using the provided methods in the `DirectusClient`.\n\n\u003e [!TIP]\n\u003e The available query parameters align with the global parameters [outlined in the Directus documentation](https://docs.directus.io/reference/query.html).\n\n### Examples\n\n#### Reading Items\n\n```python\n# Retrieve the latest 10 items from the articles collection\nitems = directus.read_items(\"articles\", query={\"limit\": 10})\n\n# Fetch items that match specific filter criteria\nfiltered_items = directus.read_items(\n    collection=\"articles\",\n    query={\"filter\": {\"author\": {\"_eq\": \"Beff Jezos\"}}},\n)\n```\n\n#### Reading an Item by ID\n\n```python\nitem = directus.read_item(collection=\"articles\", id=\"53356\")\n```\n\n#### Creating an Item\n\n```python\nnew_item_data = {\"field1\": \"value1\", \"field2\": \"value2\"}\ncreated_item = directus.create_item(\"your_collection\", data=new_item_data)\n```\n\n#### Updating an Item\n\n```python\nupdated_item_data = {\"field1\": \"new_value1\"}\nupdated_item = directus.update_item(\n    collection=\"your_collection\", id=\"item_id\", data=updated_item_data\n)\n```\n\n#### Deleting an Item\n\n```python\ndirectus.delete_item(collection=\"your_collection\", id=\"item_id\")\n```\n\n### Working with files\n\nThe method scheme introduced earlier also applies to other tables, such as the files\n\n```python\n# Retrieve the latest 5 files\nfiles = directus.read_files(query={\"limit\": 5})\n```\n\nCurrently, only existing files stored in the directory can be added. Uploading a file is not possible yet. This feature will be added soon!\n\n```python\nfile_data: File = {\n    \"storage\": \"local\",\n    \"filename_disk\": \"demo/big-buck-bunny.mp4\",\n    \"filename_download\": \"big-buck-bunny.mp4\",\n    \"title\": \"Big Buck Bunny Demo\",\n    \"type\": \"video/mp4\",\n    \"filesize\": 24252243, # in bytes\n    \"width\": 1920,\n    \"height\": 1080,\n    \"duration\": 596047, # in milliseconds\n    \"metadata\": {\"frame_rate\": 25.0}, # optional example\n}\n\ncreated_file = directus.create_file(file_data)\n```\n\nTo learn more about the client, refer to the methods provided in the [DirectusClient](https://github.com/johind/pydirectus/blob/main/pydirectus/directus.py#L33)!\n\nFeel free to report issues on [GitHub](https://github.com/johind/pydirectus).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohind%2Fpydirectus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohind%2Fpydirectus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohind%2Fpydirectus/lists"}