README
¶
REST QA Tool
A high-performance command-line tool for testing REST API endpoints with latency analysis, uptime monitoring, and rate limit detection.
Features
Core Tests
- Latency Test: Measures average, median, and 90th percentile response times
- Uptime Test: Tracks success rates and error breakdowns
- Rate Limit Detection: Uses binary search to find maximum sustainable RPS
Key Capabilities
- Configurable Parameters: Adjust request counts, timeouts, and rate limits
- Structured Logging: Built with zerolog for professional log management
- Query Parameter Support: Test endpoints with complex query strings
- Content Agnostic: Works with any HTTP endpoint (JSON, XML, HTML, etc.)
- Extensible Architecture: Modular design for easy addition of new tests
Installation
git clone https://github.com/bryanlabs/rest-performance-analyzer
cd rest-performance-analyzer
go build -o rest-performance-analyzer .
Usage
Basic Usage
# Test Coinbase API with default settings (100 requests)
./rest-performance-analyzer "https://api.coinbase.com/v2/prices/BTC-USD/spot"
# Test with query parameters
./rest-performance-analyzer "https://api.kraken.com/0/public/Ticker" --pair=XXBTZUSD
Individual Tests
# Run only latency test
./rest-performance-analyzer --test=latency --requests=5 "https://httpbin.org/delay/1"
# Run only uptime test
./rest-performance-analyzer --test=uptime --requests=5 "https://jsonplaceholder.typicode.com/posts/1"
# Run only rate limit detection
./rest-performance-analyzer --test=ratelimit --rate-low=1 --rate-high=3 --rate-duration=2 "https://api.coinbase.com/v2/prices/BTC-USD/spot"
# Run all tests
./rest-performance-analyzer --test=all --requests=5 --rate-low=1 --rate-high=2 --rate-duration=2 "https://httpbin.org/json"
Configuration Options
# Custom request count and timeout
./rest-performance-analyzer --requests=10 --timeout=30 "https://api.github.com/zen"
# Rate limit testing with custom range
./rest-performance-analyzer --test=ratelimit --rate-low=5 --rate-high=10 --rate-duration=2 "https://api.coinbase.com/v2/prices/ETH-USD/spot"
# Debug logging to see HTTP responses
./rest-performance-analyzer --log-level=debug --requests=3 "https://httpbin.org/json"
Configuration Files
# Use configuration file for complex setups
./rest-performance-analyzer --config config.yaml
# Override config file settings with CLI flags
./rest-performance-analyzer --config config.yaml --test=uptime --requests=5 --log-level=debug
# Rate limit testing with custom parameters
./rest-performance-analyzer --config config.yaml --test=ratelimit --rate-high=3 --rate-duration=2 --log-level=debug
# Fast CI testing with config file and CLI overrides
./rest-performance-analyzer --config config.yaml --requests=10 --timeout=5 --log-level=warn
Configuration Parameters
General Options
| Flag | Default | Description |
|---|---|---|
--config |
Path to YAML configuration file | |
--requests |
100 | Number of requests for latency/uptime tests |
--timeout |
10 | Request timeout in seconds |
--test |
basic | Test type: basic, all, latency, uptime, ratelimit |
--log-level |
info | Log level: debug, info, warn, error |
Rate Limit Testing
| Flag | Default | Description |
|---|---|---|
--rate-low |
1 | Minimum RPS for binary search |
--rate-high |
10 | Maximum RPS for binary search |
--rate-duration |
3 | Duration for each RPS test (seconds) |
--rate-sleep |
1 | Sleep between rate limit tests (seconds) |
Example Outputs
Latency Test Results
✅ Latency Test:
Average Latency: 34.41ms
Median Latency: 31.47ms
90th Percentile: 38.93ms
Success Rate: 100.0%
Rate Limit Detection
✅ Rate Limit Detection Test:
Maximum sustainable RPS: 938 (tested range: 5-1000, 3s per test)
With Debug Logging
When using --log-level=debug, you'll see detailed HTTP request/response information including:
- Request URLs with query parameters
- Response status codes and content
- Request durations
- Error details for failed requests
Real-World Test Examples
Cryptocurrency APIs
# Coinbase BTC price
./rest-performance-analyzer "https://api.coinbase.com/v2/prices/BTC-USD/spot"
# Kraken ticker data
./rest-performance-analyzer "https://api.kraken.com/0/public/Ticker" --pair=XXBTZUSD
# CoinGecko API
./rest-performance-analyzer "https://api.coingecko.com/api/v3/simple/price" --ids=bitcoin --vs_currencies=usd
Public Testing APIs
# JSONPlaceholder (fake REST API for testing)
./rest-performance-analyzer "https://jsonplaceholder.typicode.com/posts/1"
# HTTPBin (HTTP testing service)
./rest-performance-analyzer "https://httpbin.org/json"
./rest-performance-analyzer "https://httpbin.org/delay/2"
# ReqRes API (testing REST services)
./rest-performance-analyzer "https://reqres.in/api/users/2"
Rate Limit Testing (Use with Caution!)
# Conservative rate limit test - safe for demos
./rest-performance-analyzer --test=ratelimit --rate-low=1 --rate-high=3 --rate-duration=2 "https://api.coinbase.com/v2/prices/BTC-USD/spot"
# Test a more forgiving endpoint
./rest-performance-analyzer --test=ratelimit --rate-low=5 --rate-high=10 --rate-duration=2 "https://httpbin.org/json"
CI/CD Integration Examples
# Quick health check
./rest-performance-analyzer --requests=10 --timeout=5 "https://api.github.com/zen"
# Comprehensive API testing
./rest-performance-analyzer --test=all --requests=10 --rate-low=1 --rate-high=3 --rate-duration=2 "https://jsonplaceholder.typicode.com/posts/1"
# Monitor endpoint performance
./rest-performance-analyzer --requests=20 --log-level=warn "https://httpbin.org/delay/1"
Configuration Files
The tool supports YAML configuration files for complex testing scenarios:
config.yaml - Main Configuration
num_requests: 100
timeout: "10s"
log_level: "info"
test_type: "basic"
rate_limit:
sleep: "1s"
low_rps: 1
high_rps: 10
test_duration: "3s"
endpoints:
- name: "Coinbase BTC Price"
url: "https://api.coinbase.com/v2/prices/BTC-USD/spot"
params: {}
- name: "Kraken Ticker"
url: "https://api.kraken.com/0/public/Ticker"
params:
pair: "XXBTZUSD"
Configuration Flexibility
The configuration file provides sensible defaults, but you can override any setting with CLI flags:
CI/CD Usage:
./rest-performance-analyzer --config config.yaml --requests=10 --timeout=5 --log-level=warn
Rate Limit Testing:
./rest-performance-analyzer --config config.yaml --test=ratelimit --rate-high=3 --rate-duration=2 --log-level=debug
Development Testing:
./rest-performance-analyzer --config config.yaml --test=all --requests=10 --rate-low=1 --rate-high=3 --rate-duration=2
Configuration Priority
- CLI flags override everything
- Config file settings are used if no CLI override
- Built-in defaults are used as fallback
Architecture
The tool follows a modular architecture:
main.go: CLI interface and configurationclient/: HTTP client with timing and loggingtester/: Modular test framework with individual test implementationslatency.go: Latency measurement and statisticsuptime.go: Success rate and error trackingratelimit.go: Binary search rate limit detection
Development
Building
go build -o rest-performance-analyzer .
Testing
go test ./...
Adding New Tests
- Implement the
Testerinterface in a new file - Add the tester to
NewRunner()intester/tester.go - Add CLI support in
main.go
Safety Notes
- Rate Limit Testing: Use conservative ranges to avoid getting banned from APIs
- Demo Settings: Default rate limits (1-10 RPS) are safe for demonstrations
- Production APIs: Always check API documentation for rate limits before testing
- Error Logging: Use debug mode to investigate issues without overwhelming logs
Quick Start
Try these commands to see the tool in action:
# Build the tool
go build -o rest-performance-analyzer .
# Quick test with a reliable endpoint
./rest-performance-analyzer --requests=10 "https://httpbin.org/json"
# Use the configuration file
./rest-performance-analyzer --config config.yaml
# See detailed HTTP information
./rest-performance-analyzer --requests=5 --log-level=debug "https://api.github.com/zen"
# Test rate limiting (very conservative)
./rest-performance-analyzer --test=ratelimit --rate-low=1 --rate-high=3 --rate-duration=2 "https://api.coinbase.com/v2/prices/BTC-USD/spot"
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Documentation
¶
There is no documentation for this package.
Click to show internal directories.
Click to hide internal directories.