Appendix 1: The definition of all json objects

Inquiry MASK Name Type Remark
1 devicestatus int Aifro WaterEco's overall status 0: Watering 1: No running task 2: Raining 3: Delaying after raining 4: Pausing at low temperature
rainwaittime int Remaining time to resume watering after raining (Unit: second)
runtaskindex int Ongoing task index 1—8: The program task is running. 0: The normal task is running.
runtasklist int array Zone list of ongoing watering tasks, for example: [1, 5, 8, 11]
2 devicetimezone int Device time zone (-12 ~ 12)
devicetime int Device time (UTC)
4 connectedvalves int The maximum zone number (The number of zones which have been connected)
valvesstatus json array Zone status
The definition of valvesstatus
enabled int Enable/Disable the zone (0: disabled, 1: enabled).
valvesswitch int Dummy (not used).
valvesname string Zone name (The maximum length is 32 bytes).
valvesicon int Zone icon index (Default icon index 0-17).
valvesiconfile string The file name of zone icons: GUID.xxx (JPG or PNG). The maximum length is 36 bytes.
watertime int Duration of each watering (Unit: second)
wateredtime int Duration of watering this time (Unit: second)
totalwateredtime int Total watering time today
aiadjusttime int Duration of AI smart adjustment (Unit: second)
aiwater int Enable/Disable AI smart adjustment (0: disabled, 1: enabled).
status int Zone status 0: not watered today 1: watering 2: watered today 3: Delaying.
lastwaterdate int Last watering date (UTC)
delaytime int Remaining time to delay between zones (Unit: second)
planttype int Plant type index (0: lawn, 1: flower, 2: shrub, 3: tree, 4: vegetable, 5: other)
soiltype int Soil type index (0: loam, 1: clay, 2: silty, 3 : sandy, 4: other)
cycleandsoak int Enable/Disable cycle and soak (0: disabled, 1: enabled).
 
8 temperature int Current temperature value (1,000 times of the Celsius value)
adjusttemperature int Dummy (not used).
16 temperaturemode int Temperature unit (0: degree Celsius, 1: degree Fahrenheit).
32 sleeptemperature int Sleep value(Aifro WaterEco will stop watering when the temperature is lower than this value. 1,000 times of the Celsius value)
64 enabletimermode int Enable/Disable the program (0: disabled, 1: enabled)
didialarm int Dummy (not used).
timernum int The number of program tasks
timerdata json array Program tasks (up to 8) 7 bytes for starting time, 1 byte for enabling/disabling the program, 2 bytes for zone number, 1 byte for duration of watering. Duration of watering: 1 to 255 minutes. The default time is 5 minutes.
The definition of timerdata. There are two definitions to show time. The first definition (When time exists and is not equal to 0)
time int The starting time (UTC)
interval int Interval between tasks (Unit: day)
The second definition
week int week
hour int hour
minute int minute
For example: (week, hour, minute) Data: 01 0A 05 Monday 10:05:00 Data: 02 0A 05 Tuesday 10:05:00 Data: 04 0A 05 Wednesday 10:05:00 Data: 08 0A 05 Thursday 10:05:00 Data: 10 0A 05 Friday 10:05:00 Data: 20 0A 05 Saturday 10:05:00 Data: 40 0A 05 Sunday 10:05:00 Data: 41 0A 05 Monday and Sunday 10:05:00
enabled int Enable/Disable (0: disabled, 1: enabled)
delay int Delay between zones (Unit: minute)
status int The task status (0: not running, 1: running)
lasttime int Remaining time to finish the task (Unit: second)
tasklist json array The number of zones in the program
name string The program's name (The maximum length is 32 bytes).
addedflag int Whether the program task has been configured (0: not configured, 1: configured).

 

IC_setup json

