Download the PHP package christianjbrown/smartthings-api-sdk without Composer

On this page you can find all versions of the php package christianjbrown/smartthings-api-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package smartthings-api-sdk

SmartThings API SDK

CI Coverage Packagist License PHP

A strongly-typed PHP client for the SmartThings API. It lists the devices in your SmartThings account, reads a device's status, and — for the operations below marked as writes — lets you act on them: run device commands, switch a location's mode, and execute scenes and rules. It returns plain, typed model objects rather than raw arrays.

The client currently supports:

Supported endpoints

Resource Client Endpoint(s) Returns
Devices getDeviceApi() GET /devices, GET /devices/{deviceId}, POST /devices/{deviceId}/commands, POST /devices, PUT /devices/{deviceId}, DELETE /devices/{deviceId}, POST /devices/{deviceId}/events DeviceInterface[] / DeviceInterface / DeviceCommandResultInterface[]
Virtual devices getVirtualDeviceApi() GET /virtualdevices DeviceInterface[]
Device status getDeviceStatusApi() GET /devices/{deviceId}/status, GET /devices/{deviceId}/components/{componentId}/status, GET /devices/{deviceId}/components/{componentId}/capabilities/{capabilityId}/status DeviceStatusInterface
Device health getDeviceHealthApi() GET /devices/{deviceId}/health DeviceHealthInterface
Device preferences getDevicePreferencesApi() GET /devices/{deviceId}/preferences DevicePreferenceInterface[]
Device preference definitions getDevicePreferenceDefinitionApi() GET /devicepreferences, GET /devicepreferences/{preferenceId}, GET /devicepreferences/{id}/i18n, GET /devicepreferences/{id}/i18n/{locale}, POST /devicepreferences, PUT /devicepreferences/{preferenceId}, DELETE /devicepreferences/{preferenceId}, POST /preferences/{preferenceId}/i18n, PUT /preferences/{preferenceId}/i18n/{locale} DevicePreferenceDefinitionInterface[] / DevicePreferenceDefinitionInterface / LocaleReferenceInterface[] / LocalizationInterface
Device history getDeviceHistoryApi() GET /history/devices (paged) DeviceHistoryEventInterface[]
Locations getLocationApi() GET /locations, GET /locations/{locationId}, POST /locations, PUT /locations/{locationId}, PATCH /locations/{locationId}, DELETE /locations/{locationId} LocationInterface[] / LocationInterface
Rooms getLocationRoomApi() GET /locations/{locationId}/rooms, GET /locations/{locationId}/rooms/{roomId}, GET /locations/{locationId}/rooms/{roomId}/devices, POST /locations/{locationId}/rooms, PUT /locations/{locationId}/rooms/{roomId}, DELETE /locations/{locationId}/rooms/{roomId} LocationRoomInterface[] / LocationRoomInterface / DeviceInterface[]
Modes getLocationModeApi() GET /locations/{locationId}/modes, GET /locations/{locationId}/modes/current, GET /locations/{locationId}/modes/{modeId}, PUT /locations/{locationId}/modes/current, POST /locations/{locationId}/modes, PUT /locations/{locationId}/modes/{modeId}, DELETE /locations/{locationId}/modes/{modeId} ModeInterface[] / ModeInterface
Scenes getSceneApi() GET /scenes, GET /scenes/{sceneId}, POST /scenes/{sceneId}/execute SceneInterface[] / SceneInterface / SceneExecutionResultInterface
Rules getRuleApi() GET /rules?locationId=…, GET /rules/{ruleId}?locationId=…, POST /rules/execute/{ruleId}, POST /rules?locationId=…, PUT /rules/{ruleId}?locationId=…, DELETE /rules/{ruleId}?locationId=…, DELETE /rules?locationId=… RuleInterface[] / RuleInterface / RuleExecutionResultInterface
Capabilities getCapabilityApi() GET /capabilities, GET /capabilities/namespaces, GET /capabilities/namespaces/{namespace}, GET /capabilities/{id}, GET /capabilities/{id}/{version}, GET /capabilities/{id}/{version}/presentation, GET /capabilities/{id}/{version}/i18n, GET /capabilities/{id}/{version}/i18n/{tag}, POST /capabilities, PUT /capabilities/{id}/{version}, DELETE /capabilities/{id}/{version}, POST /capabilities/{id}/{version}/i18n, PUT /capabilities/{id}/{version}/i18n/{locale}, PATCH /capabilities/{id}/{version}/i18n/{locale}, POST /capabilities/{id}/{version}/presentation, PUT /capabilities/{id}/{version}/presentation CapabilityInterface[] / CapabilityInterface / CapabilityNamespaceInterface[] / CapabilityPresentationInterface / LocaleReferenceInterface[] / LocalizationInterface
Device profiles getDeviceProfileApi() GET /deviceprofiles, GET /deviceprofiles/{deviceProfileId}, GET /deviceprofiles/{id}/i18n, GET /deviceprofiles/{id}/i18n/{tag}, POST /deviceprofiles, PUT /deviceprofiles/{deviceProfileId}, DELETE /deviceprofiles/{deviceProfileId} DeviceProfileInterface[] / DeviceProfileInterface / LocaleReferenceInterface[] / LocalizationInterface
Presentation getPresentationApi() GET /presentation, GET /presentation?deviceId=…, GET /presentation/deviceconfig, GET /presentation/types/{typeIntegrationId}/deviceconfig, POST /presentation/deviceconfig PresentationInterface / DeviceConfigurationInterface / DevicePresentationInterface / CreateDeviceConfigRequestInterface
Apps getAppApi() GET /apps, GET /apps/{appNameOrId}, GET /apps/{appNameOrId}/oauth, GET /apps/{appNameOrId}/settings, POST /apps, PUT /apps/{appNameOrId}, DELETE /apps/{appNameOrId}, PUT /apps/{appNameOrId}/settings, PUT /apps/{appNameOrId}/oauth, POST /apps/{appNameOrId}/oauth/generate, PUT /apps/{appNameOrId}/register, PUT /apps/{appNameOrId}/signature-type AppInterface[] / AppInterface / AppOauthInterface / AppSettingsInterface
Installed apps getInstalledAppApi() GET /installedapps, GET /installedapps/{id}, GET /installedapps/me, GET /installedapps/{id}/configs, GET /installedapps/{id}/configs/{configurationId}, DELETE /installedapps/{id}, POST /installedapps/{id}/events, PUT /installedapps/{id}/alias/{aliasName}, DELETE /installedapps/{id}/alias/{aliasName}, GET /installedapps/{id}/alias/{aliasName}/capability InstalledAppInterface[] / InstalledAppInterface / InstalledAppConfigInterface[] / InstalledAppConfigInterface
Subscriptions getSubscriptionApi() GET /installedapps/{id}/subscriptions, GET /installedapps/{id}/subscriptions/{subscriptionId}, POST /installedapps/{id}/subscriptions, DELETE /installedapps/{id}/subscriptions/{subscriptionId}, DELETE /installedapps/{id}/subscriptions SubscriptionInterface[] / SubscriptionInterface
Schedules getScheduleApi() GET /installedapps/{id}/schedules, GET /installedapps/{id}/schedules/{scheduleName}, POST /installedapps/{id}/schedules, DELETE /installedapps/{id}/schedules/{scheduleName}, DELETE /installedapps/{id}/schedules ScheduleInterface[] / ScheduleInterface
Organizations getOrganizationApi() GET /organizations, GET /organizations/{organizationId} OrganizationInterface[] / OrganizationInterface
Location services getServiceApi() GET /services/coordinate/locations/{id}, GET /services/coordinate/locations/{id}/capabilities (list and ?name=…), POST /services/coordinate/locations/{id}/subscriptions, PUT /services/coordinate/locations/{id}/subscriptions/{subscriptionId}, DELETE /services/coordinate/locations/{id}/subscriptions/{subscriptionId}, DELETE /services/coordinate/locations/{id}/subscriptions?isaId=… ServiceLocationInfoInterface / string[] / ServiceCapabilityDataInterface
Edge drivers getDriverApi() GET /drivers, GET /drivers/default, GET /drivers/{driverId}, GET /drivers/{driverId}/versions/{version}, DELETE /drivers/{driverId}, POST /drivers/package DriverInterface[] / DriverInterface
Text to speech getTextToSpeechApi() GET /services/tts/info, POST /services/tts, POST /services/tts/playtext TtsInfoInterface / ConvertedTtsInterface / PlayedTextInterface
Schema app invitations getSchemaAppInviteApi() POST /invites/schemaApp, PUT /invites/schemaApp/{shortCode}/accept, GET /invites/schemaApp, GET /invites/schemaApp/checkAcceptance SchemaAppInviteReceiptInterface / SchemaAppInviteAcceptanceInterface / SchemaAppInvitePageInterface / SchemaAppInviteStatusInterface
Edge channels getChannelApi() GET /distchannels, GET /distchannels/{channelId}, GET /distchannels/{channelId}/drivers, GET /distchannels/{channelId}/drivers/{driverId}/meta, GET /distchannels/{channelId}/drivers/{driverId}, POST /distchannels, PUT /distchannels/{channelId}, DELETE /distchannels/{channelId}, POST /distchannels/{channelId}/drivers, PUT /distchannels/{channelId}/drivers/{driverId}, DELETE /distchannels/{channelId}/drivers/{driverId} ChannelInterface[] / ChannelInterface / ChannelDriverInterface[] / DriverInterface
Edge hubs getHubApi() GET /hubdevices/{hubId}, GET /hubdevices/{hubId}/characteristics, GET /hubdevices/{hubId}/drivers, GET /hubdevices/{hubId}/drivers/{driverId}, GET /hubdevices/{hubId}/channels, PUT /hubdevices/{hubId}/drivers/{driverId}, DELETE /hubdevices/{hubId}/drivers/{driverId}, PATCH /hubdevices/{hubId}/childdevice/{deviceId}, DELETE /hubdevices/eui/{hubEui} HubInterface / scalar map / HubInstalledDriverInterface[] / HubInstalledDriverInterface / HubEnrolledChannelInterface[]
ST Schema connectors getSchemaConnectorApi() GET /schema/apps, GET /schema/apps/{id}, GET /schema/install/{id}, GET /schema/installedapps/location/{locationId}, GET /schema/installedapps/{id}, GET /schema/apps/user/{userId}, GET /schema/apps/organizations, POST /schema/apps, PUT /schema/apps/{endpointAppId}, DELETE /schema/apps/{endpointAppId}, DELETE /schema/installedapps/{isaId}, POST /schema/oauth/stclient/credentials SchemaAppInterface[] / SchemaAppInterface / SchemaPageInterface / InstalledSchemaAppInterface[] / InstalledSchemaAppInterface

