PHPackages                             rbertolli/tuya-php - 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. rbertolli/tuya-php

ActiveLibrary[API Development](/categories/api)

rbertolli/tuya-php
==================

Cliente PHP para a API Tuya

15↓66.7%1PHPCI passing

Since Mar 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Rbertolli/tuya_php)[ Packagist](https://packagist.org/packages/rbertolli/tuya-php)[ RSS](/packages/rbertolli-tuya-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

Tuya PHP
========

[](#tuya-php)

This is a PHP client for interacting with the Tuya API, including support for Smart Locks and serverless deployment.

### **🔹 One-Click Deploy**

[](#-one-click-deploy)

You can deploy this project on **DigitalOcean** with a single click and get **$200 in credits** when creating an account.

[![Deploy to DigitalOcean](https://camo.githubusercontent.com/1959f5da42c67ccef3538861164e5d4bb24c70a9920a996eedb4ce5c4c2a3946/68747470733a2f2f7777772e6465706c6f79746f646f2e636f6d2f646f2d62746e2d626c75652e737667)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/Rbertolli/tuya_php/tree/main)

📖 Features
----------

[](#-features)

- **Generic Tuya Client:** Communicate with the Tuya API for token retrieval and device information.
- **Smart-Lock Functions:** Specific smart-lock functionalities, including:
    - Retrieving a password ticket for smart locks.
    - Encrypting a numeric password.
    - Creating a temporary password.
- Serverless functions support.
- Click-to-Deploy on DigitalOcean App Platform.
- Easy integration with PHP applications.

⚙️ Requirements
---------------

[](#️-requirements)

- PHP 7.2 or higher
- PHP extensions: `curl`, `openssl`
- [Composer](https://getcomposer.org/)

📜 Environment Variables
-----------------------

[](#-environment-variables)

Configure your `.env` file with the following:

```
TUYA_API_KEY=your_api_key_here
TUYA_API_SECRET=your_api_secret_here
TUYA_REGION=your_region_here

```

🌐 How to Generate Tuya API Credentials
--------------------------------------

[](#-how-to-generate-tuya-api-credentials)

To use this package, you must first obtain API credentials from Tuya. Follow these steps:

### **1. Create a Tuya Developer Account**

[](#1-create-a-tuya-developer-account)

1. Go to [Tuya IoT Platform](https://iot.tuya.com/).
2. Sign up or log in to your **Tuya Developer Account**.

### **2. Create a Cloud Project**

[](#2-create-a-cloud-project)

1. Navigate to **Cloud Development** and select **Create Cloud Project**.
2. Fill in the project details:
    - **Development Method**: Custom Development
    - **Industry**: Select based on your use case (e.g., Smart Home).
    - **Data Center**: Choose the closest data center to your location.
    - **API Services**: Select the necessary API services (e.g., Smart Home, Device Control).
3. Click **Create**.

### **3. Retrieve API Credentials**

[](#3-retrieve-api-credentials)

Once your project is created, go to **Project Details** and find:

- **Client ID** (`TUYA_CLIENT_ID`)
- **Client Secret** (`TUYA_CLIENT_SECRET`)

### **4. Link Your Tuya Devices**

[](#4-link-your-tuya-devices)

1. In the **Cloud Project**, go to **Devices**.
2. Click **Link Tuya App Account**.
3. Scan the QR Code using the **Tuya Smart App**.
4. After linking, all devices in your Tuya App will be available via API.

🌐 Serverless Functions
----------------------

[](#-serverless-functions)

This project supports DigitalOcean Functions for seamless API execution.

### Example Requests

[](#example-requests)

You can test the API using the `examples/requests.http` file or with cURL/Postman.

#### 🔐 Authenticate with Tuya API

[](#-authenticate-with-tuya-api)

```
GET {{base_url}}/functions/login.php
```

#### 🔑 Create a Temporary Smart Lock Password

[](#-create-a-temporary-smart-lock-password)

```
GET {{base_url}}/functions/smart_lock.php?device_id=YOUR_DEVICE_ID&password=123456&start_time=1713456000&end_time=1713542400
```

🛠 Click-to-Deploy
-----------------

[](#-click-to-deploy)

To deploy on DigitalOcean App Platform, simply use the `do_config/project.yml` configuration.

🏗 Contributing
--------------

[](#-contributing)

Contributions are welcome! Feel free to open issues or submit pull requests. If you have any questions, contact us via email at ****.

📄 License
---------

[](#-license)

This project is licensed under the MIT License.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

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

---

Top Contributors

[![Rbertolli](https://avatars.githubusercontent.com/u/17477719?v=4)](https://github.com/Rbertolli "Rbertolli (97 commits)")

### Embed Badge

![Health badge](/badges/rbertolli-tuya-php/health.svg)

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

###  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)[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.1M454](/packages/google-gax)

PHPackages © 2026

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