Connecting to a Device

post
Connect to a device

https://api.remot3.it/apv/v27/device/connect
Create a connection to a device.
Request
Response
Headers
developerkey
required
string
Your developer key which can be found by logging into remote.it and going to your "Account" settings page.
token
required
string
Your session token, created by logging in using the API.
Body Parameters
deviceaddress
required
string
The service address (e.g. service ID) for the device you'd like to connect to
wait
required
boolean
Whether to wait for the connection or not. Should be set to "true"
hostip
required
string
The clients public IP address, which is used to enforce "IP restriction" upon making the connection. Defaults to the IP address of the the API caller if not provided. Pass "0.0.0.0" if you want any IP address to connect (warning: this is potentially insecure if your resource is not itself secured properly!)
200: OK
Connection with device successfully created.
{
"connection": {
"deviceaddress": "80:00:00:00:00:00:00:91",
"expirationsec": "28797",
"proxy": "https://xppoobalo.p18.rt3.io"
"connectionid":"A78B3919-52E1-B674-58CC-5C0009377419"
},
"status": "true"
}

For http and https remote.it Services, the returned value for "proxy" will be a single string similar to the following. It does not need an explicit port value to be used.

"proxy": "https://xprbjalo.p18.rt3.io"

For all other types of remote.it Services, the returned value for "proxy" will include a hostname and a port value separated by a colon, as shown:

"proxy": "http:\/\/proxy18.rt3.io:38575"

The value returned for "connectionid" can be used with the /device/connect/stop API endpoint to terminate the proxy connection to your target when you are done using it.

Note Some response values are omitted from the example above because they are only used in very specific circumstances.

Usage Examples

cURL
Node (JavaScript)
Python
C#
PHP
#!/bin/sh
TOKEN="your_login_token"
DEV_KEY="your_developer_key"
DEVICE_ADDRESS="your_service_id"
HOSTIP="your_public_ip"
curl -X POST \
-H "token:$TOKEN" \
-H "developerkey:$DEV_KEY" \
-d "{\"wait\":\"true\",\"deviceaddress\":\"$DEVICE_ADDRESS\", \
\"hostip\":\"$HOSTIP\" }" \
https://api.remot3.it/apv/v27/device/connect
const axios = require("axios");
const developerkey = process.env.REMOTEIT_DEVELOPER_KEY;
const token = process.env.REMOTEIT_TOKEN;
const deviceaddress = process.env.REMOTEIT_DEVICE_ADDRESS;
const hostip = process.env.MY_PUBLIC_IP;
const wait = "true";
axios
.post(
"https://api.remot3.it/apv/v27/device/connect",
{
deviceaddress,
wait,
hostip
},
{
headers: {
developerkey,
token
}
}
)
.then(response => {
console.log("Status Code:", response.status);
console.log("Body:", response.data);
})
.catch(error => {
console.log(error);
});
import requests
import json
import os
headers = {
"developerkey": os.environ["REMOTEIT_DEVELOPER_KEY"],
# Created using the login API
"token": os.environ["REMOTEIT_TOKEN"]
}
body = {
"deviceaddress": "80:00:00:3F:AE:00:00:11",
"wait":"true",
"hostip":os.environ["MY_PUBLIC_IP"]
}
url = "https://api.remot3.it/apv/v27/device/connect"
response = requests.post(url, data=json.dumps(body), headers=headers)
response_body = response.json()
print("Status Code: %s" % response.status_code)
print("Raw Response: %s" % response.raw)
print("Body: %s" % response_body)
using System;
using System.Net.Http;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace remote.it_api_example
{
class Program
{
static void Main(string[] args)
{
string jsonString = "";
string url = "https://api.remot3.it/apv/v27/device/connect";
HttpClient client = new HttpClient();
HttpRequestMessage requestData = new HttpRequestMessage();
// Configure the HTTP requests's url, headers, and body
requestData.Method = HttpMethod.Post;
requestData.RequestUri = new Uri(url);
requestData.Headers.Add("developerkey", Environment.GetEnvironmentVariable("REMOTEIT_DEVELOPER_KEY"));
requestData.Headers.Add("token", Environment.GetEnvironmentVariable("REMOTEIT_TOKEN"));
Dictionary<string, string> bodyData = new Dictionary<string, string>() {
{
"deviceaddress", Environment.GetEnvironmentVariable("REMOTEIT_DEVICE_ADDRESS"),
"wait", "true",
"hostip", Environment.GetEnvironmentVariable["MY_PUBLIC_IP"]
}
};
string jsonFormattedBody = JsonConvert.SerializeObject(bodyData);
requestData.Content = new StringContent(jsonFormattedBody);
try
{
// Send the HTTP request and run the inner block upon recieveing a response
var response = client.SendAsync(requestData).ContinueWith((taskMessage) =>
{
var result = taskMessage.Result;
var jsonTask = result.Content.ReadAsStringAsync();
jsonTask.Wait();
// Store the body of API response
jsonString = jsonTask.Result;
});
response.Wait();
}
catch (HttpRequestException e)
{
// Triggered when the API returns a non-200 response code
jsonString = e.Message;
}
// Print JSON response from API
Console.WriteLine(jsonString);
}
}
}
<?php
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => "https://api.remot3.it/apv/v27/device/connect",
CURLOPT_HTTPHEADER => array(
"developerkey: ".$_ENV["REMOTEIT_DEVELOPER_KEY"],
"token: ".$_ENV["REMOTEIT_TOKEN"] // Created using the login API
),
CURLOPT_POSTFIELDS => json_encode(array(
"deviceaddress" => $_ENV["REMOTEIT_DEVICE_ADDRESS"],
"wait" => true,
"hostip" => $_ENV["MY_PUBLIC_IP"]
)),
CURLOPT_RETURNTRANSFER => true
));
$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
print("Status Code: ".$statusCode."\n");
$responseData = json_decode($response);
print_r($responseData);
?>