0

Hi guys i have Teamviewer installed and would like to be able to ping Teamviewer ID's and get a response of the status of that PC.

try
{
    string accessToken = "xxxxxxxxxxxxxxxxxxxx";
    string Version = "v1";
    string tvApiUrl = "https://webapi.teamviewer.com";
    string address = tvApiUrl + "/api/" + Version + "/various commands from API";
    HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
    request.Headers.Set("Authorization", "Bearer " + accessToken);
    request.Method = "GET";
    WebResponse response = request.GetResponse();
    return response;
}
catch (Exception ex) 
{
    MessageBox.Show("Failed to get request with error: " + ex.Message);
    return null;
}

this wont work because I haven't found anything related to the remote list of computers i have in Teamviewer. I want a way to check if the PC's in my Teamviewer list have internet programmatically. Thanks in advance

Scis
  • 2,934
  • 3
  • 23
  • 37
Chris
  • 11
  • 1
  • 3
  • 1
    Wouldn't that be a huge security flaw unless provided via TV's API? – Thierry Aug 12 '14 at 16:01
  • why would it be a security flaw when u are able to connect to that specific Teamviewer ID when all you want is just ping it? – Chris Aug 12 '14 at 16:07
  • i have also tried using this: ./teamviewer.exe -I -P -m but this will be heavy when u have 100 ID's to check! if there would have been a mode like 'Ping' it would have been perfect. – Chris Aug 13 '14 at 10:50

1 Answers1

1

This can be achieved using the TeamViewer API.

Have a look at the documentation under "3.10 Devices":

GET /api/v1/devices (list all devices from the computers & contacts list)

  • Parameters

    • online_state (optional) – Return only devices with the given online_state.
    • groupid (optional) – Return only contacts that are in the specified group.
  • Return values

    • device_id – The ID that is unique for this entry of the computers & contacts list. Values are always prefixed with a d.
    • remotecontrol_id – The ID that is unique to this device and can be used to start a remote control session.
    • groupid – The ID of the group that this device is a member of.
    • alias – The alias that the current user has given to this device.
    • description – The description that the current user has entered for this device.
    • online_state – The current online state of the device. Possible values are: online, offline.
  • Authentication

    • User access token. Scope: ContactList.Read.
  • Description
    • Returns a list of devices in the user’s computers & contacts list.
  • Example

Request

GET /api/v1/devices

Response

HTTP/1.1 200 OK  
   Content-Type: application/json 
 { "devices": [  
      {  
          "remotecontrol_id": "r123456789",  
          "device_id": "d123456789",  
          "alias": "PC",  
          "groupid": "g12345678",  
          "online_state": "Online"  
      },  
      {  
          "remotecontrol_id": "r123456780",  
          "device_id": "d345667567",  
          "alias": "Laptop",  
          "groupid": "g12345678",  
          "online_state": "Offline" 
      },  
      {  
          "remotecontrol_id": "r345678890",  
          "device_id": "d444443226",  
          "alias": "Office",  
          "groupid": "g12345678",  
          "online_state": "Offline" 
      }  
   ] 
}
Baris Akar
  • 4,895
  • 1
  • 26
  • 54
  • thanks for the answer and sorry for my late response. I decided not to use teamviewers API though so i wrote something that does the job. – Chris Aug 20 '15 at 06:06
  • this is not a c# code like the code posted in original question. – luka Sep 27 '21 at 12:36