@cfygaoyang
2018-09-29T06:31:49.000000Z
字数 11759
阅读 870
该包只支持 python3 , 如果使用 python2.7版本, 请连接至python3版本
pip install feiyan
from feiyan.http.api import Cloud# 密钥配置app_key = '123456'app_secret = '12345678901234567890'# 实例化接口类c = Cloud(app_key, app_secret)# 接口请求参数params = {'grantType': 'project', 'res': 'a1234567890'}# 调用 api 函数res = c.token(params)# 输出回调内容print(res.content)
token(params)
{"grantType": "project","res": "xxxxxx"}
{"code":200,"data":{"isolationId":"a103ZqtDOCpQJFE9","expireIn":7200000,"cloudToken":"d76c34b338184c3a933c39c3ae0ce071"},"id":"1538185690705015"}
refresh_token(token)
{"code":200,"data":{"isolationId":"a103ZqtDOCpQJFE9","expireIn":7200000,"cloudToken":"d76c34b338184c3a933c39c3ae0ce071"},"id":"1538185690705015"}
thing_product_list_get(params, token)
{'productInfoQuery': {"pageNo": 1,"pageSize": 10}}
{"code": 200,"data": [{"accessMethod": "DATA_DIRECT","gmtModified": 1536298985000,"modifier": "501eal0af73dcc8fcce483d2777957b3ed6a4980","productKey": "a1234567890","extendProperties": [{"extendAttrId": 16467,"gmtModify": 1536806017000,"domain": 0,"extendAttrKey": "ACTION","extendAttrValue": "ON","gmtCreate": 1529053672000,"productKey": "a1d9uTa3b7h","extendAttrName": "允许作为ACTION"}],"categoryName": "空气净化器","deviceNumLimit": 500000,"creator": "501eal0af73dcc8fcce483d2777957b3ed6a4980","productId": 213797,"netType": "NET_WIFI","dataFormaINK_FORMAT": "ALINK_FORMAT","aliyunCommodityCode": "ilop","useId2Auth": false,"productSecret": "1234567890","categoryKey": "AirPurifier","nodeType": "DEVICE","gmtCreate": 1527663512000,"domain": "abc123456789","name": "Breathe2","region": "cn-shanghai","rbacTenantId": "BAE4F5145D20416EA228A564AE5F2467","categoryId": 83,"status": "RELEASE_STATUS"}],"id": "1538188889522421"}
thing_product_get(params, token)
{'productKey': '1234567890'}
{"code": 200,"data": {"accessMethod": "DATA_DIRECT","gmtModified": 1536544723000,"modifier": "501eal0af73dcc8fcce483d2777957b3ed6a4980","extendProperties": [{"extendAttrId": 8137,"gmtModify": 1536299101000,"domain": 0,"extendAttrKey": "PUBLIC_VERSION_APP","extendAttrValue": "OFF","gmtCreate": 1527663512000,"productKey": "1234567890","extendAttrName": "加入公版APP标记"}, {"extendAttrId": 8134,"gmtModify": 1527000,"domain": 0,"extendAttrKey": "ILOP_SERVICE_GOOGLEHOME","extendAttrValue": "OFF","gmtCreate": 1527663512000,"productKey": "b1YEAzMF80d","extendAttrName": "开通googleHome服"}],"productKey ": "b1YEAzMF80d ","categoryName ": "空气净化器 ","deviceNumLimit ": 500000,"creator": "501eal0af73dcc8fcce483d2777957b3ed6a4980","productId": 123456,"dataFormat": "ALINK_FORMAT","netType": "NET_WIFI","useId2Auth": false,"aliyunCommodityCode": "ilop","categoryKey": "AirPurifier","productSecret": "1234567890","nodeType": "DEVICE","gmtCreate": 1527663512000,"domain": "b1YEAzMF80d","name": "Breathe2","region": "cn-shanghai","rbacTenantId": "BAE4F5145D20416EA228A564AE5F2467","categoryId": 83,"status": "RELEASE_STATUS"},"id": "1538189551927810"}
thing_properties_get(params, token)
{'iotId': 'c69B4mcRz26v6JGLgOJD0010336900'}
{"code": 200,"data": [{"iotId": "c69B4mcRz26v6JGLgOJD0010336900","gmtModified": 1537871668144,"attribute": "AppointmentTime","batchId": "f979237c50be4605881a4d2702cf6ead","value": 108.0000000000000000}, {"iotId": "c69B4mcRz26v6JGLgOJD0010336900","gmtModified": 1537871666958,"attribute": "CurrentTemperature","batchId": "441b6438f292433badac829f6a463fcd","value": 27.0000000000000000}, {"iotId": "c69B4mcRz26v6JGLgOJD0010336900","gmtModified": 1537871668946,"attribute": "DeviceConfiguration","batchId": "6af55fbd191f43009958d2303e380375","value": {"MotorSpeedPWM_2": 27368,"MotorSpeedPWM_1": 11428,"CalibrationPM25": 0,"AlarmPM25": 30,"AlarmCO2": 1000,"CalibrationCO2": 0,"MotorSpeedPWM_3": 43156}}, {"iotId": "c69B4mcRz26v6JGLgOJD0010336900","gmtModified": 1537871660604,"attribute": "_sys_device_pid","batchId": "9d1b63b9-aace-49dc-8623-85eb41f9ef0d","value": "AliOSThings"}],"id": "1538190327259799"}
thing_tsl_get(params, token)
{'iotId': 'c69B4mcRz26v6JGLgOJD0010336900'}
{"code": 200,"data": {"schema": "https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json","profile": {"productKey": "a1d9uTa3b7h","deviceName": "c69B4mcRz26v6JGLgOJD"},"link": "/sys/a1d9uTa3b7h/c69B4mcRz26v6JGLgOJD/thing/","services": [{"outputData": [],"identifier": "set","inputData": [{"identifier": "WIFI_Band","dataType": {"specs": {"length": "255"},"type": "text"},"name": "频段"},{"identifier": "WIFI_AP_BSSID","dataType": {"specs": {"length": "255"},"type": "text"},"name": "热点BSSID"}],"identifier": "get","inputData": ["LockState","WIFI_Band","WiFI_RSSI","WIFI_AP_BSSID","WIFI_Channel","WiFI_SNR"],"method": "thing.service.property.get","name": "get","required": true,"callType": "async","desc": "属性获取"},{"outputData": [],"identifier": "AddKey","inputData": [{"identifier": "LockType","dataType": {"specs": {"1": "指纹","2": "密码","3": "卡","4": "机械钥匙"},"type": "enum"},"name": "开锁方式"},{"identifier": "UserLimit","dataType": {"specs": {"1": "普通用户","2": "管理员","3": "劫持用户"},"type": "enum"},"name": "用户权限"}],"method": "thing.service.AddKey","name": "添加钥匙","required": true,"callType": "async"}],"properties": [{"identifier": "LockState","dataType": {"specs": {"0": "关闭","1": "打开"},"type": "enum"},"name": "门锁状态","accessMode": "r","required": true}],"events": [{"outputData": [{"identifier": "LockState","dataType": {"specs": {"0": "关闭","1": "打开"},"type": "enum"},"name": "门锁状态"}],"identifier": "post","method": "thing.event.property.post","name": "post","type": "info","required": true,"desc": "属性上报"},{"outputData": [{"identifier": "ErrorCode","dataType": {"specs": {"0": "正常"},"type": "enum"},"name": "故障代码"}],"identifier": "Error","method": "thing.event.Error.post","name": "故障上报","type": "error","required": true},{"outputData": [{"identifier": "KeyID","dataType": {"specs": {"length": "10"},"type": "text"},"name": "钥匙ID"}],"identifier": "KeyAddedNotification","method": "thing.event.KeyAddedNotification.post","name": "添加钥匙通知","type": "info","required": true},{"outputData": [{"identifier": "LockType","dataType": {"specs": {"1": "指纹","2": "密码","3": "卡","4": "机械钥匙"},"type": "enum"},"name": "开锁方式"}],"identifier": "KeyDeletedNotification","method": "thing.event.KeyDeletedNotification.post","name": "删除钥匙通知","type": "info","required": true},{"outputData": [],"identifier": "TamperAlarm","method": "thing.event.TamperAlarm.post","name": "防撬报警","type": "alert","required": true}]},"id": "1538190870103674"}
thing_service_invoke(params, token)
{"iotId": "D95D242941CE821ECCE4F31A2697","identifier": "xxxx","args": {}}
{"code": 200,"data": {},"id": "1538190870103674"}
thing_properties_set(params, token)
{"iotId": "D95D242941CE821ECCE4F31A2697","items": {}}
{"code": 200,"data": {},"id": "1538190870103674"}
thing_status_get(params, token)
{"iotId": "D95D242941CE821ECCE4F31A2697"}
{"code": 200,"data": {"time": 1537871888000,"status": 3},"id": "1538193184384915"}
thing_info_get(params, token)
{"iotId": "D95D242941CE821ECCE4F31A2697"}
{"code": 200,"data": {"gmtModified": 1537871888000,"activeTime": 1537871662000,"deviceKey": "c69B4mcRz26v6JGLgOJD","statusLast": 1,"productKey": "a1d9uTa3b7h","gmtCreate": 1537856353000,"iotId": "c69B4mcRz26v6JGLgOJD0010336900","deviceSecret": "Pcxnrhc1DikSMnZ48FUIH9brb1Rc5sYr","name": "c69B4mcRz26v6JGLgOJD","thingType": "DEVICE","region": "cn-shanghai","firmwareVersion": "app-1.0.0-20180925.1338","rbacTenantId": "BAE4F5145D20416EA228A564AE5F2467","status": 3},"id": "1538193367379207"}
things_info_get(params, token)
{"productKey": "a1d9uTa3b7h","status": 3,'currentPage': 1,'pageSize': 2}
{"code": 200,"data": [{"gmtModified": 1534922756000,"activeTime": 1529651482000,"deviceKey": "rwpefi5N8sIPWBiL5LNc","gmtCreate": 1529546182000,"productKey": "a1d9uTa3b7h","statusLast": 1,"iotId": "rwpefi5N8sIPWBiL5LNc0010e16a00","deviceSecret": "5Cjez2vpxJmAZyaNxLC6PCrK45OckBW6V+jv+KlO4Egl51dLNnK7CMa6j/W9ZKVV","name": "rwpefi5N8sIPWBiL5LNc","thingType": "DEVICE","region": "cn-shanghai","firmwareVersion": "app-1.0.0-20180705.1111","rbacTenantId": "BAE4F5145D20416EA228A564AE5F2467","status": 3}, {"gmtModified": 1537863306000,"activeTime": 1536842173000,"deviceKey": "YJSSBqiCaV8v57ez1yI8","gmtCreate": 1529559542000,"productKey": "a1d9uTa3b7h","statusLast": 1,"iotId": "YJSSBqiCaV8v57ez1yI80010c05e00","deviceSecret": "18dP050cpclibg22/SUmXvF61v/C3zp6eOLymYDrypEl51dLNnK7CMa6j/W9ZKVV","name": "YJSSBqiCaV8v57ez1yI8","thingType": "DEVICE","region": "cn-shanghai","firmwareVersion": "app-1.0.0-20180903.2246","rbacTenantId": "BAE4F5145D20416EA228A564AE5F2467","status": 3}],"id": "1538193644477318"}
thing_event_timeline_get(params, token)
{"iotId": "rwpefi5N8sIPWBiL5LNc0010e16a00","identifier": "xxxx","eventType": "Error","start": 1517217645000,"end": 1587217645000,"pageSize": 10,"ordered": True}
{"code":200,"data":{"items": [{"eventCode": "Error","iotId": "YzqEnI5DY03rxLS2pjjo0010840500","eventName": "故障上报","eventType": "info","eventBody": {"ErrorCode": 0},"batchId": "5ebc6a9c7d15459f823edde6d28c8fb3","timestamp": 1516342985261},{"eventCode": "Error","iotId": "YzqEnI5DY03rxLS2pjjo0010840500","eventName": "故障上报","eventType": "info","eventBody": {"ErrorCode": 0},"batchId": "4a0b5a7ac85e470684438d5ff77456f1","timestamp": 1516342995305}],"timestamp": 1516343075699},"id":"1538194017374719"}
thing_property_timeline_get(params, token)
{"iotId": "D95D242941CE821ECCE4F31A2697","identifier": "xxxx","start": 1517217645000,"end": 1517217645000,"pageSize": 10,"ordered": True}
{"code": 200,"data": {"items": [{"iotid": "xqxyZjSKzCwaGdlvbv0O0010851c00","data": 1.23,"modifytime": 1511812747287,"property": "LightVolt","batchId": "2fc766c5e7064554933ed1f3e4b61803","group": null,"timestamp": 1511812747245},{"iotid": "xqxyZjSKzCwaGdlvbv0O0010851c00","data": 1.24,"modifytime": 1511812747288,"property": "LightVolt","batchId": "2fc766c5e7064554933ed1f3e4b61803","group": null,"timestamp": 1511812747245}],"timestamp": 1511812747245},"id":"1538194017374719"}
account_query_identity_by_page(params, token)
{"offset": 0,"count": 1}
{"code": 200,"data": [{"gmtModified": 1536931534000,"loginId": "36014","nickName": "17681870200","onlineStatus": 0,"gmtCreate": 1531462622000,"lastLoginTime": 1536931534000,"identityId": "50e1op23399ee0c1f32e84f78241f62eed2a6183","loginName": "17681870200","tenantId": "BAE4F5145D20416EA228A564AE5F2467","loginSource": "openAccount","status": "0"}],"id": "1538197847763446"}
account_get_by_openid(params ,token)
{"openId":"10000000001","openIdAppKey":"xxx"}
{"code": 200,"data": {"gmtModified": 1537952076000,"loginId": "56947","nickName": "18150106733","gmtCreate": 1537952076000,"lastLoginTime": 1537952076000,"identityId": "5099opcfba51921fe9d11157b6ad715a0c572941","loginName": "18150106733","tenantId": "BAE4F5145D20416EA228A564AE5F2467","loginSource": "openAccount","status": "0"},"id": "1538198838429908"}
device_query_by_user(params ,token)
{"openId":"10000000001","openIdAppKey":"xxx"}
{"code": 200,"data": {"code": 200,"data": [{"gmtModified": 1537870633000,"categoryImage": "http://iotx-paas-admin.oss-cn-shanghai.aliyuncs.com/publish/image/1526474025826.png","netType": "NET_WIFI","groupId": "","nodeType": "DEVICE","productKey": "b1YEAzMF80d","gmtCreate": 1537870633000,"deviceName": "izLR74cr5WVKt0RDvkZA","identityAlias": "15721595369","productName": "Breathe2","iotId": "izLR74cr5WVKt0RDvkZA0010f40d00","owned": 0,"identityId": "5081opd8f24e72faeb45194bfabeff5355238011","thingType": "DEVICE","status": 1}, {"gmtModified": 1537843991000,"categoryImage": "http://iotx-paas-admin.oss-cn-shanghai.aliyuncs.com/publish/image/1526474025826.png","netType": "NET_WIFI","nickName": "BREATHE2","groupId": "","nodeType": "DEVICE","productKey": "b1YEAzMF80d","gmtCreate": 1537843897000,"deviceName": "OSp1Uuw3kDMBUQDznhWQ","identityAlias": "15721595369","productName": "Breathe2","iotId": "OSp1Uuw3kDMBUQDznhWQ0010a98e00","owned": 1,"identityId": "5081opd8f24e72faeb45194bfabeff5355238011","thingType": "DEVICE","status": 1}],"message": "success"},"id": "1538198926424070"}
user_device_unbind(params, token)
{"openId":"10000000001","openIdAppKey":"xxx","iotId": "zzzzzzzzzzzzzz"}