:heavy_check_mark: Prerequisites

:bulb: If you're on MacOS and have Homebrew, PHP and Composer will install with brew install composer.

:building_construction: Installation

For your composer-enabled project:

:computer: Usage

First, create a SmartThings personal access token with the devices scopes. This token is passed to each API client.

The quickest way to get the two clients is the SmartThings entry point, which builds them (and their transformer chains) for you through a dependency-injection container — just pass your token:

If you'd rather wire the clients by hand, see Wiring the clients below.

With either approach, listing devices and reading a device's status looks like this:

You can also read a single device or its status by id, list locations, or list and fetch rooms directly:

Writing: commands, modes, scenes, and rules

Reading everything a device reports

DeviceStatusApi::getReportById() returns every component, capability and attribute of a device with its health state; getComponentReport() and getCapabilityReport() narrow it. Attribute values are AttributeStateInterface objects (value, unit, data, timestamp), keyed by capability and attribute name:

Installed app configuration entries are typed too: InstalledAppConfigInterface::getConfigEntries() returns the entries of each configuration name (string, device, permission, mode, scene, message and room configs).

Reading error bodies

Failed requests surface as RequestExceptionInterface from christianjbrown/api-client. When the API sent an error body, read it with the error transformer:

SchemaAppOwnerApi (getSchemaAppOwnerApi()) returns the apps of an organization or a user with the wrapper fields (getOrganizationIds(), getUserId()).

