Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

smaXtec API client

Project description

# sxapi
smaXtec API Client

Python wrapper for the smaXtec public API

## Usage ##
To use the API smaXtec user credentials (smaXtec Messenger Account) are needed.

from sxapi import API

a = API(email="", password="mypassword")

# Get organisations
orgas = a.organisations
print orgas

# Get Animals in an organisation
animals = orgas[0].animals
print animals
# Get Sensordata for an animal
data = animals[0].get_frame(["temp", "act"], days_back=10)

# Get Events for an animal
events = animals[0].get_events()

# Get by id
print a.get_organisation("5721e3f8a80a5f54c6315131").devices
print a.get_animal("572209c1a80a5f54c631513f").name
print a.get_animal("572209c1a80a5f54c631513f").heats
print a.get_animal("572209c1a80a5f54c631513f").lactations
print a.get_animal("572209c1a80a5f54c631513f").current_dim
print a.get_animal("572209c1a80a5f54c631513f").dim_range(datetime.datetime(2018,1,1),, interval=12*60*60)

# Show request stats

### Timezone Awareness ###

By default the API Client tries to make all datetimes timezone aware with pendulum datetime instances.

To deactivate this behaviour create API Clients with *tz_aware=False*

from sxapi import API

a = API(email="", password="mypassword", tz_aware=False)

## Low Level Usage ##

from sxapi import LowLevelAPI

a = LowLevelAPI(email="", password="mypassword")

# Get by id
print a.get_organisation_by_id("5721e3f8a80a5f54c6315131")
print a.get_animal_by_id("572209c1a80a5f54c631513f")
print a.getAnimal("dsdsd") # from internal works only with api key

## Flask Usage ##
The API Client includes a Flask Extension Module for usage of the LowLevel API.
Usage is only possible with a permanent API Token and an internal endpoint.

from flask import Flask, jsonify
from sxapi.ext import FlaskSX

class MYCONFIG(object):
DEBUG = True

app = Flask(__name__)
api = FlaskSX()

# Example Id: 0700003445
def show_device(device_id):
return jsonify(api.get_device_by_id(device_id))

# Example Id: 59f0743b093ed5cab7a1fb18
def show_animal(animal_id):
return jsonify(api.get_animal_by_id(animal_id))

def show_home():
public = api.get_public_status()
private = api.get_private_status()
return jsonify({"public": public, "private": private})

if __name__ == "__main__":

## Development ##

To build a new pip version increase version and tag with git tag -a "vX.X".
Build artifacts and push to pip
python sdist bdist_wheel
twine upload dist/*

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
sxapi-0.13-py2-none-any.whl (16.8 kB) Copy SHA256 hash SHA256 Wheel py2 May 14, 2018
sxapi-0.13-py3-none-any.whl (16.8 kB) Copy SHA256 hash SHA256 Wheel py3 May 14, 2018
sxapi-0.13.tar.gz (15.2 kB) Copy SHA256 hash SHA256 Source None May 14, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page