Skip to main content

Nuxeo REST API Python client

Project description

Client Library for Nuxeo API

Build Status Coverage Lines of code

The Nuxeo Python Client is a Python client library for the Nuxeo Automation and REST API. It works with both Python 2 and 3.

This is an ongoing project, supported by Nuxeo.

Getting Started

The installation is as simple as:

python -m pip install --upgrade nuxeo

Then, use the following import statement to have access to the Nuxeo API:

from nuxeo.client import Nuxeo

Documentation

Check out the API documentation.

Requirements

The Nuxeo Python client works only with:

  • the Nuxeo Platform >= LTS 2015

  • requests >= 2.12.2 (for unicode authentication)

  • setuptools >= 30.3.0

Quick Start

This quick start guide will show how to do basics operations using the client.

Connect to the Nuxeo Platform

The easiest way to connect to the Nuxeo Platform with a basic authentication is passing a tuple containing the username and the password to the client, like so:

nuxeo = Nuxeo(auth=('Administrator', 'Administrator'))

You can then use the nuxeo object to interact with the Platform. If you want to use a specific instance, you can specify the base_url like so:

nuxeo = Nuxeo(
    host='http://demo.nuxeo.com/nuxeo/',
    auth=('Administrator', 'Administrator')
)

Download/Upload Configuration

In the nuxeo/constants.py file, you have several constants that are used throughout the client that you can change to fit your needs. Some of them are:

  • CHECK_PARAMS (False by default), to check operation’s parameters for each and every HTTP calls.

  • CHUNK_LIMIT (10 MiB by default), the size above which the upload will automatically be chunked.

  • CHUNK_SIZE (8 KiB by default), the size of the chunks when downloading.

  • MAX_RETRY (5 by default), the number of retries for connection error on any HTTP call.

  • UPLOAD_CHUNK_SIZE (20 MiB by default), the size of the chunks when uploading.

Run NXQL Queries

You can run queries in NXQL (NXQL is a subset of SQL, you can check how to use it in the documentation). Here, we are first fetching a workspace, and then using its uid to build a query which will find all its children that have a File or Picture type, and are not deleted.

# Fetch a workspace
ws = nuxeo.documents.get(path='/default-domain/workspaces/ws')

# Build a query using its UID
nxql = ("SELECT * FROM Document WHERE ecm:ancestorId = '{uid}'"
        "   AND ecm:primaryType IN ('File', 'Picture')"
        "   AND ecm:currentLifeCycleState != 'deleted'")
query = nxql.format(uid=ws.uid)

# Make the request
search = nuxeo.client.query(query, params={'properties': '*'})

# Get results
entries = search['entries']

entries will be a list containing a dict for each element returned by the query.

Usage

Now that your client is set up, here are pages to help you with the main functions available:

You can also check the API documentation of this Python client for further options.

Contributing

See our contribution documentation.

Setup

git clone https://github.com/nuxeo/nuxeo-python-client
cd nuxeo-python-client
python setup.py develop

Test

A Nuxeo Platform instance needs to be running on http://localhost:8080/nuxeo for the tests to be run, and then:

python -m pip install -U --user tox
tox

Tests can be launched without a server with Maven and tox:

mvn -f ftest/pom.xml clean verify

Sentry

We use Sentry to catch unhandled errors from tests. You can tweak it before running tox.

It can be disabled:

export SKIP_SENTRY=1

You can also customize the Sentry DSN for your own team:

export SENTRY_DSN="XXX"

And customize the Sentry environment too:

# Note that the default value is "testing"
export SENTRY_ENV="testing"

Deploying

For the maintainer, the command to distribute the module is:

python3 -m pip install wheel
python3 setup.py sdist bdist_wheel upload

Reporting Issues

You can follow the developments in the Nuxeo Python Client project of our JIRA bug tracker: NXPY.

You can report issues on answers.nuxeo.com.

License

Apache License 2.0 Copyright (c) Nuxeo

About Nuxeo

Nuxeo dramatically improves how content-based applications are built, managed and deployed, making customers more agile, innovative and successful. Nuxeo provides a next generation, enterprise ready platform for building traditional and cutting-edge content oriented applications. Combining a powerful application development environment with SaaS-based tools and a modular architecture, the Nuxeo Platform and Products provide clear business value to some of the most recognizable brands including Verizon, Electronic Arts, Sharp, FICO, the U.S. Navy, and Boeing. Nuxeo is headquartered in New York and Paris. More information is available at www.nuxeo.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nuxeo-2.2.4.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

nuxeo-2.2.4-py2.py3-none-any.whl (36.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file nuxeo-2.2.4.tar.gz.

File metadata

  • Download URL: nuxeo-2.2.4.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for nuxeo-2.2.4.tar.gz
Algorithm Hash digest
SHA256 0f8a98024b1a7a27dc3cb1f9fde60bb858cf55d41a8b899364f40488e1c29c74
MD5 12147c055855da5db691c446d1eeef63
BLAKE2b-256 3d942cf5c9bdbb6a64498b9e7136fa73a9d1f5f9144d096b9bf3373f30015e6e

See more details on using hashes here.

File details

Details for the file nuxeo-2.2.4-py2.py3-none-any.whl.

File metadata

  • Download URL: nuxeo-2.2.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 36.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for nuxeo-2.2.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a1ecf503dba2c4f2ad2a91234d72f2789ba1036d41a10fe97b7063db6ce95a70
MD5 1069e3700caa290d2b880e8c318e5e56
BLAKE2b-256 84e93c4f4cb8f64685950e999c44f92c28ba763c286acdf06e66cb8e0d6b6d61

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page