# Cacophony Project API Client for Python
Python client for the [Cacophony REST API](https://github.com/TheCacophonyProject/cacophony-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
```python
from cacophonyapi.user import UserAPI
client = UserAPI(baseurl=<SERVER-URL>,
username=<USER-NAME>,
password=<USER-PASSWORD>)
```
Alternatively, using credentials stored in a configuration file:
```python
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](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`
Raw data
{
"_id": null,
"home_page": "https://github.com/TheCacophonyProject/python-api",
"name": "cacophonyapi",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "cacophonyproject api client rest",
"author": "Anthony Uphof, Giampaolo Ferraro, Cameron Ryan-Pears, Menno Finlay-Smits",
"author_email": "coredev@cacophony.org.nz",
"download_url": "https://files.pythonhosted.org/packages/89/3f/affe7d6d3159be8359dbe69c8d2a4dce2a827dc4633b0ffcc52c82fe01e7/cacophonyapi-0.0.4.tar.gz",
"platform": null,
"description": "# Cacophony Project API Client for Python\n\nPython client for the [Cacophony REST API](https://github.com/TheCacophonyProject/cacophony-api).\n\n## Installation\n\nThis API client requires Python 3.6 or later. At present the library is not yet available on PyPI.\n\nTo install, create a virtualenv using your preferred method then:\n\n```\ngit clone https://github.com/TheCacophonyProject/python-api.git\ncd python-api\npip install .\n```\n\nIf you plan on making changes to python-api, you'll want to install the test dependencies as well:\n\n```\npip install -r .[test]\n```\n\n\n## Using the package (User API)\n\n### Client setup\n\nOpen an instance of the client and use credentials directly\n```python\nfrom cacophonyapi.user import UserAPI\nclient = UserAPI(baseurl=<SERVER-URL>,\n username=<USER-NAME>,\n password=<USER-PASSWORD>)\n```\n\nAlternatively, using credentials stored in a configuration file:\n```python\nfrom cacophonyapi.user import UserAPI\nfrom cacophonyapi.config import Config\n\nconfig=Config().load_config(config_file=os.path.join(\n os.getcwd(),'defaultconfig.json'))\n\ncp_client = UserAPI(config.api_url,\n username=config.admin_username ,\n password=config.admin_password)\n```\n\n\n## API calls\n\nBy default the most recent 100 recordings accessible to the user\naccount are queried but `UserAPI.query()` does support a number of\nfiltering options. The API server supports arbitrary queries so feel\nfree to extend `UserAPI.query()` if required.\n\n\n## Testing\n\n#TODO: expand testing in both `test_client_user_without_server.py` and `test_client_user_with_server.py`\n\nTesting uses the pythony unittest framework where by both unit and integration testing is done.\n\n`test\\test_client_user_without_server.py` is tests without requiring a server `nose2 --verbosity 2 cacophonyapi.test.test_client_user_without_server`\n\nand `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`.\nThis integration testing does require a local server setup see [travis.yml](travis.yml)\n\nFor individual test `nose2 --verbosity 2 cacophonyapi.test.test_client_user_with_server.mockedCacophonyServer.test_query`\n\n#TODO: Docs improve PEP257 compliance for cacophonyapi UserApi etc, don't know why it is not failing `tox -e pep257`\n",
"bugtrack_url": null,
"license": "GNU AFFERO GENERAL PUBLIC License 3 19 November 2007",
"summary": "Cacophony Project REST API client for Python",
"version": "0.0.4",
"project_urls": {
"Bug Tracker": "https://github.com/TheCacophonyProject/python-api",
"Documentation": "https://docs.cacophony.org.nz",
"Homepage": "https://github.com/TheCacophonyProject/python-api",
"Source Code": "https://github.com/TheCacophonyProject/python-api"
},
"split_keywords": [
"cacophonyproject",
"api",
"client",
"rest"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "893faffe7d6d3159be8359dbe69c8d2a4dce2a827dc4633b0ffcc52c82fe01e7",
"md5": "65f948c4846e5a7b6c17d862799dcef4",
"sha256": "74cfbbdd16f0f2439186b941ad7244b87fc7911099ae45f44b90209904cabdfe"
},
"downloads": -1,
"filename": "cacophonyapi-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "65f948c4846e5a7b6c17d862799dcef4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 18614,
"upload_time": "2023-12-12T08:32:13",
"upload_time_iso_8601": "2023-12-12T08:32:13.026513Z",
"url": "https://files.pythonhosted.org/packages/89/3f/affe7d6d3159be8359dbe69c8d2a4dce2a827dc4633b0ffcc52c82fe01e7/cacophonyapi-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-12 08:32:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "TheCacophonyProject",
"github_project": "python-api",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "cacophonyapi"
}