Examples

Here you will find example queries using GraphQL.

 

Find all Services by Hardware ID

All Services on a given remote.it Device have matching Hardware IDs.

query getServices($hwid: String) {
login {
devices(hardwareId: $hwid) {
items {
hardwareId
id
services {
name
id
application
endpoint {
offlineSince
onlineSince
}
}
}
}
}
}

using the Query Variables:

{
"hwid": "dc:a6:32:19:41:90-TVKNqPiIfao8dwK1EHyq"
}

returns:

{
"data": {
"login": {
"devices": {
"items": [
{
"hardwareId": "dc:a6:32:19:41:90-TVKNqPiIfao8dwK1EHyq",
"id": "80:00:00:05:3a:00:3a:5b",
"services": [
{
"name": "Game-Timer-VNC",
"id": "80:00:00:05:3a:00:3a:5d",
"application": 4,
"endpoint": {
"offlineSince": "2020-03-06T23:55:39.000Z",
"onlineSince": null
}
},
{
"name": "Game-Timer-01",
"id": "80:00:00:05:3a:00:3a:5b",
"application": 35,
"endpoint": {
"offlineSince": "2020-03-06T23:55:39.000Z",
"onlineSince": null
}
},
{
"name": "Game-Timer-SSH",
"id": "80:00:00:05:3a:00:3a:5c",
"application": 28,
"endpoint": {
"offlineSince": "2020-03-06T23:55:39.000Z",
"onlineSince": null
}
}
]
}
]
}
}
}
}

 

Find remote.it Services by Name

query getDevice($name: String) {
login {
devices(name: $name) {
items {
name
id
hardwareId
}
}
}
}

using the Query Variables:

{
"name": "tim"
}

returns:

{
"data": {
"login": {
"devices": {
"items": [
{
"name": "Game-Timer-01",
"id": "80:00:00:05:XX:XX:XX:XX",
"hardwareId": "XX:XX:XX:XX:XX:XX-TVKNqPiIfao8dwK1EHyq"
}
]
}
}
}
}

 

Getting User Information

This will show information about the user whose login token is passed in as a header to this call.

{
login {
id
created
email
language
lastLogin
timezone
endpoints {
sessions {id}
}
}
}

Sample response:

{
"data": {
"login": {
"id": "6XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX3",
"created": "2017-10-14T19:49:51.000Z",
"email": "user@remote.it",
"language": "en",
"lastLogin": "2020-03-10T20:45:49.247Z",
"timezone": null
}
}
}

 

Login Information

Sample Login Query:

{
login {
id
email
}
}

Result:

{
"data": {
"login": {
"id": "A160E4CC-26C7-4EB6-9D1B-71210DCBCC31",
"email": "example@remote.it"
}
}
}

 

Device Information

Sample Device Query:

{
login {
devices {
total
items {
id
name
hardwareId
}
}
}
}

Result:

{
"data": {
"login": {
"devices": {
"total": 12,
"items": [
{
"id": "80:00:00:00:01:01:8e:ed",
"name": "bento",
"hardwareId": "dc:a6:32:19:8b:a3-xWoYf46uJ6QdtPXTloLb"
},
...

 

Get User Info

Sample User Info Query:

{
login {
id
created
email
language
lastLogin
}
}

Result:

{
"data": {
"login": {
"id": "Sample ID",
"created": "2019-12-20T22:13:46.000Z",
"email": "example@remote.it",
"language": "en",
"lastLogin": "2020-03-05T02:03:16.117Z"
}
}
}

 

Mutations

Sample Queries

Get the token (few ways to do it, this is one of them), a token is needed for all GraphQL queries.

curl -X POST https://api.remot3.it/apv/v27/user/login \
-H 'Content-Type: application/json' \
-H 'developerKey: ######################################' \
-d '{"username": "######@remote.it", "password": "######"}'

Result:

...
"token": "######################################",
...

Run a GraphQL query that shows email for the logged-in user and their Devices.

curl -X POST https://test.vpi.io/v1/graphql \
-H 'Content-Type: application/json' \
-H 'Host: test.vpi.io' \
-H 'token: ######################################' \
-d '{"query" :"{ login { email devices { name hardwareId } } }"}'

Result:

{
"data": {
"login": {
"email": "example@remote.it",
"devices": [
{
"name": "test-pi-node-001",
"hardwareId": "dd:b3:12:32:11:k0-KcsIJhp8LA2FXsWQpl9j"
}
]
}
}
}
Was this article helpful?
0 out of 0 found this helpful