API Wiki

Introduction

To start things off, you will need a key. To generate a key, use /api-key within Discord-Linux. The key will then be sent to your Direct Messages. Keys will be valid for 365 days.

API URL: https://api.ssh.surf

You must supply an authentication header using the key: x-ssh-auth containing the value of your token.

Keep an eye on this page, new methods will be added over time.

Please see the below examples using UniRest: https://www.npmjs.com/package/unirest

GET /hello


This API Method allows you to test and ensure the correct user is in use.

Example:

var unirest = require('unirest');
unirest
  .get('https://api.ssh.surf/hello')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{ message: 'Hello, SSH65165165165261652!' }

GET /name


This API Method allows you to get the username without the hello message.

Example:

var unirest = require('unirest');
unirest
  .get('https://api.ssh.surf/name')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{ success: true, message: 'SSH42113405732790' }

GET /start (Action)


This API Method allows you to start your container.

Example:

var unirest = require('unirest');
unirest
  .get('https://api.ssh.surf/start')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{ success: true, message: 'Container started successfully' }

GET /stop (Action)


This API Method allows you to stop your container.

Example:

var unirest = require('unirest');
unirest
  .get('https://api.ssh.surf/stop')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{ success: true, message: 'Container stopped successfully' }

GET /restart (Action)


This API Method allows you to restart your container.

Example:

var unirest = require('unirest');
unirest
  .get('https://api.ssh.surf/restart')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{ success: true, message: 'Container restarted successfully' }

GET /info


This API method will allow you to get information about your container.

Example:

var unirest = require('unirest');
unirest
  .get('https://api.ssh.surf/info')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{
  success: true,
  data: {
    name: 'SSH42113405732790',
    IPAddress: '172.25.0.7',
    MacAddress: '02:42:ac:19:00:07',
    memory: '8 GB',
    cpus: '8',
    restartPolicy: { Name: 'always', MaximumRetryCount: 0 },
    restarts: 0,
    state: {
      Status: 'running',
      Running: true,
      Paused: false,
      Restarting: false,
      OOMKilled: false,
      Dead: false,
      Pid: 2455731,
      ExitCode: 0,
      Error: '',
      StartedAt: '2024-05-05T21:56:03.922346494Z',
      FinishedAt: '2024-05-05T21:56:03.207724771Z'
    },
    created: '2024-05-05T20:17:28.288279722Z',
    image: 'sha256:d587e06c9123337b2e5b54be44ef0f361e2d3517a8eddbea0e6f2ec2f64f0004'
  }
}

GET /stats


This API method will allow you to get resource usage stats about your container.

Example:

var unirest = require('unirest');
unirest
  .get('https://api.ssh.surf/stats')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{
  success: true,
  data: {
    container: 'SSH42113405732790',
    memory: { raw: '497.3MiB / 7.906GiB', percent: '6.14%' },
    cpu: '1.73%'
  }
}

GET /time


This API method will allow you to get information about the expire time of your container.

Example:

var unirest = require('unirest');
unirest
  .get('https://api.ssh.surf/time')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{ success: true, expireDate: '5/12/2024' }

GET /rootpass (Action)


This API method will change the root password of your container to a random generated password.

Example:

var unirest = require('unirest');
unirest
  .get('https://api.ssh.surf/rootpass')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{
  success: true,
  message: 'Root password set successfully',
  newRootPass: 'JvE403Lh9U'
}

GET /new-key (Action)


This API method will generate a new API key for your account.

Example:

var unirest = require('unirest');
unirest
  .get('https://api.ssh.surf/new-key')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{
  success: true,
  message: 'New API key generated successfully',
  newAPIKey: 'keyhere'
}

GET /key-time


This API method will check the time left until the key expires.

Example:

var unirest = require('unirest');
unirest
  .get('https://api.ssh.surf/key-time')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{
  success: true,
  keyexpireString: 'Sun May 12 2024 17:29:39 GMT-0400 (Eastern Daylight Time)',
  expireDate: '2024-05-12T21:29:39.000Z',
  expireEpoc: 1715549379000
}

POST /exec (Action)


This API Method allows you to run commands in your container where you can specify the working directory used.

JSON Payload:

{"cmd": "commandhere", "pwd": "/working/directory/here"}

Example:

var unirest = require('unirest');
unirest
  .post('https://api.ssh.surf/exec')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .send({"cmd": "pwd; echo test", "pwd": "/home"})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{
  success: true,
  message: 'Command executed successfully',
  stdout: '/home\ntest\n',
  stderr: null
}

POST /notify (Action)


This API Method allows you to send notifications to your DiscordID as a Direct Message.

JSON Payload:

{"message": "Hello There, This is a test!\nDid this work?"}

Example:

var unirest = require('unirest');
unirest
  .post('https://api.ssh.surf/notify')
  .headers({'Accept': 'application/json', 'Content-Type': 'application/json',
  'x-ssh-auth': 'YOURTOKENHERE'})
  .send({"message": "Hello There, This is a test!\nDid this work?"})
  .then((response) => {
    console.log(response.body)
  })

Response:

[user@test ~]# node test
{ success: true, message: 'Notification sent successfully' }

API Example Screenshot