Skip to content

CLI Reference

Anes Berbic edited this page Mar 13, 2026 · 1 revision

CLI Reference

The apiark CLI lets you run collections, import/export data, and integrate with CI/CD pipelines — all from the command line.


Installation

From Release Binary

Download the pre-built binary from GitHub Releases:

Platform Binary
Linux x86_64 apiark-cli-linux-x86_64
macOS ARM apiark-cli-macos-arm64
macOS Intel apiark-cli-macos-x86_64
Windows apiark-cli-windows-x86_64.exe
# Linux/macOS
chmod +x apiark-cli-*
sudo mv apiark-cli-* /usr/local/bin/apiark

From Source

cd apps/cli
cargo build --release
# Binary at: target/release/apiark

Commands

apiark run

Run a collection and execute all tests/assertions.

# Run entire collection
apiark run ./my-collection

# Run a specific folder
apiark run ./my-collection/users

# Run a single request
apiark run ./my-collection/users/get-all-users.yaml

# With environment
apiark run ./my-collection --env production

# With data file (data-driven testing)
apiark run ./my-collection --data test-data.csv

# Multiple iterations
apiark run ./my-collection --iterations 5

# Delay between requests (ms)
apiark run ./my-collection --delay 500

# Stop on first failure
apiark run ./my-collection --bail

Reporter Options

# JSON output (default)
apiark run ./my-collection --reporter json

# JUnit XML (for CI/CD)
apiark run ./my-collection --reporter junit --output results.xml

# HTML report
apiark run ./my-collection --reporter html --output report.html

# Write to file
apiark run ./my-collection --reporter json --output results.json

apiark import

Import collections from other API tools.

# Auto-detect format
apiark import collection.json

# Specify format explicitly
apiark import collection.json --format postman
apiark import workspace.json --format insomnia
apiark import api-spec.yaml --format openapi
apiark import collection.bru --format bruno
apiark import requests.har --format har
apiark import collection.json --format hoppscotch

# Specify output directory
apiark import collection.json --output ./my-project

# Import from cURL
apiark import --curl 'curl -X GET https://api.example.com/users -H "Authorization: Bearer token"'

apiark export

Export collections to other formats.

# Export to Postman format
apiark export ./my-collection --format postman --output postman-collection.json

# Export to OpenAPI
apiark export ./my-collection --format openapi --output api-spec.yaml

# Export to cURL (all requests)
apiark export ./my-collection --format curl

apiark lint

Lint your collection for issues.

apiark lint ./my-collection
# Checks for: missing URLs, invalid YAML, unused variables, etc.

apiark mock

Start a mock server from a collection.

# Start on default port (4000)
apiark mock ./my-collection

# Custom port
apiark mock ./my-collection --port 8080

# With CORS disabled
apiark mock ./my-collection --no-cors

Exit Codes

Code Meaning
0 All tests passed
1 One or more tests failed
2 Collection/file not found
3 Invalid configuration
4 Network error

CI/CD Integration

GitHub Actions

name: API Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Download ApiArk CLI
        run: |
          curl -L -o apiark https://github.com/berbicanes/apiark/releases/latest/download/apiark-cli-linux-x86_64
          chmod +x apiark

      - name: Run API tests
        run: ./apiark run ./tests/api-collection --env ci --reporter junit --output results.xml

      - name: Upload test results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: api-test-results
          path: results.xml

GitLab CI

api-tests:
  stage: test
  script:
    - curl -L -o apiark https://github.com/berbicanes/apiark/releases/latest/download/apiark-cli-linux-x86_64
    - chmod +x apiark
    - ./apiark run ./tests/api-collection --env ci --reporter junit --output results.xml
  artifacts:
    reports:
      junit: results.xml

Jenkins

pipeline {
    agent any
    stages {
        stage('API Tests') {
            steps {
                sh 'curl -L -o apiark https://github.com/berbicanes/apiark/releases/latest/download/apiark-cli-linux-x86_64'
                sh 'chmod +x apiark'
                sh './apiark run ./tests/api-collection --env ci --reporter junit --output results.xml'
            }
            post {
                always {
                    junit 'results.xml'
                }
            }
        }
    }
}

Environment Variables

The CLI respects environment variables for configuration:

# Set environment via env var
APIARK_ENV=production apiark run ./my-collection

# Verbose output
APIARK_LOG=debug apiark run ./my-collection

# Custom timeout (ms)
APIARK_TIMEOUT=30000 apiark run ./my-collection

Tips

  • Use --reporter junit in CI/CD for test result integration
  • Use --bail to fail fast in CI pipelines
  • Use --data for parametrized testing across environments
  • The CLI uses the same Rust HTTP engine as the desktop app — identical behavior

Clone this wiki locally