English
English
简体中文
Contact Us
Register
Log In
layoutIndex

Project Management

Last Updated on : 2021-09-18 08:21:53download

This topic describes how to create a commercial lighting project. This is the first step to connect to Tuya commercial lighting SaaS. This allows you to manage the required scenes based on projects.

API operation

Request method API endpoint Description
POST /v1.0/illumination/construction/project Create a project
PUT /v1.0/illumination/construction/project Edit a project
DELETE /v1.0/illumination/construction/project/{projectId} Delete a project
GET /v1.0/illumination/construction/project/{projectId} Get information about a project
GET /v1.0/illumination/construction/projects Get the list of projects
GET /v1.0/iot-02/projects/{project_id}/devices/count Query device statistics of the project

Create a project

API description

Create a project.

API endpoint

POST "/v1.0/illumination/construction/project"

Request parameter

Name Type Location Description Required
name string body The project name Yes
leaderMobile string body The project leader’s phone number Yes
leaderName string body The project leader’s name Yes
address string body The project address Yes
detail string body The specific address of the project, rather than geographic coordinates No
longitude double body The longitude of the project address Yes
latitude double body The latitude of the project address Yes

Return parameter

Name Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicate whether the operation succeeds.
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-bit timestamp.
result Object The request result.

Parameters of result

{
  "projectId": "string // The project ID",
  "ownerId": "string // The home ID"
}

Sample request

{
  "leaderMobile": "The project leader's phone number",
  "address": "The project address",
  "leaderName": "The project leader's name",
  "latitude": "The latitude of the project address",
  "name": "The project name",
  "detail": "The specific address of the project, rather than geographic coordinates",
  "longitude": "The longitude of the project address"
}

Sample response

{
  "ownerId": "The home ID",
  "projectId": "The project ID",
}

Edit a project

API description

Edit a project.

API endpoint

PUT "/v1.0/illumination/construction/project"

Request parameter

Name Type Location Description Required
projectId string body The project ID Yes
name string body The project name No
leaderMobile string body The project leader’s phone number No
leaderName string body The project leader’s name No
address string body The project address No
detail string body The specific address of the project, rather than geographic coordinates No
longitude double body The longitude of the project address No
latitude double body The latitude of the project address No

Return parameter

Name Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicate whether the operation succeeds.
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-bit timestamp.
result Object The request result.

Parameters of result

{
  "projectId": "string // The project ID"
}

Sample request

{
  "leaderMobile": "The project leader's phone number",
  "address": "The project address",
  "leaderName": "The project leader's name",
  "latitude": "The latitude of the project address",
  "name": "The project name",
  "detail": "The specific address of the project, rather than geographic coordinates",
  "projectId": "The poject ID",
  "longitude": "The longitude of the project address"
}

Sample response

{
  "projectId": "The project ID",
}

Delete a project

API description

Delete a project.

API endpoint

DELETE "/v1.0/illumination/construction/project/{projectId}"

Request parameter

Name Type Location Description Required
projectId string url The project ID Yes

Return parameter

Name Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicate whether the operation succeeds.
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-bit timestamp.
result Object The request result.

Parameters of result

{
  "success": "boolean"
}

Sample request

{
  "projectId": "The project ID",
}

Sample response

{
  "success": "Indicate whether the request is successful"
}

Get information about a single project

API description

Get information about a single project.

API endpoint

GET "/v1.0/illumination/construction/project/{projectId}"

Request parameter

Name Type Location Description Required
projectId string url The project ID Yes

Return parameter

Name Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicate whether the operation succeeds.
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-bit timestamp.
result Object The request result.

Parameters of result

{
  "projectId": "string // The project ID",
  "ownerId": "string // The home ID",
  "name": "string // The project name",
  "leaderMobile": "string // The project leader's phone number",
  "leaderName": "string // The project leader's name",
  "address": "string // The project address",
  "detail": "string // The specific address of the project",
  "longitude": "double // The longitude of the project address",
  "latitude": "double // The latitude of the project address",
  "timeZoneId": "string // The time zone ID",
  "timeZone": "string // The time zone of the project address",
  "zoneId": "string // The time ID of the project address",
  "source": "int // The source of the project",
  "locationId": "long // The home location ID",
  "gmtCreate": "long // The time when the project was created",
  "controlMode": "int // The control mode",
  "success": "boolean",
  "namespace": "string"
}

