Carson Living Python API
Python Carson Living is a library written in Python that exposes the carson.live devices as Python objects.
Please note, that Carson does not provide an official API documentation, therefore this project is solely based on reverse engineering.
Getting started
Installation
Carson Living Python should work against Python 2.x >= 2.7 and Python 3.x >= 3.5.
# Installing from PyPi
$ pip install carson_living
# Installing latest development
$ pip install \
git+https://github.com/rado0x54/python-carson-living@master
Initialize a Carson API object
# Initializing an API object
carson = Carson("account@email.com", 'your password')
print(carson.user)
# >> Martin
print(carson.token)
# >> ey...
You are also able to pass a valid JWT token during initialization which would prevent a login action as long as the token is valid:
# Initializing an API object with a valid token
carson = Carson("account@email.com", 'your password', 'ey....')
print(carson.token)
# >> Martin
Since Carson Living uses JWT token with very long validity, it is recommended to save the active token via carson.token, whenever one needs to reinitialize the API later on. The API library is robust to handle expired JWT tokens (and 401 handling), so no need to check before.
Carson entities
The library currently supports the following entities and actions.
User (carson.user): read
Building (carson.buildings): read
Doors (building.doors): read, open
Cameras (building.cameras): read, images, video
Door entities
Doors can be “buzzed” open via door.open()
# Open all Unit Doors of Main Building
for door in carson.first_building.doors:
if door.is_unit_door:
print('Opening Unit Door {}'.format(door.name))
door.open()
Camera entities
Eagle Eye cameras can produce live images and videos but also allow access to passed recordings (see API). The API can download the image and video directly into a provided file object or just pass a generated url with an eagle_eye auth key A=c000..... Please note, that the url can only be accessed as long as the auth_key is valid. Therefore it may make sense to force the eagle eye api to refresh the auth key before generating a image or video url.
Directly save a live image:
for camera in building.cameras:
with open('image_{}.jpeg'.format(camera.entity_id), 'wb') as file:
camera.get_image(file)
Directly save a live video of 10s:
for camera in building.cameras:
with open('video_{}.flv'.format(camera.entity_id), 'wb') as file:
camera.get_video(file, timedelta(seconds=10))
Directly download a image from a timestamp:
three_hours_ago = datetime.utcnow() - timedelta(hours=3)
# download all images from 3 hours ago
for camera in building.cameras:
with open('image_{}.jpeg'.format(camera.entity_id), 'wb') as file:
camera.get_image(file, three_hours_ago)
Directly download a recorded video from a timestamp:
three_days_ago = datetime.utcnow() - timedelta(days=3)
# download all videos from 3 days ago
for cam in building.cameras:
with open('video_{}.flv'.format(cam.entity_id), 'wb') as file:
cam.get_video(file, timedelta(seconds=5), three_days_ago)
The Carson API is also able to produce authenticated URLs that can be handled externally. Please not, that the auth_key has a limited lifetime. Therefore it makes sense to update the auth_key manually before retrieving predefined URLs. Note, the Eagle Eye API in Carson is associated with a building, so it is sufficient to update it once for all cameras in the same building. The function signature of the the _url function is identical to the previous ones (minus the file object).
# Update Session Auth Key of Eagle Eye once in a while if using
# generated authenticated URLs.
# Note, this is not needed for get_image() or get_video()
building.eagleeye_api.update_session_auth_key()
for cam in building.cameras:
img_url = cam.get_image_url(three_days_ago)
print(img_url)
# >> https://cXXX.eagleeyenetworks.com/asset/prev/image.jpeg?id=c0×tamp=20200122211442.575&asset_class=pre&A=c000~...
response = requests.get(img_url)
with open('image_{}_with_url.jpeg'.format(cam.entity_id), 'wb') as file:
file.write(response.content)
# do only 1 cam.
break
Use cam.get_video_url() the same way.
CLI Tool
Checkout ./scripts/carsoncli.py for further API implementation examples.
Development Notes
Request Headers
The library currently works with the following base headers:
User-Agent: Carson/1.0.171 (live.carson.app; build:245; iOS 13.1.0) Alamofire/1.0.171
X-Device-Type: ios
X-App-Version: 1.0.171(245)
Code Documentation
The code follow the Google Python Styleguide for docstring.
Git Branching Strategy
This project uses gitflow as a git branching model.
Open Items
The following is not supported by the API yet and remains TODO.
Expose visitor functionality (/visitors)
Expose thread / messaging functionality (/threads)
Expose delivery functionality (/deliveries)
Expose dashboard functionality (/dashboard)
Expose service functionality (/service)
Integrate Twilio (twilio/access-token/)
Expand and extract EagleEye API (into separate project?).
License
python-carson-living is released under the Apache License Version 2.0. See the LICENSE file for more details.
Credits && Thanks
A lot of the project setup and the API object design was inspired / launched off https://github.com/tchellomello/python-ring-doorbell. Saved me a lot of headaches with tox, setuptools and Travis!.
Metadata
Release files for carson-living 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| carson_living-0.0.5.tar.gz | 18.0 kB | Without provenance | Details for carson_living-0.0.5.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| carson_living-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for carson_living-0.0.5-py3-none-any.whl |
| carson_living-0.0.5-py2-none-any.whl | Python 2 | none | any | Details for carson_living-0.0.5-py2-none-any.whl |
Total release size: 64.5 kB
Release files / carson_living-0.0.5.tar.gz
| Download URL | carson_living-0.0.5.tar.gz |
|---|---|
| Size | 18.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61adddf8226476a18d71907b5d3187588aaf908ffe31808c892580b9b538097f
|
|
BLAKE2b-256 checksum How to use checksums |
63a3db895edd70d5a944842d6bd125fa0d19747c07de2f7bd35031587aa1bcaa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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.53.0 CPython/3.7.1
|
Release files / carson_living-0.0.5-py3-none-any.whl
| Download URL | carson_living-0.0.5-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
09344247cf3c15be4b936f1882fa49c9541add6eddbaa2b65a9a0c6ed877b3f5
|
|
BLAKE2b-256 checksum How to use checksums |
9e747515a3baa731346248d81d4b1271433b8393cf2e92b83a9903b3faf42a3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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.53.0 CPython/3.7.1
|
Release files / carson_living-0.0.5-py2-none-any.whl
| Download URL | carson_living-0.0.5-py2-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
8cd6db7f160da71474e1b303f46cc8c52b7bd71c0182d0e418bf1e7e580fb081
|
|
BLAKE2b-256 checksum How to use checksums |
925f5ca51c2f9162f5590369288fa8f677bcff56f4aa917cdddc1d91c217cac3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/2.7.15
|
Security for carson-living 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.