WebShell API Documentation

Learn how to use the WebShell API to execute commands programmatically.

Overview

The WebShell API allows you to execute Fedora commands programmatically through HTTP POST requests. This API is designed to interact with a web-based Fedora terminal, enabling you to run commands and retrieve their output in a structured format.

Base URL

https://web-terminal-eight.vercel.app

Endpoints

1. Run Command

Endpoint: /run

Method: POST

Content-Type: application/json

Description

This endpoint allows you to execute a Fedora command in the WebShell terminal. The command is provided as a JSON payload, and the API returns the output of the command.

Request

URL:

https://web-terminal-eight.vercel.app/run

Headers:

Content-Type: application/json

Body:

{
  "command": "your-command-here"
}

Replace "your-command-here" with the actual command you wish to run.

Example Request

To list files and directories in the current directory, you would use the following curl command:

curl -X POST https://web-terminal-eight.vercel.app/run \
  -H "Content-Type: application/json" \
  -d '{"command": "ls -l"}'

Response

The response will be a JSON object with the following structure:

{
  "stdout": "command output here",
  "stderr": "error output here",
  "exitCode": exit_code
}

Example Response

For the command ls -l, you might receive:

{
  "stdout": "total 2\ndrwxr-xr-x 67 root root 1187 Jul 27 00:36 node_modules\n-rwxr-xr-x  1 root root  303 Oct 20  2018 package.json\n-rwxr-xr-x  1 root root  753 Oct 20  2018 server.js\n"
}

Error Handling

Examples

Example 1: Listing Files

curl -X POST https://web-terminal-eight.vercel.app/run \
  -H "Content-Type: application/json" \
  -d '{"command": "ls -l"}'

Example 2: Viewing Disk Usage

curl -X POST https://web-terminal-eight.vercel.app/run \
  -H "Content-Type: application/json" \
  -d '{"command": "df -h"}'

Notes