Managing User devices

In this section, we will demonstrate how to create new devices for your applications and manipulate them effectively.

Get user devices

GET https://www.pulsestracker.com/api/devices

Query parameters :
page : int , Default 1

Example request

const url = 'https://www.pulsestracker.com/api/devices';
const options = {
  method: 'GET',
  headers: {Accept: 'application/json', Authorization: 'Bearer 123'}
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

Example response

{
  "data": [
    {
      "app_key": "string",
      "key": "string",
      "name": "string",
      "type": "string",
      "app": {
        "key": "string",
        "name": "string",
        "quota": [
          {
            "year": 0,
            "month": 0,
            "messages_sent": 0
          }
        ],
        "devices_count": 0,
        "created_at": "2019-08-24T14:15:22Z"
      },
      "lastLocation": {
        "id": 0,
        "ip_address": "string",
        "location": {
          "type": "string",
          "coordinates": {
            "lat": 0,
            "long": 0
          }
        },
        "extra_data": {
          "property1": "string",
          "property2": "string"
        },
        "updated_at": "2019-08-24T14:15:22Z"
      },
      "quota": [
        {
          "year": 0,
          "month": 0,
          "messages_sent": 0
        }
      ]
    }
  ],
  "meta": {
    "current_page": 0,
    "from": 0,
    "last_page": 0,
    "links": [
      {
        "url": "string",
        "label": "string",
        "active": true
      }
    ],
    "path": "string",
    "per_page": 0,
    "to": 0,
    "total": 0
  },
  "links": {
    "first": "string",
    "last": "string",
    "prev": "string",
    "next": "string"
  }
}

Or get device by key :

const url = 'https://www.pulsestracker.com/api/devices/{id}';
const options = {
  method: 'GET',
  headers: {Accept: 'application/json', Authorization: 'Bearer 123'}
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
{
  "data": {
    "app_key": "string",
    "key": "string",
    "name": "string",
    "type": "string",
    "app": {
      "key": "string",
      "name": "string",
      "quota": [
        {
          "year": 0,
          "month": 0,
          "messages_sent": 0
        }
      ],
      "devices_count": 0,
      "created_at": "2019-08-24T14:15:22Z"
    },
    "lastLocation": {
      "id": 0,
      "ip_address": "string",
      "location": {
        "type": "string",
        "coordinates": {
          "lat": 0,
          "long": 0
        }
      },
      "extra_data": {
        "property1": "string",
        "property2": "string"
      },
      "updated_at": "2019-08-24T14:15:22Z"
    },
    "quota": [
      {
        "year": 0,
        "month": 0,
        "messages_sent": 0
      }
    ]
  }
}

Create new application device

POST https://www.pulsestracker.com/api/devices

With this endpoint, you can create a new device for a user.

Quota Limit: If you exceed the maximum number of applications allowed for your account, the server will return a 403 Forbidden error.

Validation Errors: If any required fields are missing or invalid, the server will return a 422 Unprocessable Entity error.

To get device type_id you can query this endpoint :

GET https://www.pulsestracker.com/api/device_types

Example request

const url = 'https://www.pulsestracker.com/api/devices';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Accept: 'application/json',
    Authorization: 'Bearer 123'
  },
  body: '{"name":"string","app_key":"string","type_id":0}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

Example response

{
  "data": {
    "app_key": "string",
    "key": "string",
    "name": "string",
    "type": "string",
    "app": {
      "key": "string",
      "name": "string",
      "quota": [
        {
          "year": 0,
          "month": 0,
          "messages_sent": 0
        }
      ],
      "devices_count": 0,
      "created_at": "2019-08-24T14:15:22Z"
    },
    "lastLocation": {
      "id": 0,
      "ip_address": "string",
      "location": {
        "type": "string",
        "coordinates": {
          "lat": 0,
          "long": 0
        }
      },
      "extra_data": {
        "property1": "string",
        "property2": "string"
      },
      "updated_at": "2019-08-24T14:15:22Z"
    },
    "quota": [
      {
        "year": 0,
        "month": 0,
        "messages_sent": 0
      }
    ]
  }
}

Update device name

PUT https://www.pulsestracker.com/api/devices/{id}

Example request

const url = 'https://www.pulsestracker.com/api/devices/{id}';
const options = {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
    Accept: 'application/json',
    Authorization: 'Bearer 123'
  },
  body: '{"name":"string"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}

Example response

"string of name"
Updated on