DEV Community

Cover image for Stop writing API test scripts. Use plain English instead.
Mikołaj Badyl
Mikołaj Badyl

Posted on

Stop writing API test scripts. Use plain English instead.

Writing API tests is tedious. You either click through Postman manually, write JavaScript test scripts, or wrestle with curl flags you forget every time.

I built Octrafic to fix that - you describe what you want tested in plain English, and the AI handles the rest. This is a quick guide on how to actually use it.

Installation

Single binary, no runtime dependencies.

# Linux/macOS
curl -fsSL https://octrafic.com/install.sh | bash

# Homebrew
brew install octrafic/tap/octrafic

# Windows
iex (iwr -useb https://octrafic.com/install.ps1)
Enter fullscreen mode Exit fullscreen mode

Set up your AI provider

Octrafic supports Claude, OpenAI, OpenRouter, Gemini, Ollama, and llama.cpp. You bring your own API key - nothing goes through my servers.

Run octrafic for the first time and it'll walk you through the setup.

Octrafic onboarding

If you want to run everything locally without any API key, Ollama works great:

ollama pull qwen2.5:7b
Enter fullscreen mode Exit fullscreen mode

Then point Octrafic at it during setup.

Load your API

octrafic -u https://api.example.com -s openapi.json -n "My API"
Enter fullscreen mode Exit fullscreen mode
  • -u - your API base URL
  • -s - path to your OpenAPI/Swagger spec
  • -n - project name

Start testing

Once you're in the TUI, just describe what you want tested:

test the login endpoint with valid credentials
test the login endpoint with a wrong password
test creating a new user and check the response structure
run edge cases on the /users endpoint
Enter fullscreen mode Exit fullscreen mode

The AI figures out the right HTTP method, URL, headers, and payload based on your spec. It executes the request and shows you the response with a pass/fail result.

Octrafic gif

Authentication

Pass auth via CLI flags when starting a session:

# Bearer token
octrafic -u https://api.example.com -s spec.json \
  --auth bearer --token "your-token-here"

# API key
octrafic -u https://api.example.com -s spec.json \
  --auth apikey --key X-API-Key --value "your-key-here"

# Basic auth
octrafic -u https://api.example.com -s spec.json \
  --auth basic --user admin --pass secret123
Enter fullscreen mode Exit fullscreen mode

Or use environment variables if you don't want credentials in your shell history or project files:

export OCTRAFIC_AUTH_TYPE=bearer
export OCTRAFIC_AUTH_TOKEN=your-token-here
octrafic -u https://api.example.com -s spec.json
Enter fullscreen mode Exit fullscreen mode

One important thing - your actual tokens and passwords are never sent to the AI. The AI only knows the auth type and header names. Your credentials stay on your machine.

Export your tests

After running tests interactively, you can ask the AI to export them:

export these tests to postman
export tests as a shell script
export to pytest and name it test_users_api.py
Enter fullscreen mode Exit fullscreen mode

You can also export a test plan before executing it, useful if you just want to generate tests and run them later.

Files are saved to ~/Documents/octrafic/tests/.

Run tests in CI/CD

For pipelines, use the octrafic test subcommand - no TUI, no prompts:

octrafic test \
  --url https://api.example.com \
  --path tests/api-tests.json \
  --auth bearer \
  --token $API_TOKEN
Enter fullscreen mode Exit fullscreen mode

Or generate and run tests from a prompt directly:

octrafic test \
  --url https://api.example.com \
  --spec openapi.json \
  --prompt "test all user endpoints"
Enter fullscreen mode Exit fullscreen mode

Exits with 0 if all tests pass, 1 if anything fails.

GitHub Actions example:

- name: Run API tests
  run: |
    octrafic test \
      --url ${{ secrets.API_URL }} \
      --path tests/api-tests.json \
      --auth bearer \
      --token ${{ secrets.API_TOKEN }}
Enter fullscreen mode Exit fullscreen mode

Save your project

By default, new sessions are temporary. Use /save to persist your project, or watch for the temp indicator in the status bar.


That's the basics. It's open-source and still early, so if something doesn't work or you have ideas, open an issue.

Top comments (0)