Getting Started
10 min
the litmus software development kit (sdk) is a python module that allows users to easily interface with the litmus product apis this documentation assumes a basic familiarity with python including virtual environments package installation and management classes and objects supported versions the sdk only supports the lts versions of litmus edge it is not guaranteed to work with newer versions that are not explicitly documented below litmus edge 3 16 x installation install from whl using a package manager of your choice (eg pip), install from whl using the documentation provided by your package manager for pip that would be pip install {filename} whl the released wheels can be found under the releases page https //github com/litmusautomation/litmus sdk/releases configuration authorization running the sdk, and accessing the litmus edge apis requires the user to configure the module with a valid authentication to read more about configuration and authorization see docid\ vwtfo9sxcmrbfx9cafenw step 1 generate access tokens if you are connecting directly to your litmus edge device you need the following edge url url of your litmus edge instance (eg 127 0 0 1 or https //127 0 0 1 ) edge api client id oauth2 token id edge api client secret oauth2 token secret to generate your oauth2 token please review the following https //docs litmus io/litmusedge/how to create and use oauth 20 tokens in litmus edge if you are connecting via the litmus edge manager bridge you need the following edge manager url url of your lem instance edge manager project id project id of the le instance you want to connect to edge manager device id device id of the le instance you want to connect to edge api token your lem api token for the project to generate an lem api token please review the following https //docs litmus io/litmusedge v1/product features/system/tokens/create api token step 2 (optional) setting connection defaults using environment variables all functions which connect to a litmus edge device require a connection object which specifies and authenticates the connection if no connection object is provided then the sdk uses defaults which are specified using environment variables which can be specified directly or using a env file in the root directory of your python project in the following replace values in brackets with the values you collected in step 1 (e g edge url=127 0 0 1) direct edge connection env env edge url={url} #can include or omit https // header edge api client id={oauth client id} edge api client secret={oauth client secret} \#optional parameters, uncomment to enable \#validate certificate=false #disable validation of ssl certificates during https requests \#timeout seconds=30 #time to wait before timemout of connection, default is 30 seconds edge manager bridge connection env env use lem bridge=true edge manager url={url} #can include or omit https // header edge manager project id={project id} edge manager device id={device id} edge api token={api token} \#optional parameters, uncomment to enable \#validate certificate=false #disable validation of ssl certificates during https requests \#timeout seconds=30 #time to wait before timemout of connection, default is 30 seconds step 3 using the sdk once you have set up your connections your can now use the many methods in the sdk you can tell whether a function makes a call to the litmus api if it requires a connection object as one of its function parameters try one of the following snippets to ensure your setup is correct using a direct edge connection from litmussdk utils conn import new le connection from litmussdk devicehub import devices \# make a manual connection connection= new le connection( edge url= {edge url}, client id= {edge api client id}, client secret= {edge api client secret}, \#validate certificate=false, # optional argument \#timeout seconds=30=, # optional argument ) \# make an api call with a connection devs one = devices list devices( le connection=connection, ) \# make an api call using defaults set in environment variables \# will fail if skipped step 2 devs two = devices list devices() using the lem bridge from litmussdk utils conn import new lem bridge connection from litmussdk devicehub import devices \# make a manual connection connection = new lem bridge connection( edge manager url={edge manager url}, edge api token={edge api token}, project id={edge manager project id}, device id={edge manager device id}, \#validate certificate=false, # optional argument \#timeout seconds=30, #optional argument ) \# make an api call with a connection devs one = devices list devices( le connection=connection, ) \# make an api call using defaults set in environment variables \# will fail if skipped step 2 devs two = devices list devices() support state support š¢ complete this feature is released and actively supported by the team š” under development this feature is undergoing active development but is not yet supported š“ planned this feature is planned feature description python analytics access and create processors and instances for data analysis at the edge š¢ devicehub support for device and tag creation, reading, and deletion alongside tag browsing š¢ digital twins support for the digital twins service covering models, instances, attributes, transformations, and hierarchies to create virtual representations of industrial assets š¢ flows manager create, start/stop, and delete flows in the flows service š¢ integrations manipulate and access cloud connector integrations to communicate with third party cloud services š¢ marketplace create, start/stop, and delete flows š¢ opc the opc ua (open platform communications unified architecture) protocol provides a publish subscribe client server technology for reliable data transmission š¢ system system wide configuration of litmus edge accessing information such as internal databases, cpu usage, language settings etc š¢ module documentation the below documentation is not exhaustive , and seeks only to serve as an introduction to common use cases and best practices with the various litmus edge services for complete documentation please refer to the docstrings of the methods or our https //api litmus io