revolution/laravel-switchbot
SwitchBot API for Laravel
7,656
| Install | |
|---|---|
composer require revolution/laravel-switchbot |
|
| Latest Version: | 1.4.0 |
| PHP: | ^8.3 |
| License: | MIT |
| Last Updated: | Jul 20, 2026 |
| Links: | GitHub · Packagist |
Maintainer: revolution
SwitchBot API for Laravel
This package provides a simple integration with the SwitchBot API using Laravel's HTTP client macros.
For specific API details, please refer to the official SwitchBot API repository: https://github.com/OpenWonderLabs/SwitchBotAPI
Requirements
- PHP >= 8.3
- Laravel >= 12.0
Installation
composer require revolution/laravel-switchbot
Configuration
Get tokens from the SwitchBot app.
.env
SWITCHBOT_TOKEN=
SWITCHBOT_SECRET=
Usage
Built as a Laravel HTTP client macro.
use Illuminate\Support\Facades\Http;
$response = Http::switchbot()->get('devices');
dump($response->json());
$deviceId = $response->json('body.deviceList.0.deviceId');
if (filled($deviceId)) {
$response = Http::switchbot()->get("devices/$deviceId/status");
dump($response->json());
}
use Illuminate\Support\Facades\Http;
$response = Http::switchbot()->get('scenes');
dump($response->json());
Testing
use Illuminate\Support\Facades\Http;
Http::fake([
'*' => Http::response([
"statusCode" => 100,
"body" => [
"deviceList" => [],
"infraredRemoteList" => [],
],
"message" => "success",
]),
]);
$response = Http::switchbot()->get('devices');
$this->assertSame(100, $response->json('statusCode'));
LICENSE
MIT
Related Packages
spaanproductions/laravel-switchbot-frame
Standalone Laravel + Livewire admin page for the SwitchBot AI Art Frame: upload...
95
0
doctrine/dbal
Powerful PHP database abstraction layer (DBAL) with many features for database s...
637,827,751
9,703
laravel/serializable-closure
Laravel Serializable Closure provides an easy and secure way to serialize closur...
413,412,504
609
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.4.0 | ^8.3 | ^12.0| | MIT | |
| 1.3.0 | ^8.2 | ^11.0| | MIT | |
| 1.2.0 | ^8.1 | ^10.0| | MIT | |
| 1.1.0 | ^8.0 | ^9.0| | MIT | |
| 1.0.1 | ^8.0 | ^9.0 | MIT | |
| 1.0.0 | ^8.0 | ^9.0 | MIT |