Getting Started with the ShellHub API using Shell Script

Terminal using ShellHub API with OpenAPI 0.19.0 for secure, automated remote device access.
ShellHub now supports OpenAPI, making it easier to explore, integrate, and automate remote device management via its robust API.

The ShellHub API allows you to programmatically interact with your devices, users, and sessions. If you’re comfortable with the command line and want a quick way to explore what the API can do, using a simple Shell Script is a great starting point.

In this guide, we’ll show how to authenticate with an API Key and fetch your list of devices.

Prerequisites

  • A ShellHub account
  • A valid API Key (Learn how to generate one here)
  • curl and jq installed on your system
Tip: Storing your API Key in an environment variable is a safer practice than hardcoding it into scripts.

Example Script

Here’s a minimal script to get started:

#!/bin/bash

# ShellHub API URL
API_URL="https://cloud.shellhub.io/api"

# Your API Key stored in an environment variable
API_KEY="${SHELLHUB_API_KEY}"

# Fetch devices
echo "Fetching devices..."
curl -s -X GET "$API_URL/devices" \
  -H "X-API-Key: $API_KEY" \
  -H "Content-Type: application/json" | jq

This script will retrieve and list all devices in your namespace.

Next Steps

This is just the beginning. With the ShellHub API, you can:

  • Create and manage sessions
  • Add or remove devices
  • Automate workflows and integrations

Check out the full ShellHub API documentation to discover all available endpoints and start building your own integrations.