Filtering and query parameters

List and get calls take the API's optional query parameters. The busier lists take a small query object; the rest take plain optional arguments after $skipCache. Lists such as capability or driverIds are sent as repeated parameters, as the API expects.

Calls the API scopes to an organization or a language take them as a trailing optional argument ($organizationId sends X-ST-Organization, $acceptLanguage sends Accept-Language), for example $deviceProfileApi->getOneById('a-profile-id', false, 'an-org-id', 'fr-FR'). Cached responses are kept per organization and language.

ServiceApi::getAlertLink() returns the address the coordinate service redirects to for a location's weather alert page. The redirect is read, not followed.

List calls read every page: when a response carries _links.next.href the client follows it (up to 100 pages) and returns all the items together. DeviceHistoryApi keeps its own $maxPages limit and is not affected.

The other query objects are InstalledAppListQuery, AppListQuery, RuleListQuery, LocationListQuery and PreferenceListQuery. Each response is cached per full request, so the same call with a different filter is fetched again.

:rotating_light: Error handling

Everything this library throws implements ChristianBrown\SmartThings\Exception\ExceptionInterface, so a single catch covers it all:

There are two concrete types:

Both live in src/Exception/. Request-level failures (network errors, non-2xx responses) still surface as RequestExceptionInterface from christianjbrown/api-client, which is outside this library's exception hierarchy.

