Skip to main content

CarConnectivity plugin providing a REST API

Project description

CarConnectivity Plugin for a REST API

GitHub sourcecode GitHub GitHub issues PyPI Downloads

CarConnectivity is a python API to connect to various car services. This plugin provides a REST API that allows other clients to interact with CarConnectivity's object tree.

Supported operations

  • GET data from CarConnectivity's object tree
  • PUT writable attributes (change values)
  • POST commands with their arguments

Installation

pip install carconnectivity-plugin-restapi

Configuration

Add the plugin to your carconnectivity.json configuration file:

{
    "carConnectivity": {
        "connectors": [...],
        "plugins": [
            {
                "type": "restapi",
                "config": {
                    "host": "0.0.0.0",
                    "port": 40000,
                    "username": "admin",
                    "password": "secretpassword"
                }
            }
        ]
    }
}

Multiple users

{
    "carConnectivity": {
        "plugins": [
            {
                "type": "restapi",
                "config": {
                    "port": 40000,
                    "users": [
                        {"username": "user1", "password": "pass1"},
                        {"username": "user2", "password": "pass2"}
                    ]
                }
            }
        ]
    }
}

HTTPS

{
    "carConnectivity": {
        "plugins": [
            {
                "type": "restapi",
                "config": {
                    "port": 40000,
                    "https": true,
                    "ssl_certificate_file": "/path/to/cert.pem",
                    "ssl_certificate_key_file": "/path/to/key.pem",
                    "username": "admin",
                    "password": "secret"
                }
            }
        ]
    }
}

API Usage

All endpoints require HTTP Basic Authentication.

GET — retrieve data

GET http://localhost:40000/<path>

Returns the object or attribute at <path> in the CarConnectivity object tree as JSON. An empty path (/) returns the entire tree.

Example:

curl -u admin:secret http://localhost:40000/garage/WVWZZZAUZLW123456/charging/connector/connection_state

PUT — set a writable attribute

PUT http://localhost:40000/<path>
Content-Type: application/json

{"value": <new_value>}

Example:

curl -u admin:secret -X PUT -H "Content-Type: application/json" \
     -d '{"value": 80}' \
     http://localhost:40000/garage/WVWZZZAUZLW123456/charging/settings/target_level

POST — execute a command

POST http://localhost:40000/<path>
Content-Type: application/json

{"value": <command_arguments>}

Example:

curl -u admin:secret -X POST -H "Content-Type: application/json" \
     -d '{"value": "start"}' \
     http://localhost:40000/garage/WVWZZZAUZLW123456/climatization/commands/start-stop

Configuration parameters

Parameter Description Default
host Host/IP to listen on 0.0.0.0
port Port to listen on 40000
username Single user username
password Single user password
users List of {username, password} objects
https Enable HTTPS false
ssl_certificate_file Path to SSL certificate file
ssl_certificate_key_file Path to SSL private key file
log_level Log level (DEBUG, INFO, WARNING, ERROR) ERROR

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

carconnectivity_plugin_restapi-0.1a2.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file carconnectivity_plugin_restapi-0.1a2.tar.gz.

File metadata

File hashes

Hashes for carconnectivity_plugin_restapi-0.1a2.tar.gz
Algorithm Hash digest
SHA256 0d9289ca389830379512be507a2cc8160447328038845b0e811bae7d2c019a94
MD5 f89fb8341b8b401d3934702873920d22
BLAKE2b-256 48e6166ebb08a7187a7b7b89751f2cf36f36e165d63f7311cb7955b92c77d393

See more details on using hashes here.

Provenance

The following attestation bundles were made for carconnectivity_plugin_restapi-0.1a2.tar.gz:

Publisher: build_and_publish.yml on tillsteinbach/CarConnectivity-plugin-restapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file carconnectivity_plugin_restapi-0.1a2-py3-none-any.whl.

File metadata

File hashes

Hashes for carconnectivity_plugin_restapi-0.1a2-py3-none-any.whl
Algorithm Hash digest
SHA256 ef9a9a432a0440ddead216333a49b98ddf640493659aba6b40399d96d07142f0
MD5 da659da9d99eb6afd00f99f970766b08
BLAKE2b-256 16ee7c3480e7a2dda2eecc36307e1b3a9c05147d9b067740cb4dbe3464cd272d

See more details on using hashes here.

Provenance

The following attestation bundles were made for carconnectivity_plugin_restapi-0.1a2-py3-none-any.whl:

Publisher: build_and_publish.yml on tillsteinbach/CarConnectivity-plugin-restapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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