Documentation - Devices


  1. Getting an android device information
  2. Searching android devices

Devices - Searching android devices

You can use the SMS Gateway API to get a list of your devices programmatically. Devices refer to your Android phones that you currently have connected to your SMS Gateway API account.
Below is some sample requests and response. For complete API documentation on searching android devices please refer to the Swagger (Open API Specification) documentations here: SMS Gateway API Definition


API Request

Request Endpoint
Endpoint: https://smsgateway.me/api/v4/device/search
Method: POST
Request Parameters
Name Location Required Description
Authorization header true Your API token found on the settings page
search body true The search query

Request Example

Valid Fields: id, type, name, phone_number, make, model, provider, country

{
  "filters": [
    [
      {
        "field": "name",
        "operator": "=",
        "value": "New Device"
      },
      {
        "field": "country",
        "operator": "=",
        "value": "uk"
      }
    ],
    [
      {
        "field": "make",
        "operator": "=",
        "value": "samsung"
      }
    ]
  ],
  "order_by": [
    {
      "field": "type",
      "direction": "desc"
    },
    {
      "field": "make",
      "direction": "asc"
    }
  ],
  "limit": 5,
  "offset": 5
}

Response Examples

Successful Response

A search result object consisting of results and a total result count

Response Code: 200

{
  "results": [
    {
      "attributes": {
        "phone_number": "07791064782",
        "make": "Samsung",
        "model": "S9",
        "provider": "EE",
        "country": "UK",
        "connection_type": "wifi",
        "battery": 10,
        "signal_percent": 90,
        "wifi": true,
        "gcm": "1234567"
      },
      "id": 79010,
      "name": "Device 79010"
    },
    {
      "attributes": {
        "phone_number": "07956042961",
        "make": "Samsung",
        "model": "SM-J320F",
        "provider": "EE",
        "country": "gb",
        "connection_type": "4G",
        "battery": 100,
        "signal_percent": 75,
        "wifi": true,
        "lat": "-0.2456489",
        "lng": "-0.2456489",
        "last_seen": "2018-05-05T16:10:49+00:00"
      },
      "id": 86675,
      "name": "Device 86675"
    }
  ],
  "count": 5
}

Error Response

When a request can not be processed

Response Code: 40x | 500

{
  "status": "fail",
  "message": "Could not process request",
  "data": {
    "exception": "Error message"
  }
}

SDK Examples

You can use our Swagger generated PHP SDK to help integrate with our service. If you wish to use SMS Gateway Me with a different platform you may generate your own client using the swagger file.

Installation Instructions: PHP SMS Gateway SDK
Swagger Definition: SMS Gateway API Definition


Request Example

<?php

require 'vendor/autoload.php';

use SMSGatewayMe\Client\ApiClient;
use SMSGatewayMe\Client\Configuration;
use SMSGatewayMe\Client\Api\DeviceApi;

// Configure client
$config = Configuration::getDefaultConfiguration();
$config->setApiKey('Authorization', 'your-token-here');
$apiClient = new ApiClient($config);

// Create device client
$deviceClient = new DeviceApi($apiClient);

/**
 *   Device Search
 *
 *   Valid Fields: id, type, name, phone_number, make, model, provider, country
 *
 *   Filters is a multidimensional array.
 *   Each array inside of $filters is a query group.
 *   An 'and' is done for items within the same group. and an 'or' between groups.
 */
$devices = $deviceClient->searchDevices(
    [
        'filters' => [
            [
                [
                    'field' => 'name',
                    'operator' => '=',
                    'value' => 'New Device'
                ],
                [
                    'field' => 'country',
                    'operator' => '=',
                    'value' => 'uk'
                ]
            ],
            [
                [
                    'field' => 'make',
                    'operator' => '=',
                    'value' => 'samsung'
                ]
            ]
        ],
        'order_by' => [
            [
                'field' => 'type',
                'direction' => 'DESC'
            ],
            [
                'field' => 'make',
                'direction' => 'ASC'
            ]
        ],
        'limit'   => 5,
        'offset'  => 5
    ]
);
print_r($devices);

Successful response

SMSGatewayMe\Client\Model\DeviceSearchResult Object
(
    [count:protected] => 6
    [results:protected] => Array
        (
            [0] => SMSGatewayMe\Client\Model\Device Object
                (
                    [id:protected] => 1
                    [name:protected] => New Device
                    [attributes:protected] => SMSGatewayMe\Client\Model\DeviceAttributes Object
                        (
                            [phoneNumber:protected] => 07791064781
                            [make:protected] => samsung
                            [model:protected] => SM-G965F
                            [provider:protected] => EE
                            [country:protected] => gb
                            [connectionType:protected] => 4G
                            [battery:protected] => 43
                            [signalPercent:protected] =>
                            [wifi:protected] =>
                            [lat:protected] => 51.6076925
                            [lng:protected] => -0.2946643
                            [lastSeen:protected] => DateTime Object
                                (
                                    [date] => 2018-05-14 17:36:20.000000
                                    [timezone_type] => 1
                                    [timezone] => +00:00
                                )

                        )

                )
        )
)