Skip to content

aine1100/ApiTester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ API Tool (Shell Edition)

A blazing-fast, Postman-like API testing experience right in your terminal

Shell Platform License Speed

✨ Why API Tool?

Stop switching between terminal and GUI tools. API Tool brings the full power of API testing directly to your command line with:

  • ⚑ Lightning Speed: Test APIs in seconds, not minutes
  • 🎯 Zero Dependencies: Pure Bash with only curl required
  • πŸ’Ύ Smart Persistence: Save and reuse requests instantly
  • 🌈 Beautiful Output: Color-coded responses with JSON formatting
  • ⌨️ Developer-First: Built by developers, for developers

πŸ“‹ Table of Contents


πŸ”₯ Features

Core Functionality

  • βœ… All HTTP Methods: GET, POST, PUT, PATCH, DELETE
  • βœ… Smart Headers: Easy key:value input with validation
  • βœ… Request Bodies: JSON, plain text, with auto-validation
  • βœ… Auto-Timeouts: Lightning-fast workflow with smart defaults
  • βœ… Response Formatting: Pretty JSON with syntax highlighting

Productivity Boosters

  • πŸ”„ Request Collections: Save, list, run, and delete requests
  • ⚑ Speed Mode: Auto-defaults for common scenarios
  • 🎨 Color Output: Green success, red errors, blue info
  • πŸ“± Cross-Platform: Linux, macOS, Windows (Git Bash/MINGW64)
  • πŸ›‘οΈ Error Handling: Graceful failures with helpful messages

Developer Experience

  • πŸš€ One-Command Testing: ./apitool.sh and go
  • πŸ’‘ Intelligent Prompts: Context-aware input suggestions
  • πŸ“Š Request Summary: See exactly what you're sending
  • πŸ” JSON Validation: Real-time JSON syntax checking

πŸš€ Quick Start

# 1. Download
curl -O https://raw.githubusercontent.com/aine1100/ApiTester/main/apitool.sh

# 2. Make executable
chmod +x apitool.sh

# 3. Run immediately
./apitool.sh

That's it! πŸŽ‰ You're ready to test APIs at terminal speed.


πŸ› οΈ Installation

Prerequisites

  • bash (4.0+) - Standard on all modern systems
  • curl - For HTTP requests
  • jq (optional) - For JSON pretty-printing

Install Dependencies

πŸ“¦ Ubuntu/Debian
sudo apt update && sudo apt install -y curl jq
🍎 macOS
# Using Homebrew
brew install curl jq

# Using MacPorts
sudo port install curl jq
πŸͺŸ Windows
# Git Bash/MINGW64 (recommended)
# curl is usually pre-installed
# Install jq from: https://jqlang.github.io/jq/download/

# Or use Chocolatey
choco install jq

Setup

# Option 1: Direct download
curl -L https://github.com/aine1100/ApiTester/raw/main/apitool.sh -o apitool.sh
chmod +x apitool.sh

# Option 2: Clone repository
git clone https://github.com/aine1100/ApiTester.git
cd apiTester
chmod +x apitool.sh

# Option 3: Add to PATH (recommended)
sudo cp apitool.sh /usr/local/bin/apitool

πŸ’‘ Usage Examples

πŸš€ Lightning-Fast GET Request

$ ./apitool.sh

πŸš€ Welcome to API Tool (Shell Edition)
Choose HTTP method: > 1
βœ… Method: GET
URL: https://api.github.com/users/octocat
βœ… Target: https://api.github.com/users/octocat
Add headers? (y/N): [auto: n]
Send now? (Y/n): [auto: y]
βœ… Sending...

Response:
βœ… Status: 200 OK
{
  "login": "octocat",
  "id": 1,
  "name": "The Octocat",
  "public_repos": 8
}

Save as? test-user
βœ… Saved as "test-user"

πŸ“€ POST with JSON Body

Choose HTTP method: > 2
βœ… Method: POST
URL: https://jsonplaceholder.typicode.com/posts
Add headers? (y/N): y
Header 1: Content-Type: application/json
Header 2: [enter]
Add body? (y/N): y
Body: {"title": "My Post", "body": "Hello API!", "userId": 1}
βœ… Body: 54 chars
βœ… Valid JSON

Response:
βœ… Status: 201 Created
{
  "id": 101,
  "title": "My Post",
  "body": "Hello API!",
  "userId": 1
}

⚑ Using Saved Requests

# List all saved requests
$ ./apitool.sh list
πŸ“‹ Saved Requests:
  test-user: GET https://api.github.com/users/octocat
  create-post: POST https://jsonplaceholder.typicode.com/posts

# Run a saved request
$ ./apitool.sh run test-user
ℹ️ Running saved request: test-user
βœ… Sending...
# ... response output

πŸ“š Commands

Command Description Example
./apitool.sh Interactive mode - Full guided experience ./apitool.sh
./apitool.sh run <name> Run saved request by name ./apitool.sh run api-test
./apitool.sh list List all saved requests ./apitool.sh list
./apitool.sh delete <name> Delete a saved request ./apitool.sh delete old-test
./apitool.sh help Show help and usage info ./apitool.sh help