Setup MASK Name Type Remark
2 devicetimezone int Device time zone (-12 ~ 12)
devicetime int Device time (UTC)
4 connectedvalves int Maximum zone number (The default value is 52.)
8 adjusttemperature int Dummy (not used).
16 temperaturemode int Temperature unit (0: degree Celsius, 1: degree Fahrenheit)
32 sleeptemperature int Sleep value (Aifro WaterEco will stop watering when the temperature is lower than this value. Value represented by 1000 times in degree Celsius)
64 enabletimermode int Enable/Disable the program (0: disabled, 1: enabled).
didialarm int Dummy (not used).
timernum int The number of program tasks
timerdata json array Timed programs (up to 8)
128 Weather int Weather code (0-47 codes, -1: Unknown, -2: Can not obtain the weather forecast of the city, -3: Can not connect to the weather forecast server. Please check your network settings.)
weathertemperature int Temperature (degree Celsius)
weatherwindpower int Wind grading
weatherhumidity int Humidity (percentage)
aiadjustwater int AI smart adjustment value (percentage)
256 soundalarm int Enable/Disable sound prompt (0: OFF, 1: ON)
512 autoadjusttime int Whether to automatically adjust the device time by server (0: OFF, 1: ON)
1024 devicename string Device name (The maximum length is 32 bytes.)
devicepasswd string Device password (The maximum length is 32 bytes.)
2048 serverhostname string Dummy (not used)
serverport int Dummy (not used)
8192 rainpause int Whether to stop watering when raining (1: stop, 0: don't stop)
16384 rainpausetime int Duration of suspending after raining (Unit: hour)
32768 delaytime int Duration of delaying watering (Unit: second, -1: pausing)
65536 Country string Country (The maximum length is 50 bytes.)
City string City (The maximum length is 50 bytes.)
Zipcode int Dummy (not used).
131072 maxadjustvalue int Maximum value of AI smart adjustment Adjustment value of each zone = maxadjustvalue * aiadjustwater * watertime
524288 backlightstatus int Enable/Disable the backlight (0: OFF, 1: ON)
1048576 zerousedwater int Perform zero command (0: No, 1: Yes).
gallonperminute int How much water used per minute (Value represented by 100 times, Unit: gallon)
pricepergallon int How many dollars per gallon of water (Value represented by 100 times, Unit: dollar)
2097152 enablecloudmode int Enable/Disable Aifro Cloud (0: OFF, 1: ON)
4194304 everywatersecond int Duration of each watering (Unit: second)
needstopsecond int Suspend watering for several seconds to ensure the soil is thoroughly soaked. (Unit: second, 0: don't stop, 60: one minute)
8388608 restrictiontime json Disable any zone to be watered every day (0000: no restrictions)
The definition of restrictiontime
starthour int From hour
startminute int From minute
endhour int To hour
endminute int To minute

 

The definition of device list

Name Type Remark
ip string The server address the device is currently logged in to. To control the device, you must access this server address.
title string Device name. The maximum length is 32 bytes.
deviceid string Device ID. The maximum length is 32 bytes.
type int Device type. The value must be 2.
descript string Device's description information. The maximum length is 50 bytes.
registerdate int Date when the device is logged in to Aifro Cloud for the first time (UTC).
onlinestatus int Whether the device is online (0: Offline, 1: Online).
temperature int Device temperature (Value represented by 1000 times in degree Celsius)
adjusttemperature int Dummy (not used).
icon int The icon index of the device (The default icon index is 0 ~ 17).
iconurl string The name of the uploaded custom icon
authority int Dummy (not used)
enableprogram int The status of the program task (0: disabled, 1: enabled)
protocolversion int The protocol version of the device
invalidpassword int The device password has been modified. You should login again with the new password. (0: not modified, 1: modified).

 

The codes of weather forecast.

Code Description
0 tornado
1 tropical storm
2 hurricane
3 severe thunderstorms
4 thunderstorms
5 mixed rain and snow
6 mixed rain and sleet
7 mixed snow and sleet
8 freezing drizzle
9 drizzle
10 freezing rain
11 showers
12 showers
13 snow flurries
14 light snow showers
15 blowing snow
16 snow
17 hail
18 sleet
19 dust
20 foggy
21 haze
22 smoky
23 blustery
24 windy
25 cold
26 cloudy
27 mostly cloudy (night)
28 mostly cloudy (day)
29 partly cloudy (night)
30 partly cloudy (day)
31 clear (night)
32 sunny
33 fair (night)
34 fair (day)
35 mixed rain and hail
36 hot
37 isolated thunderstorms
38 scattered thunderstorms
39 scattered thunderstorms
40 scattered showers
41 heavy snow
42 scattered snow showers
43 heavy snow
44 partly cloudy
45 thundershowers
46 snow showers
47 isolated thundershowers
3200 not available

Appendix 2: The definition of error code from Aifro Cloud

Example: The response contents from Aifro Cloud when occurred a error
{
"code": 101,
"error": "user name or password error"
}

 

code Http response code Error string
0 200,201 success
101 403 Can not find your username or the password is incorrect
102 403 user has been regirsted already
103 401 sorry, invalid access_token
104 403 the device type is not supported
105 403 the device has been regirsted already
106 403 sorry, can't find the deviceid
107 404 sorry, invalid inquiry flag
108 403 sorry, invalid operation code
109 403 sorry, invalid setup information
110 400 sorry, invalid parameters
111 404 sorry, invalid request url
112 400 sorry, invalid json data struct
113 401 sorry, token expired ,need login again
114 401 sorry, can't find the login name or token error
115 403 sorry, invalid phone number
116 403 sorry, invalid email address
117 403 sorry, the device number reach limit (50)
118 403 user name or password empty
119 403 the device is not online
120 403 the action expired, please check device is online
121 403 error encountered while upgrading the device
122 403 sorry, invalid password, the character numbers must between 6 to 32
123 403 invalid user name, invalid character or the beginning character is not letter
124 403 sorry, the email has been registered
125 403 sorry, the email has not been registered
126 401 sorry, invalid reset token
127 403 user name or email error
128 403 sorry, the group number reach limit (50)
129 403 sorry, the group has been registered
130 403 sorry, can't find the group, create it first.
131 403 sorry, invalid device root password
132 403 sorry, invalid fireware id
133 403 sorry, occur error when upgrading fireware.
134 403 sorry, need input captcha.
135 403 sorry, can't find or build the captcha in server
136 401 sorry, register or delete user need root account authority
137 403 sorry, can't delete the user created by others
138 403 sorry, can't find the user in database
139 403 sorry, can't delete user with root authority
140 403 sorry, the device has been registered by others
141 403 sorry, can't delete device registered by others
142 403 sorry, can't control device registered by others
143 403 sorry, another task is running.
144 403 sorry, there are collisions in program settings
145 403 sorry, can't stop running task
146 403 sorry, fail to restore device configs
147 403 sorry, there is no config information on server
148 403 sorry, the deviceid is not valid
149 403 sorry, the timezoneid is not exist
150 500 sorry, the operation has expired
151 403 sorry, the device's password has expired
152 403 sorry, fail to get informations by ip address

 

Http response codes:

200 OK
201 CREATED
400 BAD REQUEST
401 UNAUTHORIZED
404 NOT FOUND
403 FORBIDDEN

Aifro Server API

(The APIs of captcha)

API NO.: 00501 Get a captcha 1

API NO.: 00502 Verify the captcha 2

NOTE: The host name of the APIs listed below is http(s)://srv1.aifro.com

API .: 00501

Description: Get a captcha from Aifro Cloud

Method: GET

URL: /v1/captcha

Input:

Name Type Remark
tokenid string The maximum length is 32 bytes. Different IDs are needed in different situations. The user name is used for tokenid when API NO. 00002 is called. The user name is used for tokenid when API NO. 00003 is called. The device ID is used for tokenid when API NO. 00101 is called.
type int The value type: The value must be 1 when API NO. 00002 is called. The value must be 2 when API NO. 00003 is called. The value must be 3 when API NO. 00101 is called.
refresh int Whether to refresh captcha (1: refresh, 0: don't refresh)

Response: success=201

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

pngdata

string

The Base64 data of captcha (Format: PNG, 120x60px)

Example:

Send
/v1/captcha?tokenid= 11010F60BA50CF0D &type=3&refresh=0
Receive

{
"code" : 0,
"pngdata" : "dsifierjoiwfrjiwjfekjfkwfjk"
}

API NO.: 00502
Description: Verify the captcha
Method: POST
URL: /v1/captcha
Input:

Name

Type

Remark

tokenid

string

The maximum length is 32 bytes. Different IDs are needed in different situations.

The user name is used for tokenid when API NO. 00002 is called.

The user name is used for tokenid when API NO. 00003 is called.

The device ID is used for tokenid when API NO. 00101 is called.

type

int

The value type:

The value must be 1 when API NO. 00002 is called.

The value must be 2 when API NO. 00003 is called.

The value must be 3 when API NO. 00101 is called.

word

string

The captcha string needs to be verified.

Response: success=201

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

result

int

0: Correct answer 1: Wrong answer

Example:

Send
{
"tokenid" : " 11010F60BA50CF0D ",
"type" : 3,
"word" : "1234"
}
Receive
{
"code" : 0,
"result" : 0
}

Aifro Server API

(The APIs of Device Control)

API NO.: 00201 Obtaining the device's current status 1

API NO.: 00202 Start watering 2

API NO.: 00203 Stop watering 3

API NO.: 00204 Device settings 3

API NO.: 00205 Zone settings 4

NOTE: The host name of the APIs listed below is http(s)://< the host name that the device is logged in to> (the sub server host name obtained from API NO. 00103)

 

API NO.: 00201

Description: Obtaining the device's current status

Method: GET

URL: /v1/device/<deviceid>/status?flag=<flag>

Input:

Name Type Remark
access_token string Access token in http headers (Authorization: access_token, and the length is 32 bytes)
flag int Inquiry MASK

 

The definition of inquiry MASK:

0xFFFFFFFF: All MASK (Obtaining all statuses)

01: Obtaining the device's overall status

02: Obtaining the device time

04: Obtaining the zone status of the device

08: Obtaining the device temperature

16: Obtaining the temperature unit of the device

32: Obtaining the sleep temperature value of the device

64: Obtaining the program settings

128: Obtaining the weather forecast and AI smart adjustment value

256: Obtaining whether to enable sound prompt

512: Obtaining whether to adjust time automatically by server

1024: Obtaining the device name and password

2048: Dummy (not used)

4096: Obtaining whether the local user is connected to the device

8192: Obtaining whether to stop watering when raining

16384: Obtaining the duration of suspending after raining

32768: Obtaining the duration of delaying

65536: Obtaining the location setting of the device

131072: Obtaining the maximum value of AI smart adjustment

262144: Obtaining the firmware version and protocol version of the device

524288: Obtaining the status of the device's backlight

1048576: Obtaining the total duration of watering of the device

2097152: Obtaining whether to enable Aifro Cloud

4194304: Obtaining whether to enable cycle and soak

8388608: Obtaining the information about restricted time period

 

Response: success: 200

Name Type Remark
code int Success: 0, Error: 1~152. Refer to Appendix 2.
status json object Device's current status, which is a variable json object. To learn about the definition of a json object, please refer to Appendix 1.

 

Example:

 

Authorization: aksfj28342k34nj2jd834554567789

Send

{

}

Receive

{

"code" : 0

}

 

API NO.: 00202

Description: Start watering

Method: POST

URL: /v1/device/<deviceid>

Input:

Name Type Remark
access_token string Access token in http headers (Authorization: access_token, and the length is 32 bytes)
delaytime int Delaying time (Unit: second). After the delay, it will start watering. If the value is 0, it will start watering at once.
tasklist int json Zone list to be watered.

 

Response: success: 200

Name Type Remark
code int Success: 0, Error: 1~152. Refer to Appendix 2.

 

Example:

Authorization: aksfj28342k34nj2jd834554567789

Send

{

"delaytime" : 200,

"tasklist" :

[

1,

13,

23,

49

]

}

Receive

{

"code" : 0

}

API NO.: 00203

Description: Stop watering

Method: DELETE

URL: /v1/device/<deviceid>/stoptask

Input:

Name Type Remark
access_token string Access token in http headers (Authorization: access_token , and the length is 32 bytes)

 

Response: success: 200

Name Type Remark
code int Success: 0, Error: 1~152. Refer to Appendix 2.

 

Example:

 

Authorization: aksfj28342k34nj2jd834554567789

Send

{

}

Receive

{

"code": 0,

"status": {

"deviceid": "11010F90A3198701",

"onlinestatus": 1,

"devicestatus": 1,

"rainwaittime": 0,

"runtasklist": [],

"runtaskindex": 0,

"devicetimezone": 8,

"devicetime": 1442558738,

"connectedvalves": 1,

"valvesstatus": [

{

"enabled": 1,

"valvesswitch": 0,

"valvesname": "",

"valvesicon": 1,

"valvesiconfile": "",

"watertime": 300,

"wateredtime": 0,

"totalwateredtime": 310,

"aiadjusttime": -78,

"aiwater": 1,

"status": 2,

"delaytime": 0,

"planttype": 0,

"soiltype": 0,

"cycleandsoak": 0,

"lastwaterdate": 1442541910

}

],

"temperature": 0,

"adjusttemperature": 0,

"temperaturemode": 1,

"sleeptemperature": -100,

"enabletimermode": 1,

"didialarm": 0,

"timernum": 1,

"timerdata": [

{

"week": 0,

"hour": 10,

"minute": 0,

"interval": 0,

"enabled": 1,

"delay": 0,

"status": 0,

"lasttime": 0,

"tasklist": [

1,

2,

3,

4,

5,

6,

7,

8,

9,

10,

11,

12,

13,

14,

15,

16

],

"name": "Program1"

},

{

"week": 0,

"hour": 0,

"minute": 0,

"interval": 0,

"enabled": 0,

"delay": 0,

"status": 0,

"lasttime": 0,

"tasklist": [],

"name": ""

},

],

"weather": 28,

"weathertemperature": 26,

"weatherwindpower": 11,

"weatherhumidity": 47,

"aiadjustwater": -52,

"soundalarm": 1,

"autoadjusttime": 0,

"devicename": "Aifro-WE-701",

"devicepasswd": "",

"serverhostname": "srv.aifro.com",

"serverport": 9600,

"authority": 0,

"authorityname": "",

"rainpause": 1,

"rainpausetime": 0,

"delaytime": 0,

"country": "China",

"city": "Shenyang",

"zipcode": 0,

"maxadjustvalue": 50,

"firewareversion": 100,

"protocolversion": 143,

"backlightstatus": 0,

"usedwater": 31,

"usedwaterzerodate": 0,

"gallonperminute": 12000,

"pricepergallon": 5,

"enablecloudmode": 1,

"everywatersecond": 0,

"needstopsecond": 0,

"restrictiontime": {

"starthour": 0,

"startminute": 0,

"endhour": 0,

"endminute": 0

}

}

 

}

 

 

API NO.: 00204

Description:Device settings

Method: PUT

URL: /v1/device/<deviceid>/setup

Input:

Name Type Remark
access_token string Access token in http headers (Authorization: access_token , and the length is 32 bytes)
setup json object Detailed information about device settings. To learn about the definition of a json object, please refer to Appendix 1.

 

Response: success: 200

Name Type Remark
code int Success: 0, Error: 1~152. Refer to Appendix 2.
status json object Device's current status, which is a variable json object. To learn about the definition of a json object, please refer to Appendix 1.

 

Example:

 

Authorization: aksfj28342k34nj2jd834554567789

Send

{

"setup": {

"connectedvalves": 1,

"adjusttemperature": 0,

"sleeptemperature": -100,

"soundalarm": 1,

"devicetimezone": 8,

"devicetime": 1442559023,

"autoadjusttime": 0,

"devicename": "Aifro-WE-701",

"devicepasswd": "",

"rainpause": 1,

"rainpausetime": 0,

"country": "China",

"city": "Shenyang",

"zipcode": 0,

"maxadjustvalue": 50,

"everywatersecond": 0,

"needstopsecond": 0,

"restrictiontime": {

"starthour": 0,

"startminute": 0,

"endhour": 0,

"endminute": 0

}

}

}

 

Receive

{

"code": 0,

"status": {

"deviceid": "11010F90A3198701",

"onlinestatus": 1,

"devicetimezone": 8,

"devicetime": 1442559023,

"connectedvalves": 1,

"valvesstatus": [

{

"enabled": 1,

"valvesswitch": 0,

"valvesname": "",

"valvesicon": 1,

"valvesiconfile": "",

"watertime": 300,

"wateredtime": 0,

"totalwateredtime": 310,

"aiadjusttime": -78,

"aiwater": 1,

"status": 2,

"delaytime": 0,

"planttype": 0,

"soiltype": 0,

"cycleandsoak": 0,

"lastwaterdate": 1442541910

}

],

"temperature": 0,

"adjusttemperature": 0,

"sleeptemperature": -100,

"soundalarm": 1,

"autoadjusttime": 0,

"devicename": "Aifro-WE-701",

"devicepasswd": "",

"rainpause": 1,

"rainpausetime": 0,

"country": "China",

"city": "Shenyang",

"zipcode": 0,

"maxadjustvalue": 50,

"everywatersecond": 0,

"needstopsecond": 0,

"restrictiontime": {

"starthour": 0,

"startminute": 0,

"endhour": 0,

"endminute": 0

}

}

}

 

API NO.: 00205

Description: Zone settings

Method: POST

URL: /v1/device/<deviceid>/valvessetup

Input:

Name Type Remark
access_token string Access token in http headers (Authorization: access_token, and the length is 32 bytes)
valvesindex int The index of zone No. (1 ~ 52)
enabled int Whether to enable the zone (0: disabled, 1: enabled)
valvesname string The name of the zone (The maximum length is 32 bytes).
valvesicon int The index of the zone icon (0 ~ 16)
watertime int Duration of each watering (Unit: sccond)
aiwater int Whether to enable AI smart adjustment (0: disabled, 1: enabled)
planttype int The index of the plant type (0: lawn, 1: flower, 2: shrub, 3: tree, 4: vegetable, 5: other)
soiltype int The index of the soil type (0: loam, 1: clay, 2: silty 3: sandy, 4: other)
cycleandsoak int Whether to enable cycle and soak (0: disabled, 1: enabled)

 

Response: success: 200

Name Type Remark
code int Success: 0, Error: 1~152. Refer to Appendix 2.

 

Example:

 

Authorization: aksfj28342k34nj2jd834554567789

Send

{

"valvesindex" : 2,

"enabled" : 1,

"valvesname" : "myname",

"valvesicon" : 1,

"watertime" : 5,

"aiwater" : 1,

"planttype " : 1,

"soiltype " : 1,

"cycleandsoak " : 1

}

Receive

{

"code" : 0

}

Aifro Server API

(The APIs of Device Management)

API NO.: 00101 Add a new device 1

API NO.: 00102 Delete the device 2

API NO.: 00103 Enumerate all devices 2

API NO.: 00104 Edit the device 2

API NO.: 00105 Check the device password 4

 

NOTE: The host name of the APIs listed below is http(s)://srv1.aifro.com

API NO.: 00101

Description: Add a new device to Aifro Cloud (Checking captcha is needed if you have input invalid password for three times continuously within three minutes .Please refer to the captcha document)

Method: POST

URL: /v1/devices

Input:

Name

Type

Remark

access_token

 

string

Access token in http headers (Authorization: access_token, and the length is 32 bytes).

deviceid

string

Device ID. The length is 16 bytes.

password

string

Device password (The maximum length is 32 bytes).

type

int

Device type, and the value must be 1.

descript

string

Device description (The maximum length is 50 bytes.)

icon

int

The index of the device's default icon (0~17) (optional)

 

Response: success=201

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

 

Example:

Send

Authorization: aksfj28342k34nj2jd834554567789

{

"deviceid" : "11010F60BA50CF0D",

"password" : "12345678",

"type" : 1,

"descript" : "what is your device's descriptions"

"icon" : 0

}

Receive

{

"code" : 0

}

 

 

API NO.: 00102

Description: Delete the device

Method: DELETE

URL: /v1/device/<device_id>

Input:

Name

Type

Remark

access_token

 

string

Access token in http headers (Authorization: access_token, and the length is 32 bytes).

 

Response: success: 200

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

 

Example:

Send

Authorization: aksfj28342k34nj2jd834554567789

Receive

{

"code" : 0

}

 

API NO.: 00103

Description: Enumerate all devices

Method: GET

URL: /v1/devices

Input:

Name

Type

Remark

access_token

 

string

Access token in http headers (Authorization: access_token, and the length is 32 bytes).

 

Response: success: 200

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

devicenum

int

The number of devices

devicelist

json object array

The detailed information about the device. This json object contains a json array, which represents the device list. To learn about the definition, please refer to Appendix 1.

 

 

Example:

Send

Authorization: aksfj28342k34nj2jd834554567789

Receive

{

"code" : 0,

"devicenum" : 1,

"devicelist" :

[

{

"ip" : "srv3.aifro.com",

"title" : "MyFirstDevice",

"deviceid" : " 11010F60BA50CF0D ",

"type" : 1,

"descript" : "the description of the device",

"registerdate": 1442288484,

"onlinestatus" : 1,

"icon" : 0,

"iconurl":"";

"authority" : 0,

"temperature" : 2500,

"adjusttemperature" : 0,

"temperaturemode" : 0,

"enableprogram" : 1,

"protocolversion" : 140

}

]

}

 

API NO.: 00104

Description: Edit the device

Method: PUT

URL: /v1/device/<deviceid>

Input:

Name

Type

Remark

access_token

 

string

Access token in http headers (Authorization: access_token, and the length is 32 bytes.)

descript

string

Device description (The maximum length is 50 bytes.)

icon

int

The index of the device's default icon (0~17) (optional)

 

Response: success: 200

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

 

Example:

Send

Authorization: aksfj28342k34nj2jd834554567789

{

"descript" : " the description of the device "

"icon" : 0,

}

Receive

{

"code" : 0

}

API NO.: 00105

Description: Check the device password (If the device password has been modified on the device, you must call this API to get the authority to control it again. Checking captcha is needed if you have input invalid password for three times continuously within three minutes. Please refer to the captcha document.)

Method: POST

URL: /v1/device/check

Input:

Name

Type

Remark

deviceid

string

Device ID (Device SN, and the length is 16 bytes.)

password

string

Device password (The maximum length is 32 bytes.)

 

Response: success: 201

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

 

Example:

Send

Authorization: aksfj28342k34nj2jd834554567789

{

"deviceid" : " 11010F60BA50CF0D ",

"password" : "12345678"

}

Receive

{

"code" : 0

}

Aifro Server API

(The APIs of User Control)

API NO.: 00001 Register a new user 1

API NO.: 00002 Login to the account 2

API NO.: 00003 Modify the password 2

API NO.: 00004 Edit the user information 3

API NO.: 00005 Get the user information 4

API NO.: 00006Logout 5

NOTE: The host name of the APIs listed below is http(s)://srv1.aifro.com

 

API NO.: 00001

Description: Register a new user

Method: POST

URL: /v1/rootusers

Input:

Name

Type

Remark

name

string

The maximum length is 32 bytes, case insensitive.

passwd

string

The maximum length is 32 bytes, case sensitive. It must be mixed with capital, lower case and digits.

accountname

string

The maximum length is 32 bytes (optional).

email

string

The maximum length is 320 bytes (required).

phone

string

The maximum length is 20 bytes (optional).

country

string

The maximum length is 50 bytes (optional).

 

Response: success: 201

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

name

string

The maximum length is 32 bytes, case insensitive.

registerdate

int

Registration time (UTC)

 

Example:

Send

{

"name" : "nihaoaaa1a",

"passwd" : "Coocococococo3!@34",

"accountname" : "huyoucai",

"email" : "whatyouname@gmail.com",

"phone" : "13908882333",

"country" : "china"

}

Receive

{

"code" : 0,

"name" : "conan123456",

"registerdate": 1442288484

}

 

API NO.: 00002

Description: Login to the account (Checking captcha is needed if you have input invalid password for three times continuously within three minutes. Please refer to the captcha document.)

Method: POST

URL: /v1/user/login

Input:

Name

Type

Remark

name

string

The maximum length is 32 bytes, case insensitive.

passwd

string

The maximum length is 32 bytes, case sensitive. It must be mixed with capital, lower case and digits.

 

Response: success: 200

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

access_token

string

The access token expires in three days (The length is 32 bytes). After that, you need to login again to obtain the access token.

type

int

The type value must be 0.

 

Example:

Send

{

"name" : "conan123456",

"passwd" : "Aa234598289432348235524334"

}

Receive

{

"code" : 0,

"access_token" : "aksfj28342k34nj2jd834554567789",

"type" : 0

}

 

 

API NO.: 00003

Description: Modify the password (Checking captcha is needed if you have input invalid password for three times continuously within three minutes. Please refer to the captcha document.)

Method: PUT

URL: /v1/user/passwd

Input:

Name

Type

Remark

name

string

The maximum length is 32 bytes, case insensitive.

passwd

string

The old password (The maximum length is 32 bytes, case sensitive.)

passwdnew

string

The new password (The maximum length is 32 bytes, case sensitive.)

 

Response: success: 200

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

 

Example:

Send

{

"name" : "conan123456",

"passwd" : "Aa234598289432348235524334",

"passwdnew" : "Aa34aa8289432348235524335"

}

Receive

{

"code" : 0

}

 

 

API NO.: 00004

Description: Edit the user information

Method: PUT

URL: /v1/user/<user_name>

Input:

Name

Type

Remark

access_token

 

string

Access token in http headers (Authorization: access_token, and the length is 32 bytes).

accountname

string

The maximum length is 32 bytes (optional).

email

string

The maximum length is 320 byte (required).

phone

string

The maximum length is 20 bytes (optional).

country

string

The maximum length is 50 bytes (optional).

 

Response: success: 200

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

 

Example:

Send

Authorization: aksfj28342k34nj2jd834554567789

{

"accountname" : "huyoucai",

"email" : "whatyouname@gmail.com",

"phone" : "13908882333",

"country" : "china"

}

Receive

{

"code" : 0

}

 

 

API NO.: 00005

Description: Get the user information

Method: GET

URL: /v1/user/<user_name>

Input:

Name

Type

Remark

access_token

 

string

Access token in http headers (Authorization: access_token, and the length is 32 bytes).

 

Response: success: 200

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

name

string

The maximum length is 32 bytes, case insensitive.

accountname

string

The maximum length is 32 bytes (optional).

email

string

The maximum length is 320 bytes.

phone

string

The maximum length is 20 bytes (optional).

country

string

The maximum length is 50 bytes (optional).

type

int

The type value must be 0.

registerdate

int

Registration time (UTC)

lastlogindate

int

Login date last time (UTC)

lastloginip

string

The IP address logged in last time (The maximum length is 20 bytes).

 

Example:

Send

Authorization: aksfj28342k34nj2jd834554567789

Receive

{

"code" : 0,

"name" : "conan123456",

"accountname" : "huyoucai",

"email" : "whatyouname@gmail.com",

"phone" : "13908882333",

"type" : 0,

"country" : "china",

"registerdate" : 1442288484,

"lastlogindate" : 1442288484,

"lastloginip" : "127.0.0.1"

}

 

 

API NO.: 00006

Description: Logout

Method: DELETE

URL: /v1/user/<user_name>

Input:

Name

Type

Remark

access_token

string

Access token in http headers (Authorization: access_token, and the length is 32 bytes).

 

Response: success: 200

Name

Type

Remark

code

int

Success: 0, Error: 1~152. Refer to Appendix 2.

 

Example:

Send

Authorization: aksfj28342k34nj2jd834554567789

Receive

{

"code" : 0

}