Sample request

{
  "projectId": "string // The project ID"
}

Sample response

{
  "projectId": "The project ID",
  "ownerId": "The home ID",
  "name": "The project name",
  "leaderMobile": "The project leader's phone number",
  "leaderName": "The project leader's name",
  "address": "The project address",
  "detail": "The specific address of the project",
  "longitude": "The longitude of the project address"
  "latitude": "The latitude of the project address",
  "timeZoneId": "The time zone ID",
  "timeZone": "The time zone of the project address",
  "zoneId": "The time ID of the project address",
  "source": "The project creation source",
  "locationId": "The home location ID",
  "gmtCreate": "The creation time",
  "controlMode": "The control mode",
  "success": "boolean",
  "namespace": "string"
}

Get the list of projects

API description

Get the list of projects.

API endpoint

GET "/v1.0/illumination/construction/projects"

Request parameter

Name Type Location Description Required
page int body The page number starting from 1 No
pageSize int body The number of entries per page. Valid values: 0 to 10000 No
keyword string body Query keyword No

Return parameter

Name Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicate whether the operation succeeds.
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-bit timestamp.
result Object The request result.

Parameters of result

{
  "total": "int",
  "list": [
    {
      "projectId": "string // The project ID",
      "ownerId": "string // The home ID",
      "name": "string // The project name",
      "leaderMobile": "string // The project leader's phone number",
      "leaderName": "string // The project leader's name",
      "address": "string // The project address",
      "detail": "string // The specific address of the project",
      "longitude": "double // The longitude of the project address",
      "latitude": "double // The latitude of the project address",
      "timeZoneId": "string // The ID of the time zone",
      "timeZone": "string // The time zone of the project address",
      "zoneId": "string // The time ID of the project address",
      "source": "int // The project creation source",
      "locationId": "long // The home location ID",
      "gmtCreate": "long // The creation time",
      "controlMode": "int // The control mode",
      "success": "boolean",
      "namespace": "string"
    }
  ]
}

Sample request

{
  "pageSize": "The number of entries per page",
  "page": "The page number"
}

Sample response

{
  "total": "int",
  "list": [
    {
      "projectId": "The project ID",
      "ownerId": "The home ID",
      "name": "The project name",
      "leaderMobile": "The project leader's phone number",
      "leaderName": "The project leader's name",
      "address": "The project address",
      "detail": "The specific address of the project",
      "longitude": "The longitude of the project address"
      "latitude": "The latitude of the project address",
      "timeZoneId": "The time zone ID",
      "timeZone": "The time zone of the project address",
      "zoneId": "The time ID of the project address",
      "source": "The project creation source",
      "locationId": "The home location ID",
      "gmtCreate": "The creation time",
      "controlMode": "The control mode",
      "success": "boolean",
      "namespace": "string"
    }
  ]
}

Query device statistics of the project

API description

Query the device statistics information about a specified project, including the total number of devices, and the number of online devices, offline devices, and devices that send an alert.

API endpoint

GET "/v1.0/iot-02/projects/{project_id}/devices/count"

Request parameter

Parameter Type Parameter type Definition Required
project_id string url The project ID Yes

Return parameter

Parameter Type Definition
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request fails. It is empty if the request is successful.
t Long The returned 13-bit timestamp.
result Object The returned result.

Description of result parameter

{
  "projectId": "String // The project ID",
  "deviceCount": "int // The number of devices",
  "onlineDeviceCount": "int // The number of online devices",
  "offlineDeviceCount": "int // The number of offline devices",
  "alarmDeviceCount": "int // The number of devices that send an alert"
}

Sample response

{
  "projectId": "The project ID",
  "deviceCount": "The number of devices",
  "onlineDeviceCount": "The number of online devices",
  "offlineDeviceCount": "The number of offline devices",
  "alarmDeviceCount": "The number of devices that send an alert"
}

Error code

The following table lists the error codes that might be returned when you make the API request. For more exception errors, see global error codes.

Error code Description
500 The error message is returned because a system error has occurred.