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
| Option | Description |
|---|---|
-v, --verbose | Increase verbosity level |
-w, --log-more | Enable detailed logging |
-j, --json | Output 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:
| Option | Description |
|---|---|
--prevent-breaking | Prevent breaking schema changes (default: true) |
--no-zip | Don't zip webapp files |
--dry-run | Show 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:
| Option | Description |
|---|---|
-r, --relative-from | Control directory structure |
-d, --delete-all | Delete existing files first |
-z, --zip | Zip 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:
| Option | Description |
|---|---|
-w, --web-app | API path from portal |
-l, --listening-port | Port (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:
| Option | Description |
|---|---|
--skip-security-policy | Skip security policy validation |
--skip-roles | Skip role validation |
--skip-cascade | Skip 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:
| Variable | Description |
|---|---|
RAT_CLIENT_ID | Service account client ID |
RAT_CLIENT_SECRET | Service 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
-ashorthand for--apiin most commands - The
--dry-runflag shows what would happen without making changes - Combine with
jqfor JSON processing:rat api list -j | jq '.[] | .name' - Store API name in environment:
export RAT_API=my-api