🎯 Pro Tips

# Quick API testing workflow
./apitool.sh                    # Test your API
./apitool.sh run my-endpoint    # Repeat tests
./apitool.sh list               # Manage saved requests

# Integration with other tools
./apitool.sh run auth-test && ./apitool.sh run data-fetch

πŸ”§ Advanced Features

⏱️ Auto-Timeout System

API Tool uses intelligent timeouts for lightning-fast workflows:

  • Headers prompt: 5s timeout β†’ defaults to "no headers"
  • Body prompt: 5s timeout β†’ defaults to "no body"
  • Send confirmation: 3s timeout β†’ defaults to "yes, send"
  • Save prompt: 5s timeout β†’ defaults to "don't save"

🎨 Color System

  • 🟒 Green: Success messages, 2xx status codes
  • πŸ”΄ Red: Errors, 4xx/5xx status codes
  • 🟑 Yellow: Warnings, input validation
  • πŸ”΅ Blue: Information, headers, metadata
  • 🟣 Cyan: Headers, section titles

πŸ“ Request Storage

Requests are stored in ~/.apitool/requests.json:

{
  "my-api-test": {
    "method": "GET",
    "url": "https://api.example.com/data",
    "headers": "Authorization: Bearer token",
    "body": "",
    "created": "2025-08-18T10:30:15Z"
  }
}

πŸ”„ Fallback Mode

Without jq, API Tool gracefully falls back to:

  • Plain text JSON output
  • Simple file-based request storage
  • Basic validation

βš™οΈ Configuration

Environment Variables

# Customize config directory
export APITOOL_CONFIG_DIR="$HOME/.config/apitool"

# Adjust timeouts (seconds)
export APITOOL_HEADER_TIMEOUT=10
export APITOOL_BODY_TIMEOUT=30
export APITOOL_SEND_TIMEOUT=5

File Locations

~/.apitool/
β”œβ”€β”€ requests.json          # Saved requests (with jq)
β”œβ”€β”€ requests_simple.txt    # Fallback storage
└── temp/                  # Temporary files

Customization

Edit the script to customize:

  • Colors and emojis
  • Timeout values
  • Default behaviors
  • Output formats

πŸ” Troubleshooting

πŸ› Common Issues & Solutions

Script hangs after method selection

# Debug mode
bash -x ./apitool.sh

# Check bash version
bash --version  # Needs 4.0+

# Try with different read timeout
export APITOOL_TIMEOUT=10

JSON not pretty-printed

# Install jq
sudo apt install jq    # Ubuntu/Debian
brew install jq        # macOS

# Verify jq works
echo '{"test":true}' | jq .

Curl command fails

# Test curl directly
curl -I https://httpbin.org/get

# Check network connectivity
ping google.com

# Verify curl supports HTTPS
curl --version | grep -i ssl

Permission denied

# Make executable
chmod +x apitool.sh

# Check script location
ls -la apitool.sh

Windows/MINGW64 issues

# Use Git Bash instead of CMD
# Ensure line endings are correct
dos2unix apitool.sh

# Test in PowerShell
powershell -c "./apitool.sh"
🚨 Error Codes
Exit Code Description Solution
0 Success πŸŽ‰ All good!
1 Invalid input/arguments Check command syntax
2 Network/curl error Verify URL and connectivity
3 File/permission error Check file permissions
4 Missing dependency Install curl/jq

🀝 Contributing

We love contributions! Here's how to get involved:

πŸ› Found a Bug?

  1. Check existing issues
  2. Create a new issue with:
    • Your OS and bash version
    • Steps to reproduce
    • Expected vs actual behavior

πŸ’‘ Have an Idea?

  1. Fork the repository
  2. Create a feature branch: git checkout -b amazing-feature
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸš€ Development Setup

git clone https://github.com/aine1100/apiTester.git
cd apitool

# Make changes
vim apitool.sh

# Test your changes
./apitool.sh

# Run tests (if available)
./test.sh

πŸ“ Contributing Guidelines

  • Keep it simple and fast
  • Maintain cross-platform compatibility
  • Add comments for complex logic
  • Follow existing code style
  • Test on multiple platforms

πŸ“„ License

MIT License - see LICENSE file for details.

This means you can:

  • βœ… Use commercially
  • βœ… Modify and distribute
  • βœ… Use privately
  • βœ… Include in other projects

πŸ™ Acknowledgements

Built with ❀️ for terminal enthusiasts everywhere

  • Inspired by: Postman - The API testing gold standard
  • Powered by: curl - The universal HTTP client
  • Enhanced by: jq - The JSON processor
  • Thanks to: The open-source community for endless inspiration

🌟 Star History

If API Tool saved you time, please ⭐ star this repo and share it with your team!

Happy API Testing! πŸš€


Made with πŸ’» and β˜• by developers, for developers

Report Bug β€’ Request Feature β€’ Contribute β€’ Star ⭐

About

This is a simple shell tool for testing apis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages