PHPackages                             tuyapiphp/tuyapiphp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tuyapiphp/tuyapiphp

ActiveLibrary[API Development](/categories/api)

tuyapiphp/tuyapiphp
===================

Tuya cloud api home management php client

1.1.3(1y ago)3814.2k↓40.9%18[1 issues](https://github.com/ground-creative/tuyapiphp/issues)GPL-3.0-or-laterPHPPHP &gt;=8.1

Since Feb 28Pushed 6mo ago6 watchersCompare

[ Source](https://github.com/ground-creative/tuyapiphp)[ Packagist](https://packagist.org/packages/tuyapiphp/tuyapiphp)[ RSS](/packages/tuyapiphp-tuyapiphp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (4)Used By (0)

Tuya Cloud Api PHP Client
=========================

[](#tuya-cloud-api-php-client)

This is a simple php client to interact with devices that support the tuya api.

*A version of the lib for nodejs is hosted here: *

*If you are looking for a more ready to use solution or u need to control devices from different brands, you can use [this tool](https://github.com/ifsale/YourHomeServer) with nodejs.*

Requirements
------------

[](#requirements)

I believe all is needed is php curl for the requests.

Installation
------------

[](#installation)

### With composer:

[](#with-composer)

Add the package to your composer.json file

```
"require":
{

        "tuyapiphp/tuyapiphp": "*"
}

```

and run `composer update`

### Stand Alone:

[](#stand-alone)

You must require all the needed classes manually, or you can use an autoloader [like this one](http://phptoolcase.com/guides/ptc-hm-guide.html).

Basic Usage
-----------

[](#basic-usage)

Use these [setup instructions](https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md) for how to find the needed parameters.

### Create new instance

[](#create-new-instance)

```
$config =
[
	'accessKey' 	=> 'xxxxxxxxxxxxxxxxx' ,
	'secretKey' 	=> 'xxxxxxxxxxxxxxxxx' ,
	'baseUrl'		=> 'https://openapi.tuyaus.com'
];

$tuya = new \tuyapiphp\TuyaApi( $config );

```

### Get an access token

[](#get-an-access-token)

```
$data = $tuya->token->get_new( );

```

### Example device operations

[](#example-device-operations)

```
$app_id = 'xxxxxxxxxxxxxxxxxxxx';

$device_id = 'xxxxxxxxxxxxxxxxxxx';

// Get a token
$token = $tuya->token->get_new( )->result->access_token;

// Get list of devices connected with tuya/smart life app
$tuya->devices( $token )->get_app_list( $app_id );

// Get device status
$tuya->devices( $token )->get_status( $device_id );

// Set device name
$tuya->devices( $token )->put_name( $device_id , [ 'name' => 'FAN' ] );

// Send command to device
$payload = [ 'code' => 'switch_1' , 'value' => false ];
$tuya->devices( $token )->post_commands( $device_id , [ 'commands' => [ $payload ] ] );

```

### Example camera stream

[](#example-camera-stream)

```
$app_id = 'xxxxxxxxxxxxxxxxxx';

$camera_id = 'xxxxxxxxxxxxxxxxxxxx';

$tuya = new \tuyapiphp\TuyaApi( $config );

// Get a token
$token = $tuya->token->get_new( )->result->access_token;

// Get camera stream link
$stream = $tuya->devices( $token )->post_stream_allocate( $app_id , $camera_id , [ 'type' => 'rtsp' ] );

```

Use the returned url to open the stream: `ffplay -i rtsps://xxxxxxxxx`

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance54

Moderate activity, may be stable

Popularity39

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~326 days

Total

3

Last Release

522d ago

PHP version history (2 changes)1.1.1PHP &gt;=5.3

1.1.3PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/8352e76f8a98f5253281053fa04631890f21b9d50aaaa14776daf3bc3348c4d2?d=identicon)[ground-creative](/maintainers/ground-creative)

---

Top Contributors

[![ground-creative](https://avatars.githubusercontent.com/u/1550792?v=4)](https://github.com/ground-creative "ground-creative (59 commits)")[![vespino](https://avatars.githubusercontent.com/u/6991325?v=4)](https://github.com/vespino "vespino (6 commits)")[![apphancer](https://avatars.githubusercontent.com/u/3098891?v=4)](https://github.com/apphancer "apphancer (5 commits)")[![daudfatihah](https://avatars.githubusercontent.com/u/15126928?v=4)](https://github.com/daudfatihah "daudfatihah (2 commits)")[![StanekO](https://avatars.githubusercontent.com/u/29358013?v=4)](https://github.com/StanekO "StanekO (1 commits)")

---

Tags

Tuyasmart life

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tuyapiphp-tuyapiphp/health.svg)

```
[![Health](https://phpackages.com/badges/tuyapiphp-tuyapiphp/health.svg)](https://phpackages.com/packages/tuyapiphp-tuyapiphp)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
