Package: wiliot-api
PyWiliot: wiliot-apiwiliot-api is a python library for accessing Wiliot's cloud APIs from PythonInstalling pyWiliotpip install wiliot-apiUsing pyWiliotWiliot package location can be found, by typing in the command line:pip show wiliot-apiCode examples for using PyWiliot-apiplatformedgemanufacturingFor more documentation and instructions, please contact us:support@wiliot.comRelease Notes:Version 4.7.1:Added option to upload testers data to cloudAdded option to get a new and unique reel id for manufacturingAdded the option to get post process tables for manufacturing partnersAdded the option to add temperature calibration point to a tagAdded assetSeenInLocation to the list of generateable eventsVersion 4.6.4:Changed get_asset() implementation to use dedicated endpoint instead of metadataFetchVersion 4.6.3:Fixed a bug in functions to get all bridges and gateways that prevented all results from being returned on subsequent calls after the first oneVersion 4.6.2:Added optional parameters to filter returned gateways and bridgesVersion 4.5.0:Added option to change gateway name when updating its configurationAdded functionality to filter the list of returned pixels by sub stringsImplemented function to get pixel countAdded function to batch create assets using a CSV fileAdded a function to get event counts in a time rangeVersion 4.4.4:Added support for updating bridges with ### Version 3.16 and newer (MEL)Version 4.4.3:Added shipment api supportImproved post function to handle different type of payloadVersion 4.4.2:Improved support for alternate clouds and regionsVersion 4.4.0:Forcing a token refresh when an access token is less than a minute from expiryAdded support for alternate clouds and regionsStreamlined API paths to match between the platform and edge modulesVersion 4.3.2:Added an option to get a binary file from the APIAdded a function for sending actions to a gatewayVersion 4.3.1:* Added a function for sending actions to a gatewayVersion 4.3.0:Change code to match the changes in asset label API endpointAll 2xx status code returned by the API are considered a successVersion 4.2.0:Changed API URLs to support new cloud environmentAdded support for pulling paginated bridge and gateway lists (when an owner has more than 100 bridges/gateways)Added a function to update multiple bridges' configuration in one callRemoved GATEWAY as an association type for location - not supported by the platformRequiring at least one pixel to be provided when creating an assetVersion 4.1.2:Changed additional functions use the metadataFetch API to support larger returned data sets:Get LocationsGet zonesGet location associationsGet zone associationsAdded the ability to associate pixels to zonesAdded the ability to associate bridges and gateways to locationsVersion 4.1.0:Changed get_locations and get_categories to use the metadataFetch API endpoint to support:Fetching more than the first 100 itemsTo return the underlying zones for each location when fetching locationsAdded calls to get, create and delete asset labelsChanged get_asset function call to use the metdataFetch endpoint for compatibility with the get_assets callRemoved an unsupported event type (geolocation)Version 4.0.3:Changed logic for get_assets in Platform module to remove limitation of only getting back the first 100 assetsFixed bug in call to add pixel to assetVersion 4.0.2:First ### VersionThe package previous content was published under the name 'wiliot' package.
for more information please read 'wiliot' package's release notesExamplesPlatform API# Import the libraryfromwiliot_api.platform.platformimport*importos# Define an owner IDowner_id="test_owner1"# ToDo: add here your owner ID# Initialise an Wiliot client objectplatform=PlatformClient(api_key=os.environ.get("WILIOT_PLATFORM_API_KEY"),owner_id=owner_id)# Get the first 50 pixels owned by the accountprint(platform.get_pixels())# Get a list of all pixels (not recommended on accounts with many pixels)pixels=[]next_p=NonewhileTrue:p,next_p=platform.get_pixels(next=next_p)pixels+=pifnext_pisNone:break# Get a list of categoriesplatform.get_categories()# Get a list of asset typeplatform.get_asset_types()# Create a categoryplatform.create_category(name="Black_box",asset_type_id='Default',category_id="black-box-sku",description="A generic black box")# Get a list of assetsplatform.get_assets()# Create an assetplatform.create_asset(name="Black-box-118763",category_id="black-box-sku",tags=[{"tagId":"pixel-1-id","role":TagRole.DEFAULT},{"tagId":"pixel-2-id","role":TagRole.DEFAULT}])# Associate a pixel to an assetplatform.associate_pixel_to_asset("my-asset-id",pixel_id="pixel-id")# Disassociate a pixel from an assetplatform.disassociate_pixel_from_asset(asset_id="my-asset-id",pixel_id="pixel-id")# Delete an assetplatform.delete_asset(asset_id="my-asset-id")# Locations and zones# Get a list of locationsplatform.get_locations()# Get a list of zones in a locationplatform.get_zones(location_id="my-location-id")# Associate a bridge to a zoneplatform.create_zone_association(location_id="my-location-id",zone_id="my-zone-id",association_type=ZoneAssociationType.BRIDGE,association_value="my-bridge-id")Edge API# Import the libraryfromwiliot_api.edge.edgeimport*importos# Define an owner IDowner_id="test_owner"# ToDo: add here your owner ID# Initialise an Wiliot edge client objectedge=EdgeClient(api_key=os.environ.get('WILIOT_EDGE_API_KEY'),owner_id=owner_id)# Get a list of gateways owned by the owneredge.get_gateways()# Get details on a single gateway by its IDedge.get_gateway(gateway_id="my-gateway-id")# Update a gateway's configuration# First get its current configurationconfig=edge.get_gateway("my-gateway-id")["reportedConf"]# Make the required change - for example, change the pacer intervalconfig["additional"]["pacerInterval"]=15# Update the gateway's configurationedge.update_gateways_configuration(gateways=["my-gateway-id"],config=config)# Register a new gatewayedge.register_gateway(gateways=["my-new-gateway-id"])# Delete a gateway from the account (to move to another account, for example)edge.delete_gateway(gateway_id="my-gateway-id")# Bridges# Get a list of all bridges registered under the account with their configurationedge.get_bridges()# Get a list of all online bridgesedge.get_bridges(online=True)# Get a list of bridges connected to a certain gatewayedge.get_bridges(gateway_id="my-gateway-id")# Update a bridge configuration# First, get its current configurationconfig=edge.get_bridge(bridge_id="my-bridge-id")["config"]# Request the configuration change - single bridgeedge.update_bridge_configuration(bridge_id="my-bridge-id",config={'energyPattern':63})# Request the configuration change - multiple bridgeedge.update_bridges_configuration(bridge_ids=["bridge1-id","bridge2-id"],config={'energyPattern':63})# Change a bridge's nameedge.update_bridge_configuration(bridge_id="my-bridge-id",name="my_bridge_name")# Get bridges connected to gatewayedge.get_bridges_connected_to_gateway("gateway-id")Manufacturing API(for Wiliot's manufacturing clients)# Import the libraryfromwiliot_api.manufacturing.manufacturingimport*importos# Initialise an Wiliot client objectwiliot_manufacturing=ManufacturingClient(os.environ.get('WILIOT_MANUFACTURING_API_KEY'))# Change the owner for a sequence of pixel IDs - useful for changing consecutive IDs - like part of a reelreq=wiliot_manufacturing.change_pixel_owner_by_range("first_pixel_id","last_pixel_id","from_owner_id","to_owner_id")# Change the owner for a list of pixel IDs - When non-consecutive IDs need changing - up to 3000 pixelsreq=wiliot_manufacturing.change_pixel_owner_by_list(["tag_1","tag_2","tag_3"],"from_owner_id","to_owner_id")# Change the owner of pixels by file - when needing to change more than 3000, non-consecutive IDs## The file should be formatted as follows:# tagId# tag_1_id# tag_2_id# .....req=wiliot_manufacturing.change_pixel_owner_by_file("from_owner_id","to_owner_id","/path/to/file")# Each of the functions above returns a string representing a request ID. To check on the status of the requestprint(wiliot_manufacturing.get_pixel_change_request_status(req))