A powerful command-line interface for managing Tyk APIs and configurations. Built to streamline API lifecycle management with OpenAPI Specification (OAS) support.
π View Complete Documentation | π Get Started | π‘ Examples
- π Interactive Setup Wizard - Get started quickly with guided configuration
- π Unified Config/Environment System - Named environments with seamless switching
- π OpenAPI First - Native support for OAS 3.0 specifications
- π§ Flexible Configuration - Environment variables, unified config file, or CLI flags
- π¨ Beautiful CLI - Colorful, intuitive command-line experience
- β Comprehensive Testing - >80% test coverage with live environment validation
- This CLI is designed to work with the licensed version of Tyk - via Control Plane.
# Add the Tyk tap
brew tap sedkis/tyk
# Install the CLI
brew install tyk
## Check version
$ tyk -v
tyk version 0.2.1
## UPGRADING the cli
$ brew update
$ brew upgrade tyk
## Check version
$ tyk -v
tyk version 0.2.1# Download and install the latest release
curl -L "https://github.com/sedkis/tyk-cli/releases/latest/download/tyk-cli_$(uname -s)_$(uname -m).tar.gz" | tar xz
sudo mv tyk /usr/local/bin/
# Verify installation
tyk --versiongit clone https://github.com/sedkis/tyk-cli.git
cd tyk-cli
go build -o tyk ./cmd/
sudo mv tyk /usr/local/bin/# Run the interactive setup wizard
tyk initπ‘ Need more help? Check out our complete documentation with detailed guides, examples, and troubleshooting tips!
# Interactive setup wizard
tyk init # Full setup wizard with multiple environments
# Environment management
tyk config list # List all environments
tyk config use # Switch environnment interactively
tyk config use staging # Switch to staging environment
tyk config current # Show current environment
tyk config set dashboard-url https://api.tyk.io # Update current environment# Quick API Creation
tyk api create --name "User Service" --upstream-url https://users.api.com
# Create from OpenAPI Spec Management
tyk api import-oas --file petstore.yaml # Import external OpenAPI spec
tyk api import-oas --url https://api.example.com/openapi.json # Import from URL
tyk api update-oas <api-id> --file new-spec.yaml # Update API's OpenAPI spec only
# Tyk-Enhanced OAS Management (GitOps)
# If the file contains x-tyk-api-gateway.info.id, apply will upsert:
# update if it exists, or create with the same ID if missing
tyk api apply --file enhanced-api.yaml # Idempotent upsert (update or create)
# General Operations
tyk api list # List all APIs
tyk api list -i # Interactive
tyk api get <api-id> # Get API details
tyk api get <api-id> --oas-only # Get OpenAPI spec only
tyk api delete <api-id> # Delete API (with confirmation)
tyk api delete <api-id> --yes # Delete without confirmation
# Utilities (Phase 3)
tyk api convert --file api.yaml --format apidef # Convert OAS to Tyk format# Scaffold a new policy file
tyk policy init --id gold --name "Gold Plan"
# List policies
tyk policy list # Paginated table
tyk policy list --json # JSON output
# Get a policy (outputs CLI-schema YAML)
tyk policy get <policy-id> # YAML to stdout, summary to stderr
tyk policy get <policy-id> --json # JSON output
# Apply a policy (idempotent upsert β creates or updates)
tyk policy apply -f policy.yaml # From file
tyk policy apply -f - # From stdin
# Delete a policy
tyk policy delete <policy-id> # Interactive confirmation
tyk policy delete <policy-id> --yes # Skip confirmationPolicies use a human-friendly CLI schema with readable durations (30d, 1h) and API selectors by name, listen path, or tags. The CLI converts to Dashboard wire format on apply. See the Policy Guide for the full YAML reference.
The Tyk CLI uses a unified environment/configuration system with the following precedence (highest to lowest):
- Command-line flags (
--dash-url,--auth-token,--org-id) - Environment variables (
TYK_DASH_URL,TYK_AUTH_TOKEN,TYK_ORG_ID) - Named environments in config file (
~/.config/tyk/cli.toml)
Each "environment" is simply a named set of configuration values.
export TYK_DASH_URL=http://localhost:3000
export TYK_AUTH_TOKEN=your-api-token
export TYK_ORG_ID=your-org-idConfiguration is automatically saved to ~/.config/tyk/cli.toml:
default_environment = "dev"
[environments.dev]
dashboard_url = "http://localhost:3000"
auth_token = "dev-api-token"
org_id = "dev-org-id"
[environments.staging]
dashboard_url = "https://staging.tyk.io"
auth_token = "staging-token"
org_id = "staging-org-id"
[environments.production]
dashboard_url = "https://api.yourcompany.com"
auth_token = "prod-token"
org_id = "prod-org-id"- Local Development:
http://localhost:3000(default) - Tyk Cloud:
https://admin.cloud.tyk.io - Self-hosted: Your custom domain
- Log into your Tyk Dashboard
- Go to Users β Your User Profile
- Find API Access Credentials
- Copy the Auth Token
- Found next to your API Token, in User Profile.
- Go 1.21+
- Make (optional)
# Clone the repository
git clone https://github.com/sedkis/tyk-cli.git
cd tyk-cli
# Install dependencies
go mod download
# Build the CLI
go build -o tyk ./cmd/
# Run tests
go test ./...
# Build with make (if available)
make build
make testtyk-cli/
βββ cmd/ # Entry point
βββ internal/ # Internal packages
β βββ cli/ # Cobra command definitions (api, policy, config)
β βββ config/ # Configuration management
β βββ client/ # HTTP client for Tyk Dashboard API
β βββ policy/ # Policy domain logic (duration, validation, selectors, conversion)
β βββ oas/ # OAS file handling
β βββ filehandler/ # File utilities
βββ pkg/types/ # Shared types (API, policy, config)
βββ test/ # Integration tests
βββ docs/ # Documentation (Jekyll site)
- Tyk API Tokens / Credentials
tyk api convert- Convert between OAS and Tyk API definition formats- Enhanced error handling and user experience improvements
- Advanced JSON output formatting
- API versioning commands (
versions list/create/switch-default) - API validation and linting
- GitOps diff functionality
We welcome contributions! Please see our Contributing Guide for details.
# Run tests
go test ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
# Lint code (if golangci-lint is installed)
golangci-lint run
# Format code
go fmt ./...This project is licensed under the MIT License.
- π Documentation: Complete Documentation
- π Getting Started: Installation & Setup Guide
- π Issues: GitHub Issues
- π¬ Community: Tyk Community Forum
Built with: