Skip to main content

RestAPI Terminal (RAT)

RestAPI Terminal (RAT) is a command-line interface for managing your RestAPI.com APIs. Distributed as a single-file binary, it enables deployment of web applications, schema management, and API operations from local environments or CI/CD pipelines.

Installation

Linux / macOS

wget ggcmd.io/gg.cmd
sh gg.cmd rat@1

Windows (PowerShell)

wget ggcmd.io -OutFile gg.cmd
.\gg.cmd rat@1

Versioning

Use @<version> syntax to specify a version. Omit to get the latest:

# Specific version
sh gg.cmd rat@1

# Latest version
sh gg.cmd rat

Help

rat help

Authentication

Login

Authenticate with your RestAPI.com account:

rat login

This opens a browser for OAuth authentication. Your credentials are stored securely in the system keyring.

Logout

rat logout

Command Structure

Commands follow a hierarchical structure:

rat [global-options] <command> [subcommand] [options]

Global Options

OptionDescription
-v, --verboseIncrease verbosity level
-w, --log-moreEnable detailed logging
-j, --jsonOutput as JSON (default is human-readable tables)

Tenant Commands

List Tenants

rat tenant list

API Commands

List APIs

rat api list --tenant <tenant-name>

Show API Details

rat api -a my-api show

Create API

rat api create --tenant my-tenant --name my-new-api --description "My API"

Delete API

rat api -a my-api delete

Schema Management

Get Schema

Download the current schema to schema.json:

rat api -a my-api schema get

Update Schema

Apply schema changes from a file:

rat api -a my-api schema update --prevent-breaking true

Use --prevent-breaking false to allow breaking changes (deletions, renames).

Validate Schema

Check schema without applying:

rat api -a my-api schema validate --prevent-breaking true

Deployment

Deploy Everything

Deploy webapp, schema, and triggers in one command:

rat api -a my-api deploy

Default paths:

  • Webapp: dist/
  • Schema: schema.json
  • Triggers: triggers/*.*

Custom paths:

rat api -a my-api deploy --dist build --schema api-schema.json --triggers functions/*.*

Options:

OptionDescription
--prevent-breakingPrevent breaking schema changes (default: true)
--no-zipDon't zip webapp files
--dry-runShow what would be deployed

Pull from API

Download schema and triggers from your API:

rat api -a my-api pull

Upload Webapp Files

rat api upload -a my-api ./dist --zip

Options:

OptionDescription
-r, --relative-fromControl directory structure
-d, --delete-allDelete existing files first
-z, --zipZip before upload (faster)

Virtual File System (VFS)

List Files

rat api -a my-api vfs list "**/*"

Upload Files

rat api -a my-api vfs upload "src/**/*.js" --base-path /scripts

Download Files

rat api -a my-api vfs download "logs/**/*.log" --output ./logs

Delete Files

rat api -a my-api vfs delete "tmp/**/*"

Triggers (Functions)

List Triggers

rat api -a my-api trigger list

Show Trigger

rat api -a my-api trigger show --trigger <trigger-id>

Upload Trigger Code

rat api -a my-api trigger file --trigger <id> upload --file handler.js

Invoke Trigger

Test a trigger with input data:

rat api -a my-api trigger invoke --trigger <id> --file test-input.json

Local Code Execution

Run JavaScript/TypeScript locally with API context:

Run a File

rat run script.js

Run with API Context

rat run script.ts --api my-api

This provides access to:

  • API tokens and secrets
  • Built-in HTTP methods (get, post, put, patch, del)
  • User context

Run with Trigger Config

Load configuration from an existing trigger:

rat run --api my-api --trigger my-trigger script.js

Run with Item Data

Fetch an item as input:

rat run --api my-api --collection products --item <item-id> handler.js

Run Inline Code

rat run --code "console.log('Hello from rat!')"

Development Server

Start a local development server:

rat dev-server --web-app my-api

Options:

OptionDescription
-w, --web-appAPI path from portal
-l, --listening-portPort (default: 4000)
rat dev-server -w my-api -l 3000 ./src

User Management

List Users

rat api -a my-api user list

Generate User Token

rat api -a my-api user token --user <user-id>

Options:

OptionDescription
--skip-security-policySkip security policy validation
--skip-rolesSkip role validation
--skip-cascadeSkip cascade validation

Service Accounts

List Service Accounts

rat api -a my-api service-account list

Create Service Account

rat api -a my-api service-account create

Manage Secrets

rat api -a my-api service-account secret --client-id <id> list
rat api -a my-api service-account secret --client-id <id> create

Roles

List Roles

rat api -a my-api role list

Manage Role Members

rat api -a my-api role member --role <id> list
rat api -a my-api role member --role <id> add --user <user-id>
rat api -a my-api role member --role <id> remove --user <user-id>

Secrets

List Secrets

rat api -a my-api secret list

Create Secret

rat api -a my-api secret create --key STRIPE_API_KEY --value sk_live_xxx

Delete Secret

rat api -a my-api secret delete --key STRIPE_API_KEY

Settings

List Settings

rat api -a my-api setting list

Jobs

List Jobs

rat api -a my-api job list

Start/Cancel Jobs

rat api -a my-api job start --job <id>
rat api -a my-api job cancel --job <id>

Data Export

Export as JSON

rat api -a my-api export json

Export as Blob

rat api -a my-api export blob

Billing

View Usage

rat api -a my-api billing usage
rat api -a my-api billing metrics

CI/CD Integration

For automated deployments, use service account credentials via environment variables:

VariableDescription
RAT_CLIENT_IDService account client ID
RAT_CLIENT_SECRETService account secret

GitHub Actions Example

name: Deploy API

on:
push:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install rat
run: |
wget ggcmd.io/gg.cmd
sh gg.cmd rat@1

- name: Deploy
env:
RAT_CLIENT_ID: ${{ secrets.RAT_CLIENT_ID }}
RAT_CLIENT_SECRET: ${{ secrets.RAT_CLIENT_SECRET }}
run: |
rat api -a my-api deploy --dry-run
rat api -a my-api deploy

Simple Upload

For basic webapp deployment in CI/CD:

./gg.cmd rat@1 upload -a <api-name-or-id> <directory>

Output Formats

By default, rat outputs human-readable tables. Use --json for machine-readable output:

# Table format (default)
rat api list --tenant my-tenant

# JSON format
rat api list --tenant my-tenant --json

Tips

  • Use -a shorthand for --api in most commands
  • The --dry-run flag shows what would happen without making changes
  • Combine with jq for JSON processing: rat api list -j | jq '.[] | .name'
  • Store API name in environment: export RAT_API=my-api