PHPackages                             evilhalba/tuyapiphp-fork - 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. evilhalba/tuyapiphp-fork

ActiveLibrary[API Development](/categories/api)

evilhalba/tuyapiphp-fork
========================

Tuya cloud api home management php client

1.2(5mo ago)06GPL-3.0-or-laterPHPPHP &gt;=8.1

Since Dec 7Pushed 5mo agoCompare

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

READMEChangelog (3)Dependencies (1)Versions (3)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

34

—

LowBetter than 77% of packages

Maintenance73

Regular maintenance activity

Popularity4

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75.6% 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 ~0 days

Total

2

Last Release

154d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a53ca8995e71479c2c20bad527b9622d00be12167956c97f54893001faf33c09?d=identicon)[evilhalba](/maintainers/evilhalba)

---

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)")[![evilhalba](https://avatars.githubusercontent.com/u/52472753?v=4)](https://github.com/evilhalba "evilhalba (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/evilhalba-tuyapiphp-fork/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

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

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

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

PHP wrapper for the Meilisearch API

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

Google API Core for PHP

263103.1M453](/packages/google-gax)

PHPackages © 2026

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