API Testing from the Command Line - Making HTTP requests as simple as child's play!
A lightweight, Java-based command-line HTTP client that brings Postman-like functionality to your terminal. Perfect for developers who prefer CLI tools, DevOps automation, and CI/CD pipeline integration.
- HTTP Methods: Full support for GET, POST, PUT, DELETE requests
- Interactive JSON Editor: Built-in editor with syntax highlighting and formatting
- API Collections: Organize and save requests in groups for easy reuse
- Command History: Navigate through previous commands with arrow keys
- Response Formatting: Automatic JSON prettification and colored output
- Request Management: Save, modify, and execute requests with a single command
- Terminal-First Design: Built for CLI lovers and automation workflows
- CLI Developers who prefer terminal-based tools over GUI applications
- DevOps Engineers integrating API tests into CI/CD pipelines
- Backend Developers testing APIs during development
- System Administrators working in headless environments
- Automation Engineers scripting API interactions
- Java 8 or higher (JRE or JDK)
- Terminal with ANSI color support (most modern terminals)
# Clone the repository
git clone https://github.com/yourusername/curlbaby.git
# Navigate to directory
cd curlbaby
# Make executable and run
chmod +x curlbaby.sh
./curlbaby.shThat's it! cUrlBaby will compile itself and launch.
> get jsonplaceholder.typicode.com/users/1> post api.example.com/users
# Follow interactive prompts or use 'json' for the editor> group create MyAPIs "My API collection"
> api save MyAPIs LoginRequest
> run 1 # Execute saved request by ID| Command | Description | Example |
|---|---|---|
get <url> |
Execute GET request | get api.github.com/user |
post <url> |
Execute POST request | post api.example.com/data |
put <url> |
Execute PUT request | put api.example.com/users/1 |
delete <url> |
Execute DELETE request | delete api.example.com/users/1 |
help |
Show available commands | help |
exit |
Quit application | exit |
| Command | Description | Example |
|---|---|---|
group create <name> |
Create new API group | group create AuthAPI |
group list |
List all groups | group list |
group show <id|name> |
Show group details | group show AuthAPI |
api save <group> <name> |
Save request to group | api save AuthAPI Login |
api list <group> |
List requests in group | api list AuthAPI |
run <id> |
Execute saved request | run 5 |
When editing request bodies, cUrlBaby provides a powerful JSON editor:
| Command | Description |
|---|---|
:h |
Show help |
:p |
Preview current JSON |
:l |
List lines with numbers |
:e <line> |
Edit specific line |
:f |
Format/prettify JSON |
:s |
Save and exit |
:paste |
Multi-line paste mode |
cUrlBaby follows a modular architecture designed for maintainability and extensibility:
com.curlbaby/
βββ CurlBabyApp.java # Main application entry point
βββ CommandProcessor.java # Command parsing and routing
βββ HttpRequestHandler.java # HTTP client implementation
βββ UIManager.java # Terminal UI and colors
βββ ApiCollectionManager.java # Database operations for collections
βββ ApiCollectionCommands.java # Collection command handlers
βββ JsonFormatter.java # JSON prettification
βββ SimpleJsonEditor.java # Interactive JSON editor
βββ ConsoleReader.java # Terminal input handling
βββ CommandHistory.java # In-memory command history
βββ CommandHistoryDatabase.java # Persistent command history
- CurlBabyApp: Main entry point that initializes components and handles the main application loop
- CommandProcessor: Routes user input to appropriate handlers
- HttpRequestHandler: Manages HTTP requests using Java's built-in HTTP client
- UIManager: Handles all terminal output with colors and formatting
- ApiCollectionManager: SQLite-based persistence for saved requests and groups
- JsonFormatter: Custom JSON parser and prettifier
- SimpleJsonEditor: Interactive text editor for JSON content
cUrlBaby uses a simple build system via the curlbaby.sh script:
# The script automatically:
# 1. Creates necessary directories
# 2. Compiles Java source files
# 3. Sets up classpath with dependencies
# 4. Launches the application
./curlbaby.shcurlbaby/
βββ curlbaby.sh # Build and launch script
βββ .gitignore # Git ignore rules
βββ com/curlbaby/ # Java source files
βββ curlbaby/
β βββ lib/ # JAR dependencies
β βββ target/classes/ # Compiled Java classes
βββ backup/ # Backup dependencies
- SQLite JDBC: For API collection persistence
- Java Standard Library: HTTP client, JSON handling, terminal I/O
We welcome contributions! Here's how to get started:
-
Fork and Clone
git clone https://github.com/yourusername/curlbaby.git cd curlbaby -
Understand the Codebase
- Start with
CurlBabyApp.javato understand the main flow - Look at
CommandProcessor.javato see how commands are routed - Examine
HttpRequestHandler.javafor HTTP functionality
- Start with
-
Test Your Changes
./curlbaby.sh # Test various commands to ensure everything works
- Java Conventions: Follow standard Java naming conventions
- Modular Design: Keep classes focused on single responsibilities
- Error Handling: Always handle exceptions gracefully with user-friendly messages
- Terminal UX: Use
UIManagerfor all output to maintain consistent formatting
- New HTTP Methods: Add support for PATCH, OPTIONS, HEAD
- Authentication: Implement OAuth, API key management
- Import/Export: Add Postman collection import/export
- Response Processing: Add response validation, testing frameworks
- Performance: Optimize startup time, memory usage
Example: Adding a PATCH command
-
Add to CommandProcessor:
case "patch": if (argument.isEmpty()) { uiManager.printError("Usage: patch <url>"); } else { requestHandler.executePatchRequest(argument); } break;
-
Implement in HttpRequestHandler:
public void executePatchRequest(String urlString) { Request request = new Request("PATCH", urlString); // Add body and headers handling similar to POST/PUT executeRequest(request); }
-
Update Help Text in
CommandProcessor.printHelp()
cUrlBaby uses SQLite for persistence:
-- API Groups
CREATE TABLE api_groups (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE NOT NULL,
description TEXT
);
-- API Requests
CREATE TABLE api_requests (
id INTEGER PRIMARY KEY AUTOINCREMENT,
group_id INTEGER NOT NULL,
name TEXT NOT NULL,
method TEXT NOT NULL,
url TEXT NOT NULL,
headers TEXT, -- JSON string
body TEXT,
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(group_id) REFERENCES api_groups(id) ON DELETE CASCADE
);-
Java Not Found
- Install Java 8+ and ensure it's in your PATH
- Test with
java -version
-
Compilation Errors
- Ensure all
.javafiles are in the correct package structure - Check that SQLite JDBC driver is in
curlbaby/lib/
- Ensure all
-
Terminal Colors Not Working
- Use a terminal that supports ANSI escape codes
- Try Windows Terminal, iTerm2, or modern Linux terminals
-
Database Issues
- Database files are stored in
~/.curlbaby/ - Delete the directory to reset all data
- Database files are stored in
- Issues: Report bugs and feature requests on GitHub Issues
- Discussions: Join GitHub Discussions for questions and ideas
- Code Review: All PRs are reviewed for quality and consistency
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by Postman's API testing workflow
- Built for the command-line loving developer community
- Designed with automation and CI/CD integration in mind
Happy API Testing! π
Made with β€οΈ for developers who live in the terminal.