Skip to main content

Kinto python client

Kinto is a service allowing you to store and synchronize arbitrary data, attached to a user account. Its primary interface is HTTP.

kinto-client is a Python library aiming at easing interacting with a Kinto server instance. A project with related goals is also available for JavaScript.

Usage

  • The first version of this API doesn’t cache any access nor provide any refresh mechanism. If you want to be sure you have the latest data available, issue another call.

Here is an overview of what the API looks like:

from kinto_client import Bucket

bucket = Bucket('default', server_url='http://localhost:8888/v1',
                auth=('alexis', 'p4ssw0rd'))
todo = bucket.get_collection('todo')

records = todo.get_records()
for i, record in enumerate(records):
    record.data.title = 'Todo #%d' %i

todo.save_records(records)

Handling buckets

All operations are rooted in a bucket. It makes little sense for one application to handle multiple buckets at once.

The passed auth parameter is a requests authentication policy, allowing authenticating using whatever fits you best.

By default, Kinto supports Firefox Accounts and Basic authentication policies.

credentials = ('alexis', 'p4ssw0rd')

bucket = Bucket('payments', server_url='http://localhost:8888/v1',
                auth=credentials)

# Passing `create=True` to the bucket will make an HTTP request to
# create it.
bucket = Bucket('payments', server_url='http://localhost:8888/v1',
                auth=credentials, create=True)

Collections

A collection is where records are stored.

# Once the bucket handy, use it to handle collections or groups.
collection = bucket.create_collection('receipts')

# Or get an existing one.
collection = bucket.get_collection('receipts')

# To delete an existing collection.
bucket.delete_collection('receipts')

Records

Records can be retrieved from and saved to collections.

# You can pass a python dictionary to create the record
record = collection.create_record(dict(id='XXX', status='done',
                                       title='Todo #1'))

# Get all records
record = collection.get_records()
record = collection.get_record(id='89881454-e4e9-4ef0-99a9-404d95900352')
collection.save_record(record)
collection.save_records([record1, record2])
collection.delete_record(id='89881454-e4e9-4ef0-99a9-404d95900352')
collection.delete_records([record1, record2])

# Alternative use
record.save()

Permissions

By default, authenticated users will get read and write access to the manipulated objects. It is possible to change this behavior by passing a dict to the permissions parameter.

record = collection.create_record(
    data={},
    permissions={'read': ['group:groupid']})

The Bucket, Collection, Group and Record classes have a special permissions object that can be mutated in order to update the permissions model attached to the object.

bucket = Bucket('default', auth=('alexis', 'p4ssw0rd'))

friends = ['natim', 'niko', 'mat', 'tarek']
bucket.permissions.write += friends
bucket.permissions.create_collection += friends

# You *need* to call save in order to have these changes reflected in the
# remote.
bucket.save()

Installation

To install the kinto client, use pip:

$ pip install kinto_client

Metadata

Release files for kinto-client 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kinto-client 0.2.0
File Size Uploaded
kinto-client-0.2.0.tar.gz 13.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kinto-client 0.2.0
File Interpreter ABI Platform
kinto_client-0.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 30.7 kB

Release files / kinto-client-0.2.0.tar.gz

Download URL kinto-client-0.2.0.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8c86c13785fe2616e9a7130bb513b3961785b545bc6f95c868505fe5c076f108
BLAKE2b-256 checksum
How to use checksums
1165cb3d152057746bd9945b0c83189ee86b74bc2f5e8353098a2fec5359b06c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / kinto_client-0.2.0-py2.py3-none-any.whl

Download URL kinto_client-0.2.0-py2.py3-none-any.whl
Size 17.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
10feaa0034ce0469a8b93032037de62fe402ed2bf75ec35c0f130aa67754c6a9
BLAKE2b-256 checksum
How to use checksums
e17e3026b26807ba46ca0d98a6393b39491344b6818035d55566f532c73ea272
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

5.0.0

2 release files

4.1.0

1 release file

4.0.0

2 release files

3.1.0

1 release file

3.0.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

This release

0.2.0 This release

2 release files

0.1.1

2 release 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