Documentation

Home/Documentation/Documentation

id: cli-getting-started-guide sidebar_label: CLI Getting Started

CLI Getting Started Guide

The Apito CLI is a powerful command-line tool that allows you to create, manage, and deploy GraphQL and REST API projects from your terminal. This open source tool streamlines your development workflow and enables rapid API building with our API builder platform.

Installation

npm install -g @apito/cli

Install via curl

curl -fsSL https://get.apito.io/install.sh | bash

Verify Installation

apito --version

You should see the installed version of the Apito CLI.

Quick Start

1. Login to Apito

First, authenticate with your Apito account:

apito login

This will open your browser to authenticate with your Apito account. Once authenticated, you’ll be able to create and manage projects from the command line.

2. Create a New Project

Create a new API builder project:

apito create my-project

This command will:

  • Create a new project in your Apito workspace
  • Set up the project structure
  • Initialize both GraphQL and REST API endpoints
  • Configure the open source CMS components

3. Navigate to Your Project

cd my-project

4. Start Development Server

Launch the local development environment:

apito dev

This will start a local development server where you can:

  • Test your GraphQL queries and mutations
  • Explore REST API endpoints
  • Manage content through the open source CMS interface
  • View real-time changes as you develop

Core Commands

Project Management

# List all your projects
apito projects

# Get project details
apito project info

# Switch between projects
apito project switch <project-id>

Database Operations

# Connect to a database
apito db connect <connection-string>

# Generate API from existing database
apito db generate-api

# Run database migrations
apito db migrate

# Seed the database with sample data
apito db seed

API Development

# Generate GraphQL schema from models
apito generate schema

# Create new API endpoints
apito create endpoint <endpoint-name>

# Deploy API changes
apito deploy

Content Management

# Import content from external sources
apito content import <source>

# Export content for backup
apito content export

# Sync content between environments
apito content sync

Configuration

Project Configuration

Your project includes a apito.config.js file for configuration:

module.exports = {
  project: {
    name: 'my-project',
    version: '1.0.0'
  },
  database: {
    provider: 'postgresql',
    url: process.env.DATABASE_URL
  },
  api: {
    graphql: {
      playground: true,
      introspection: true
    },
    rest: {
      swagger: true,
      cors: true
    }
  },
  cms: {
    media: {
      provider: 'local',
      maxSize: '10MB'
    }
  }
}

Environment Variables

Create a .env file in your project root:

# Database Configuration
DATABASE_URL=postgresql://user:password@localhost:5432/mydb

# API Configuration
API_SECRET=your-api-secret
JWT_SECRET=your-jwt-secret

# Media Storage
CLOUDINARY_URL=your-cloudinary-url
AWS_ACCESS_KEY_ID=your-aws-key
AWS_SECRET_ACCESS_KEY=your-aws-secret

Deployment

Deploy to Apito Cloud

# Deploy your project to Apito Cloud
apito deploy --production

Deploy to Custom Infrastructure

# Generate deployment files
apito generate deployment

# Deploy with Docker
docker build -t my-apito-app .
docker run -p 4000:4000 my-apito-app

Advanced Features

Plugin Development

# Create a new plugin
apito plugin create <plugin-name>

# Install community plugins
apito plugin install <plugin-name>

# List installed plugins
apito plugin list

API Testing

# Run API tests
apito test

# Generate test coverage report
apito test --coverage

# Run specific test suites
apito test --suite=integration

Monitoring and Logs

# View project logs
apito logs

# Monitor API performance
apito monitor

# Get project analytics
apito analytics

Troubleshooting

Common Issues

Authentication Problems:

# Re-authenticate
apito logout
apito login

Database Connection Issues:

# Test database connection
apito db test-connection

# Reset database configuration
apito db reset

Build Errors:

# Clear build cache
apito clean

# Rebuild project
apito build --force

Getting Help

# Show help for any command
apito help <command>

# Show all available commands
apito --help

# Get detailed command documentation
apito <command> --help

Next Steps

Now that you have the Apito CLI installed and configured:

  1. Explore the API Explorer - Use apito dev to start the development server and explore your GraphQL and REST API endpoints
  2. Build Your First Model - Create database models that automatically generate API endpoints
  3. Deploy Your Project - Use apito deploy to make your API builder project live
  4. Join the Community - Connect with other developers using our open source platform

For more detailed documentation, visit our GitHub repository or explore the other documentation sections in this guide.

:::tip The Apito CLI is continuously updated with new features. Keep your CLI updated by running npm update -g @apito/cli regularly. :::