A bunch of scripts that abstracts the Directus-REST-Api for faster development.
Project description
Directus-Python-Client
This library aims to provide a simple and easy to use interface to the Directus API. It is written in Python and uses the requests library.
Motivation
Working with APIs can sometimes be a bit cumbersome. If you are not careful, boilerplates can quickly lead to code duplication. Most of the time they come from similar workflows. Like authentication, request header configuration or just the execution of the request itself.
Documentation
Authentication
from directus_api import DirectusApi
# Authentication
api = DirectusApi(username="username", password="password", endpoint="https://directus.example.com")
Items
Retrieve Items:
...
# (Optional) Add filter_dict to filter items.
# (Optional) Add arg 'show_progress' to show progress bar.
# (Optional) Add 'limit' to limit the number of items to retrieve. If None all items will be returned.
items = api.get_items(collection="collection_name",
limit=42,
filter_dict={'match_id': {'_eq': 'wzi6xmt37'}},
show_progress=True)
print(items)
Create Items:
...
# Create a single item or multiple items
item = api.create_items(collection="collection_name", data=[{"title": "My new item"}])
Update Items:
...
# Update a single item or multiple items. Primary key (here 'id') is required.
item = api.update_items(collection="collection_name", data=[{"title": "My updated item", "id": 1}])
Delete Items:
...
# Delete a single item by id from a collection
item = api.delete_item_by_id(collection="collection_name", id=1)
# Delete all items from a collection
item = api.delete_items_by_ids(collection="collection_name", ids=[1, 2, 3])
#
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for directus-python-client-1.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcfc72b4e6657e2d399db8b0cd2f715cdea58faa5301e2d77d555b978223ea29 |
|
MD5 | 247236e10acc47be22d892b4b0a02d37 |
|
BLAKE2b-256 | a865789dac577f0ace7b1468547fcc2035282baae6edb734ba87893c69cf4a9e |
Close
Hashes for directus_python_client-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | debffd72eebc39df2503a79ebc973aecbb667caaf002c6fe963d81f4c0a3ecc5 |
|
MD5 | 1be080b4207eb4d89510d88a893a4624 |
|
BLAKE2b-256 | 293784cfebd528ce7f60e73f5160151fcabb0fbb977c85d428331552bb7a750c |