Package: iotery-python-server-sdk
iotery.io Python Server SDKThe python iotery.io SDK is intended to be used on your server or in your data processing apps to interact with the itoery.io IoT Platform. The SDK is a fully featured wrapper for theREST API.Getting StartedSetup your free account oniotery.ioand go to yoursettings dashboardto get your server API Key.After you get your key, install the SDK:pipinstalliotery-python-server-sdkNote: Make sure you are using Python 3.5+!And finally, some simple example usage:fromiotery_python_server_sdkimportIoteryiotery=Iotery("my-key")# find the exact `data` specification at https://iotery.io/v1/docs#createDeviceTypedevice_type=iotery.createDeviceType(data={"name":"My Device Type","enum":"MY_DEVICE_TYPE",...})device_type_by_uuid=iotery.getDeviceTypeByUuid(deviceTypeUuid=device_type["uuid"],opts={"limit":1})The above code connects you to the iotary.io platform, creates a device type and then gets that device type.Next, you might want to create a data type for the the device type you created...here's an example snippet:temperature_data_type=iotery.createDataType(deviceTypeUuid=device_type_by_uuid["uuid"],data={name:"Temperature",enum:"TEMPERATURE",units:"C",isNumber:true})To have a "thing" (like a Raspberry Pi) create data, you will want to check out theiotery.io thing client.For a tutorial on setting up a full stack system in 15 minutes using iotery.io, checkthis linkout.APIThis SDK simply wraps theREST API, so more information and specifics can be found there. Since the API is a wrapper around the REST API, the syntax is standard for each of the Create, Read, Update, and Delete operations on iotery.io resources. All methods return a dictonary containing the API response. If there is an error, the method willraisean expection.Creating ResourcesThe generalized syntax for creating resources in iotery.io python sdk looks like:iotery.methodName(inputParameter="parameter",data={"data":"variables"})For example, to create a device, the javascript would look likecreateDevice(deviceTypeUuid="a-valid-device-type-uuid",data={"name":"My Device","other":"parameter"})wherecreateDevicemaps tomethodName,deviceTypeUuidmaps toinputParameter, andnameandothermap to the dictonary{data : "variables"}in the generalized form given above.The available resource creation methods aremethodNameinputlinkdescriptioncreateAccountManagerlinkCreate an account manager.createConsumerlinkCreate a consumer.linkConsumerToDeviceconsumerUuidlinkLink a consumer to a device.linkConsumerToNetworkconsumerUuidlinkLink a consumer to a network.createConsumerSecretconsumerUuidlinkCreate a consumer secret for authentication.createDeviceTypelinkCreate a device type.createSettingTypelinkCreate a setting type.createDefaultSettinglinkCreate a default setting.createDataTypelinkCreate a data type.createDevicelinkCreate a device.createBatchedCommandInstanceslinkCreate a set of batched command instances.clearUnexecutedDeviceCommandInstancesdeviceUuidlinkClear all unexecuted command instance for a device.createDeviceCommandInstancedeviceUuidlinkCreate a command instance for a device.createDeviceNotificationInstancedeviceUuidlinkCreate a notification instance for a device.createSettingdeviceUuidlinkCreate a setting for a device.createFirmwareRecordlinkCreate a firmware record.createSeverityTypelinkCreate a severity type.createNotificationTypelinkCreate a notification type.createNotificationFieldlinkCreate a notification field.createPriorityTypelinkCreate a priority type.createCommandTypelinkCreate a command type.createCommandFieldlinkCreate a command field.createEventTypelinkCreate an event type.createEventlinkCreate an event.createGroupingTypelinkCreate a grouping type.createTeamlinkCreate a team.linkAccountManagerToTeamuserUuidlinkLink account manager to a team.resetTeamteamUuidlinkReset a team by uuid.createGroupingBatchedCommandsgroupingUuidlinkCreate a set of batched commands for a grouping and all child grouping devices.moveDeviceToGroupinggroupingUuidlinkMove a device to a grouping.createNetworklinkCreate a network.createNetworkBatchedCommandsnetworkUuidlinkCreate a set of batched commands for a network's devices.createGroupingnetworkUuidlinkCreate a network grouping.addChildGroupingnetworkUuid,groupingUuidlinkAdd a child grouping.createNetworkLocationnetworkUuidlinkCreate a network location.createSchedulenetworkUuidlinkCreate a schedule.executeNetworkSchedulenetworkUuid,scheduleUuidlinkExecute a schedule.deprovisionNetworknetworkUuidlinkDeprovision a network.provisionNetworklinkProvision a network.provisionDevicenetworkUuid,deviceUuidlinkProvision a device.deprovisionDevicenetworkUuid,deviceUuidlinkDeprovision a device.executeSchedulescheduleUuidlinkExecute a schedule.createGroupingDevicelinkCreate a GroupingDevice link.createGroupingLinklinkCreate a GroupingLink.createWebhookActionlinkCreate a webhook action.createQrCodelinkCreate a QR code.Reading ResourcesThe generalized syntax for reading (getting) resources in iotery.io python sdk looks like:iotery.methodName(inputParameter="parameter",opts={"query":"parameter"})For example, to get a device by it's unique identifieruuid, the python would look likegetDeviceByUuid(deviceUuid="a-valid-device-uuid",opts={"limit":1})wheregetDeviceByUuidmaps tomethodName,deviceUuidmaps toinputParameter, and{ "limit": 1 }maps to the dictonary{"query" : "parameters"}in the generalized form given above.Thelimitoption is for instructive purposes only. By definition, auuidis unique and so there will never be more than one device for a givenuuid.For more advanced queries, some parameters allow for an array of values to be passed in. Two options available are$inand$btwn, which allows a user to specify a set or range of values, respectively. For example, when requesting for data for a device, one may use the SDK as follows:iotery.getDeviceDataList(opts={"dataTypeEnum":{"$in":["ENUM_1","ENUM_2","ENUM_3"]},"timestamp":{"$btwn":[1562759000,1562759500]},"limit":5},deviceUuid="a-valid-device-uuid")Refer to the iotery REST API docs to see when options such as$inand$btwnare available for a given query parameter.The available resource creation methods aremethodNameinputlinkdescriptiongetHealthCheckResultlinkGet the result of a server health check.getAccountManageruserUuidlinkGet an account manager by uuid.getConsumerListlinkGet a list of available consumers.getConsumerconsumerUuidlinkGet a consumer by uuid.getDeviceTypeListlinkGet a list of available device types.getDeviceTypedeviceTypeUuidlinkGet a device type by uuid.getSettingTypeListlinkGet a list of available setting types.getSettingTypesettingTypeUuidlinkGet a setting type by uuid.getDefaultSettingListlinkGet a list of default settings.getDefaultSettingdefaultSettingUuidlinkGet a default setting by uuid.getDataTypeListlinkGet a list of available data types.getDataTypedataTypeUuidlinkGet a data type by uuid.getCommandInstanceListlinkGet a list of command instances.getCommandInstancecommandInstanceUuidlinkGet a command instance by uuid.getDeviceListlinkGet a list of devices.getDevicedeviceUuidlinkGet a device by uuid.getDeviceDataListdeviceUuidlinkGet a list of data for a device.getDeviceEventListdeviceUuidlinkGet a list of events for a device.getDeviceIsppConfigurationdeviceUuidlinkGet an ISPP configuration for a device.getDeviceNotificationInstanceListdeviceUuidlinkGet a list of notification instances for a device.getDeviceSettingListdeviceUuidlinkGet a list of settings for a device.getDeviceSystemEventListdeviceUuidlinkGet a list of system events for a device.getNotificationInstancenotificationInstanceUuidlinkGet a notification instance by uuid.getSettingsettingUuidlinkGet a setting by uuid.getFirmwareRecordListlinkGet a list of firmware records.getFirmwareRecordfirmwareUuidlinkGet a firmware record by uuid.getSeverityTypeListlinkGet a list of available severity types.getSeverityTypeseverityTypeUuidlinkDelete a severity type by uuid.getNotificationTypeListlinkGet a list of available notification types.getNotificationTypenotificationTypeUuidlinkGet a notification type by uuid.getNotificationFieldListlinkGet a list of available notification fields.getNotificationFieldnotificationFieldUuidlinkGet a notification field by uuid.getPriorityTypeListlinkGet a list of available priority types.getPriorityTypepriorityTypeUuidlinkGet a priority type by uuid.getCommandTypeListlinkGet a list of available command types.getCommandTypecommandTypeUuidlinkGet a command type by uuid.getCommandFieldListlinkGet a list of available command fields.getCommandFieldcommandFieldUuidlinkGet a command field by uuid.getEventTypeListlinkGet a list of available event types.getEventTypeeventTypeUuidlinkGet an event type by uuid.getEventListlinkGet a list of events.getEventeventUuidlinkGet an event by uuid.getGroupingTypeListlinkGet a list of available grouping types.getGroupingTypegroupingTypeUuidlinkGet a grouping type by uuid.getTeamListlinkGet a list of available teams.getTeamteamUuidlinkGet a team by uuid.getGroupinggroupingUuidlinkGet a grouping by uuid.getChildGroupingListgroupingUuidlinkGet a list of child groupings for a grouping.getDeviceListForGroupinggroupingUuidlinkGet a list of devices for a grouping.getNetworkListlinkGet a list of networks.getNetworknetworkUuidlinkGet a network by uuid.getNetworkDeviceListnetworkUuidlinkGet a network's devices.getNetworkGroupingListnetworkUuidlinkGet a network's groupings.getNetworkGroupingnetworkUuid,groupingUuidlinkGet a network's grouping by uuid.getNetworkLocationListnetworkUuidlinkGet a network's locations.getNetworkLocationnetworkUuid,networkLocationUuidlinkGet a network location by uuid.getNetworkScheduleListnetworkUuidlinkGet a list of a network's schedules.getNetworkSchedulenetworkUuid,scheduleUuidlinkGet a schedule by uuid.getSchedulescheduleUuidlinkGet a schedule by uuid.getGroupingDeviceListlinkGet a list of GroupingDevice links.getGroupingDevicegroupingDeviceUuidlinkGet a GroupingDevice link by uuid.getGroupingLinkListlinkGet a list of GroupingLinks.getGroupingLinkgroupingLinkUuidlinkGet a GroupingLink by uuid.getWebhookActionListlinkGet a list of webhook actions.getWebhookActionwebhookActionUuidlinkGet a webhook action by uuid.getWebhookActionTypeListlinkGet a list of webhook action types.getWebhookActionTypewebhookActionTypeUuidlinkGet a webhook action type by uuid.getQrCodeListlinkGet a list of QR codes.getQrCodeqrCodeUuidlinkGet a QR code by uuid.Updating ResourcesThe generalized syntax for updating resources in iotery.io python sdk looks like:iotery.methodName(inputParameter="parameter",data={"data":"variables"})For example, to update a device type, the javascript would look likeupdateDeviceType(deviceTypeUuid="a-valid-device-type-uuid",data={"name":"My New Name"})whereupdateDevicemaps tomethodName,deviceTypeUuidmaps toinputParameter, and{ "name": "My New Name" }maps to the dictonary{data : "variables"}in the generalized form given above.The available update methods aremethodNameinputlinkdescriptionupdateAccountManageruserUuidlinkUpdate an account manager by uuid.updateConsumerconsumerUuidlinkUpdate a consumer by uuid.updateDeviceTypedeviceTypeUuidlinkUpdate a device type by uuid.updateSettingTypesettingTypeUuidlinkUpdate a setting type by uuid.updateDefaultSettingdefaultSettingUuidlinkUpdate a default setting by uuid.updateDataTypedataTypeUuidlinkUpdate a data type by uuid.updateCommandInstancecommandInstanceUuidlinkUpdate a command instance by uuid.updateDevicedeviceUuidlinkUpdate a device by uuid.updateNotificationInstancenotificationInstanceUuidlinkUpdate a notification instance.updateSettingsettingUuidlinkUpdate a setting.updateFirmwareRecordfirmwareUuidlinkUpdate a firmware record by uuid.updateSeverityTypeseverityTypeUuidlinkUpdate a severity type by uuid.updateNotificationTypenotificationTypeUuidlinkUpdate a notification type by uuid.updateNotificationFieldnotificationFieldUuidlinkUpdate a notification field by uuid.updatePriorityTypepriorityTypeUuidlinkUpdate a priority type by uuid.updateCommandTypecommandTypeUuidlinkUpdate a command type by uuid.updateCommandFieldcommandFieldUuidlinkUpdate a command field by uuid.updateEventTypeeventTypeUuidlinkUpdate an event type by uuid.updateEventeventUuidlinkUpdate an event by uuid.updateGroupingTypegroupingTypeUuidlinkUpdate a grouping type by uuid.updateTeamteamUuidlinkUpdate a team by uuid.updateGroupinggroupingUuidlinkUpdate a grouping.updateNetworkLocationnetworkLocationUuidlinkUpdate a network location by uuid.updateNetworknetworkUuidlinkUpdate a network by uuid.updateNetworkGroupingnetworkUuid,groupingUuidlinkUpdate a network grouping.updateNetworkNetworkLocationnetworkUuid,networkLocationUuidlinkUpdate a network location.updateNetworkSchedulenetworkUuid,scheduleUuidlinkUpdate a schedule.updateSchedulescheduleUuidlinkUpdate a schedule.updateGroupingDevicegroupingDeviceUuidlinkUpdate a GroupingDevice link by uuid.updateGroupingLinkgroupingLinkUuidlinkUpdate a GroupingLink by uuid.updateWebhookActionwebhookActionUuidlinkUpdate a webhook action by uuid.updateQrCodeqrCodeUuidlinkUpdate a QR code by uuid.Deleting ResourcesThe generalized syntax for reading (getting) resources in iotery.io python sdk looks like:iotery.methodName(inputParameter="parameter",opts={"query":"parameter"})For example, to get a device by it's unique identifieruuid, the python would look likedeleteDevice(deviceUuid="a-valid-device-uuid",opts={"some":"option"})wheredeleteDevicemaps tomethodName,deviceUuidmaps toinputParameter, and{ "some": "option" }maps to the dictonary{"query" : "parameters"}in the generalized form given above.The available resource creation methods aremethodNameinputlinkdescriptiondeleteAccountManageruserUuidlinkDelete an account manager by uuid.deleteConsumerconsumerUuidlinkDelete a consumer by uuid.unlinkConsumerFromDeviceconsumerUuid,deviceUuidlinkUnlink a consumer from a device.unlinkConsumerFromNetworkconsumerUuid,networkUuidlinkUnlink a consumer from a network.deleteConsumerSecretListconsumerUuidlinkDelete all stored consumer secrets.deleteDeviceTypedeviceTypeUuidlinkDelete a device type by uuid.deleteSettingTypesettingTypeUuidlinkDelete a setting type by uuid.deleteDefaultSettingdefaultSettingUuidlinkDelete a default setting by uuid.deleteDataTypedataTypeUuidlinkDelete a data type by uuid.deleteDevicedeviceUuidlinkDelete a device by uuid.deleteNotificationInstancenotificationInstanceUuidlinkDelete a notification instance by uuid.deleteSettingsettingUuidlinkDelete a setting by uuid.deleteFirmwareRecordfirmwareUuidlinkDelete a firmware record by uuid.deleteSeverityTypeseverityTypeUuidlinkDelete a severity type by uuid.deleteNotificationTypenotificationTypeUuidlinkDelete a notification type by uuid.deleteNotificationFieldnotificationFieldUuidlinkDelete a notification field by uuid.deletePriorityTypepriorityTypeUuidlinkDelete a priority type by uuid.deleteCommandTypecommandTypeUuidlinkDelete a command type by uuid.deleteCommandFieldcommandFieldUuidlinkDelete a command field by uuid.deleteEventTypeeventTypeUuidlinkDelete an event type by uuid.deleteEventeventUuidlinkDelete an event by uuid.deleteGroupingTypegroupingTypeUuidlinkDelete a grouping type by uuid.deleteTeamteamUuidlinkDelete a team by uuid.unlinkAccountManagerFromTeamuserUuidlinkUnlink account manager from a team.deleteGroupinggroupingUuidlinkDelete a grouping by uuid.deleteNetworknetworkUuidlinkDelete a network by uuid.deleteNetworkGroupingnetworkUuid,groupingUuidlinkDelete a network's grouping by uuid.removeDeviceFromGroupingnetworkUuid,groupingUuid,deviceUuidlinkremove a device from a groupingdeleteNetworkLocationnetworkUuid,networkLocationUuidlinkDelete a network location by uuid.deleteNetworkSchedulenetworkUuid,scheduleUuidlinkDelete a schedule by uuid.deleteSchedulescheduleUuidlinkDelete a schedule by uuid.deleteGroupingDevicegroupingDeviceUuidlinkDelete a GroupingDevice link by uuid.deleteGroupingLinkgroupingLinkUuidlinkDelete a GroupingLink by uuid.deleteWebhookActionwebhookActionUuidlinkDelete a webhook action type by uuid.deleteQrCodeqrCodeUuidlinkDelete a QR code by uuid.Simple Getting Data Examplefrom iotery_python_server_sdk import Iotery
import json

API_KEY = "MY_TEAM_API_KEY"

DEVICE_UUID = "MY_DEVICE_UUID"
DATA_TYPE_ENUM = "MY_DATA_TYPE_ENUM"

iotery = Iotery(API_KEY)

device_data_list = iotery.getDeviceDataList(
    opts={"dataTypeEnum": DATA_TYPE_ENUM, "limit": 5}, deviceUuid=DEVICE_UUID)

print(json.dumps(device_data_list["results"], indent=2))ContributingWe welcome contributors and PRs! Let us know if you are interested.