API Tester CLI Tool

A simple command-line tool to test REST APIs. This tool allows you to interactively input API details or provide them as command-line arguments for quick testing.

Features

  • Supports HTTP methods (GET, POST, PUT, DELETE)
  • Allows adding custom headers
  • Supports JSON body for requests
  • Bearer token authentication
  • Interactive mode for beginners
  • Command-line mode for advanced users
  • Colored and formatted output for better readability

Installation

  1. Clone the repository: bash git clone https://github.com/bhavyansh001/api-tester.git
  2. Install dependencies: bash bundle install
  3. Run the CLI tool:

    cd api-tester
    chmod +x bin/api-tester
    

    Usage

  4. Interactive Mode Run the tool without any arguments, and it will prompt you for the necessary information interactively.

    bin/api-tester
    

    You will be asked to provide the following:

  5. URL

  6. HTTP Method (GET, POST, PUT, DELETE)

  7. Body (as JSON)

  8. Bearer Token (if needed)

  9. Custom Headers (optional)

  10. Command-Line Mode You can also provide arguments directly to make the process faster.

    bin/api-tester -u https://your-api.com/login -m POST -H '{"Content-Type": "application/json"}' -b '{"email": "[email protected]", "password": "password123"}' -t  'your_bearer_token'
    

    Options:

  11. -u, --url : The API URL.

  12. -m, --method : The HTTP method (GET, POST, PUT, DELETE).

  13. -b, --body : The request body as JSON.

  14. -H, --headers : Custom headers as JSON.

  15. -t, --token : Bearer token for authorization.

  16. Response The response from the server is displayed with colored status codes, headers in table format, and pretty-printed JSON body.

Logging

The tool provides colored logging to enhance visibility. Output includes details about the request, response status, and any errors encountered.

Best Practices

Respect the API's terms of service and rate limits. Ensure you have permission to test authenticated endpoints. Use caution with sensitive information when testing.

Contributing

Contributions are welcome! Report bugs and submit pull requests on GitHub at https://github.com/bhavyansh001/api_tester_cli. Please adhere to the Contributor Covenant code of conduct.

License

api_tester_cli is released under the MIT License. See the LICENSE file for details.