Under the hood, SmartThings wires the clients and their transformer chains through a Symfony dependency-injection container. If you don't want the container, you can build the same chains by hand — as shown below. The HTTP request sender comes from christianjbrown/api-client.

Overriding the API host

Every request goes to https://api.smartthings.com by default. To point at a different host — a staging environment, a proxy, a recorded-fixture server in a test suite — pass an ApiHostInterface as the second constructor argument:

Omit it, or pass null, and requests go to production exactly as before — existing callers don't need to change anything. ApiHostInterface::PRODUCTION_BASE_URL holds the default. The interface constants on each *ApiInterface (e.g. DeviceApiInterface::API_URL) still point at production and are unaffected by an override; the override only changes the host each request is actually sent to.

Wiring the clients The `SmartThings` facade builds and wires every client, and that is the supported way to use the library. If you construct a client yourself, every collaborator is a required constructor argument: the JSON request sender, the client's transformers, a `Token`, and, for the operations that write, the request serializers and response transformers. The registrars under `src/DependencyInjection/Registrar/` show the exact wiring of each client. For example, the scenes client:

:arrow_up: Upgrading to 2.0

Version 2.0 removes the built-in fallbacks: a client no longer builds a default serializer or transformer for a collaborator you leave out. Every collaborator of an *Api class, and of the transformers and serializers that take collaborators, is now a required constructor argument typed on its interface. Code that uses the SmartThings facade (new SmartThings($token) and the get*Api() getters) is unaffected, because the facade's registrars wire everything. Code that constructs *Api classes by hand has to pass the collaborators, including the RequestUrlBuilderInterface that the clients with query parameters take; the registrars list them.

:memo: Changelog

Notable changes in each release are listed in CHANGELOG.md.

:page_facing_up: License

Released under the MIT License.


All versions of smartthings-api-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
christianjbrown/api-client Version ^3.0
guzzlehttp/guzzle Version ^7.15
psr/container Version ^2.0
symfony/dependency-injection Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package christianjbrown/smartthings-api-sdk contains the following files

Loading the files please wait ...