Skip to main content

Cacophony Project REST API client for Python

Project description

Cacophony Project API Client for Python

Python client for the Cacophony REST API.

Installation

This API client requires Python 3.6 or later. At present the library is not yet available on PyPI.

To install, create a virtualenv using your preferred method then:

git clone https://github.com/TheCacophonyProject/python-api.git
cd python-api
pip install .

If you plan on making changes to python-api, you'll want to install the test dependencies as well:

pip install -r .[test]

Using the package (User API)

Client setup

Open an instance of the client and use credentials directly

from cacophonyapi.user import UserAPI
client = UserAPI(baseurl=<SERVER-URL>,
                 username=<USER-NAME>,
                 password=<USER-PASSWORD>)

Alternatively, using credentials stored in a configuration file:

from cacophonyapi.user import UserAPI
from cacophonyapi.config import Config

config=Config().load_config(config_file=os.path.join(
    os.getcwd(),'defaultconfig.json'))

cp_client = UserAPI(config.api_url,
                            username=config.admin_username ,
                            password=config.admin_password)

API calls

By default the most recent 100 recordings accessible to the user account are queried but UserAPI.query() does support a number of filtering options. The API server supports arbitrary queries so feel free to extend UserAPI.query() if required.

Testing

#TODO: expand testing in both test_client_user_without_server.py and test_client_user_with_server.py

Testing uses the pythony unittest framework where by both unit and integration testing is done.

test\test_client_user_without_server.py is tests without requiring a server nose2 --verbosity 2 cacophonyapi.test.test_client_user_without_server

and test\test_client_user_with_server is full integration testing against a server. This is also part of the travis test nose2 --verbosity 2 CacophonyClient.test.test_client_user_with_server. This integration testing does require a local server setup see travis.yml

For individual test nose2 --verbosity 2 cacophonyapi.test.test_client_user_with_server.mockedCacophonyServer.test_query

#TODO: Docs improve PEP257 compliance for cacophonyapi UserApi etc, don't know why it is not failing tox -e pep257

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

cacophonyapi-0.0.1.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

cacophonyapi-0.0.1-py2.py3-none-any.whl (20.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file cacophonyapi-0.0.1.tar.gz.

File metadata

  • Download URL: cacophonyapi-0.0.1.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.1

File hashes

Hashes for cacophonyapi-0.0.1.tar.gz
Algorithm Hash digest
SHA256 784baf0c0a0fd8f54787056b05f2f0c33fd9490bd11cf294d13f92d30f85ee4a
MD5 e7950868fb5ef5e64a0a8e648bb4a182
BLAKE2b-256 21b4adb6904d2d1de0dcd58aa1c31c249d3b38b54ce1bcdff04d517dbcfa2ed0

See more details on using hashes here.

File details

Details for the file cacophonyapi-0.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: cacophonyapi-0.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.9

File hashes

Hashes for cacophonyapi-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f175cc1f7603c4e2b1c44fdf8a63c9a101082b7863d896aacd77cd3bcbc68330
MD5 c655329d1e572f1b33c1d3140f25fc77
BLAKE2b-256 e28ad3eb35b6f87e6d67839692928fd3d5da794a3b18ce05b03f7b6b122ede83

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