Command Line

Start by downloading the most recent version of our Python API on Github. You can also check out our Python Package on the Python Package Index or Github. You may also use pip to install the Leftronic package with pip install leftronic.

Import the file:

# Import file (location may vary)
from leftronic import Leftronic

Create a class instance with your Access Key:

update = Leftronic("YOUR_ACCESS_KEY")

Try pushing to your dashboard with some of these functions, substituting the names of your custom widgets.

# Example: push a number to a widget
update.pushNumber("yourNumberStream", 14600)
 
# Example: push a location to a map widget
update.pushGeo("yourGeoStream", 37.8, -122.6)
 
# Or choose a color for your map point (red, blue, green,
# purple, and yellow only)
update.pushGeo("yourGeoStream", 37.8, -122.6, "blue")
 
# Example: push a title and message to a text feed widget
update.pushText("yourTextStream", "This is my title.",
    "Hello World!")
 
# Example: push an array to a leaderboard widget
leaderArray = [{"name": "Johnny", "value": 84},
    {"name": "Jamie", "value": 75},
    {"name": "Lance", "value": 62}]
update.pushLeaderboard("yourBoardStream", leaderArray)
 
# Example: push an array to a list widget
listArray = [{"listItem": "Elizabeth"},
    {"listItem": "Marshall"},
    {"listItem": "Claire"},
    {"listItem": "Nolan"}]
update.pushList("yourListStream", listArray)
 
# Example: push an image URL
update.pushImage("yourImageStream",

# Example: push a Label Widget
update.pushLabel("yourLabelStream", "Uptime")
 
# Updating an X-Y Graph widget
x = 15
y = 8
update.pushPair("yourGraphStream", x, y)
# x and y can be arrays: x = [10, 23, 45], y = [12, 90, 30]
# creates three points at (10, 12), (23, 90) and (45, 30)
 
# Updating a Table widget:
headerRow = ['name', 'city', 'country']
dataRows = [ ['Lionel', 'Rosario', 'Argentina'],
    ['Andres', 'Albacete', 'Spain']]
update.pushTable("yourTableStream", headerRow, dataRows)
 
# Updating an HTML widget:
html = '<html><body>Hi there!</body></html>'
update.pushHtml('yourHtmlStream', html)
 
# And clearing a widget. You can programmatically clear Map,
# Text Feed, Sparkline/Line Graph, and X-Y Graph widgets:
update.clear("yourStreamName")
 
# Example: push to multiple streams
multipush = []
multipush.append(update.populateNumber("MyNumberStream", 42))
multipush.append(update.populateGeo("MyMap", 34, -118))
update.pushMultiple(multipush)