@api-client/cli
v1.0.4
Published
API Now! CLI
Readme
API NOW! CLI
The API NOW! CLI is a robust, cross-platform command-line tool designed to manage settings, handle authentication, organize directories/files, and publish assets directly to the Data Catalog from your terminal.
Features
- OAuth2 Loopback Authentication: Authenticate using your Google, GitHub, or LinkedIn accounts.
- Interactive Onboarding: Guided setup prompts for first-time users to configure organization names and slugs (validated against reserved keywords/taken values).
- Default Organization Management: List organizations and pin a default workspace ID.
- Metadata and Media Uploads: Create, list, and read blueprints, domains, and multimedia assets.
- Data Catalog Publishing: Publish schemas and datasets to the global/private catalog with automatic semantic versioning support.
- Developer Formatting Options: Toggle outputs between human-friendly ASCII tables and machine-readable JSON.
Installation
Install the CLI globally from npm:
npm install -g @api-client/cliOnce installed, the CLI is available as the apinow command.
Usage & Commands
All commands support the following global options:
--api-url <url>: Override the target API Server URL (Default:http://localhost:8080). Note that the platform is actively under development and the final default URL will be set once the platform is officially released.--format <text|json>: Define the output layout (Default:text).
1. Configuration (config)
Read and write persistent CLI configurations stored in the OS settings folder depending on the platform:
- Linux:
~/.config/apinow-cli/config.json(or respects$XDG_CONFIG_HOME) - macOS:
~/Library/Preferences/apinow-cli/config.json - Windows:
%APPDATA%\apinow-cli\config.json
# Get a configuration property (e.g. apiUrl, defaultOrg)
apinow config get <key>
# Set a configuration property
apinow config set <key> <value>2. Authentication (auth)
Securely log in to the API platform using OAuth2.
# Log in using Google, GitHub, or LinkedIn
apinow auth login <google|github|linkedin>
# Verify current authentication status and user identity details
apinow auth status
# Log out and erase stored authentication tokens
apinow auth logoutNote: On your first login or checking status with no registered organization, an interactive step will automatically guide you through creating your first organization with live slug verification.
Personal Access Tokens (auth tokens)
Generate and manage Personal Access Tokens (PATs) for programmatic access.
# List all personal access tokens
apinow auth tokens list
# Create a new personal access token
apinow auth tokens create [--name <token_name>] [--expires-at <duration_or_timestamp>]
Example:
apinow auth tokens create --name "Test Token" --expires-at "30 days"
# Delete a personal access token by its ID
apinow auth tokens delete <token_id>3. Organizations (orgs)
Manage organization contexts.
# List all organizations you belong to
apinow orgs list
# Get the default configured organization
apinow orgs get-default
# Set default organization to avoid passing --org CLI parameters
apinow orgs set-default <organization_id>4. Files (files)
Manage domain and API files in your organizations.
# List files with optional filters
apinow files list --org <org_id> --parent <parent_id> --kind <domain|api>
# Create file metadata and upload local media
apinow files create --name "My Domain File" --kind "domain" --org <org_id> --parent <parent_id> --media ./path/to/schema.ts
# Create file metadata and pipe media contents from STDIN
echo '{"schema": "content"}' | apinow files create --name "My Piped File" --kind "api" --org <org_id> --stdin
# Read file metadata (default) or media content (--media)
apinow files read --id <file_id> --org <org_id> [--media]5. Data Catalog (catalog)
Publish and browse published catalog items.
# Publish a local data domain file to the catalog
apinow catalog publish --file <file_id> --name "Catalog Name" --description "Catalog Description" --scope public --catalog-version 1.0.0
# List all published data domains in the catalog
apinow catalog list --scope <all|public|organization|private> [--key <domain_key>]Development
Local Setup & Building
Clone the repository and install dependencies:
npm installBuild the package:
npm run buildRun the CLI locally:
# Run directly via tsx (Development) npm run dev -- [command] # Or execute the compiled build node dist/index.js [command]
Formatting and Linting
To format the source code with Prettier:
npm run formatTo run the ESLint static code analysis checks:
npm run lintType Checking
To run the TypeScript compiler in dry-run mode:
npm run typecheck