Skip to content

FluxAPI CLI is a lightweight, cross-platform command-line interface for interacting with APIs. Built as a companion to the FluxAPI Desktop client, it allows developers and testers to send HTTP requests, inspect responses, and manage API workflows directly from the terminal.

License

Notifications You must be signed in to change notification settings

M-Skilla/fluxapi-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ FluxAPI CLI

MIT License Node.js npm version

A lightweight, cross-platform command-line interface for interacting with APIs. Built as a companion to the FluxAPI Desktop client, it allows developers and testers to send HTTP requests, inspect responses, and manage API workflows directly from the terminal.

✨ Features

  • πŸ”„ Send HTTP Requests - Support for all HTTP methods (GET, POST, PUT, DELETE, etc.)
  • πŸ’Ύ Save & Manage Requests - Store frequently used requests for quick access
  • 🎨 Beautiful Output - Colored JSON responses and status codes
  • πŸ“‹ Code Generation - Export saved requests as code snippets in 12+ languages
  • πŸ” Authentication Support - Bearer token authentication
  • πŸ“ Query Parameters & Headers - Full support for custom headers and query parameters
  • 🎯 Environment Variables - Support for environment-based authentication
  • πŸ“‹ Clipboard Integration - Copy generated code snippets to clipboard

πŸ›  Installation

Global Installation (Recommended)

npm install -g fluxapi-cli

Using pnpm

pnpm add -g fluxapi-cli

Using yarn

yarn global add fluxapi-cli

πŸš€ Quick Start

Basic HTTP Request

# Simple GET request
fluxapi req https://jsonplaceholder.typicode.com/posts/1

# POST request with JSON data
fluxapi req https://jsonplaceholder.typicode.com/posts \
  -m POST \
  -H "Content-Type=application/json" \
  -b '{"title": "My Post", "body": "Hello World", "userId": 1}'

Save & Reuse Requests

# Save a request configuration
fluxapi save myapi https://api.example.com/users \
  -m GET \
  -H "Authorization=Bearer your-token" \
  -q "limit=10&page=1"

# Use saved request
fluxapi req @myapi

# List all saved requests
fluxapi list

# Delete a saved request
fluxapi delete myapi

Generate Code Snippets

# Export as curl command
fluxapi export myapi --language curl

# Export as Python requests code
fluxapi export myapi -l python --copy

# Export as JavaScript fetch
fluxapi export myapi -l javascript

πŸ“– Command Reference

fluxapi req <url> - Send HTTP Request

Send an HTTP request to the specified URL or use a saved request.

Usage:

fluxapi req <url|@saved-name> [options]

Arguments:

  • <url> - URL to send the request to, or @name to use a saved request

Options:

  • -m, --method <method> - HTTP method (GET, POST, PUT, DELETE, etc.) [default: "GET"]
  • -H, --header <header...> - Headers in key=value format (can be used multiple times)
  • -q, --query <query...> - Query parameters in key=value format (can be used multiple times)
  • -b, --body <body> - Request body (JSON string)
  • -t, --token <token> - Bearer authentication token

Examples:

# GET request
fluxapi req https://api.github.com/users/octocat

# POST with JSON body
fluxapi req https://httpbin.org/post \
  -m POST \
  -H "Content-Type=application/json" \
  -b '{"name": "John", "age": 30}'

# With authentication
fluxapi req https://api.example.com/protected \
  -H "Authorization=Bearer your-token"

# With query parameters
fluxapi req https://api.example.com/search \
  -q "q=javascript" \
  -q "sort=stars"

# Use saved request
fluxapi req @myapi

fluxapi save <name> <url> - Save Request Configuration

Save a request configuration for future use.

Usage:

fluxapi save <name> <url> [options]

Arguments:

  • <name> - Name to save the request under
  • <url> - URL to send the request to

Options:

  • -m, --method <method> - HTTP method [default: "GET"]
  • -H, --header <header...> - Headers in key=value format
  • -q, --query <query...> - Query parameters in key=value format
  • -b, --body <body> - Request body (JSON string)
  • -t, --token <token> - Bearer authentication token

Examples:

# Save a simple GET request
fluxapi save github-user https://api.github.com/users/octocat

# Save a complex POST request
fluxapi save create-post https://jsonplaceholder.typicode.com/posts \
  -m POST \
  -H "Content-Type=application/json" \
  -H "Authorization=Bearer token123" \
  -b '{"title": "My Post", "body": "Content", "userId": 1}'

# Save with query parameters
fluxapi save search-repos https://api.github.com/search/repositories \
  -q "q=javascript" \
  -q "sort=stars" \
  -q "order=desc"

fluxapi list - List Saved Requests

Display all saved request configurations.

Usage:

fluxapi list

Example:

$ fluxapi list
Saved Requests:
- github-user
- create-post
- search-repos

fluxapi delete <name> - Delete Saved Request

Delete a saved request configuration.

Usage:

fluxapi delete <name>

Arguments:

  • <name> - Name of the saved request to delete

Example:

fluxapi delete github-user

fluxapi export <name> - Export Code Snippets

Export a saved request as a code snippet in various programming languages.

Usage:

fluxapi export <name> [options]

Arguments:

  • <name> - Name of the saved request

Options:

  • -l, --language <lang> - Target language/framework [default: "curl"]
  • --copy - Copy the generated snippet to clipboard

Supported Languages:

  • curl - cURL command
  • fetch / javascript - JavaScript Fetch API
  • axios - JavaScript Axios library
  • python / requests - Python requests library
  • java / okhttp - Java OkHttp library
  • go / golang - Go net/http package
  • php - PHP with file_get_contents
  • csharp / c# - C# HttpClient
  • ruby - Ruby Net::HTTP
  • swift - Swift URLSession
  • kotlin - Kotlin OkHttp
  • rust - Rust reqwest library

Examples:

# Export as cURL (default)
fluxapi export myapi

# Export as Python requests
fluxapi export myapi -l python

# Export as JavaScript and copy to clipboard
fluxapi export myapi -l javascript --copy

# Export as Go code
fluxapi export myapi -l go

πŸ” Authentication

Bearer Token Authentication

You can provide authentication tokens in several ways:

  1. Via command line option:
fluxapi req https://api.example.com/protected -t "your-token-here"
  1. Via environment variable:
export AUTH_TOKEN="your-token-here"
fluxapi req https://api.example.com/protected
  1. Save in request configuration:
fluxapi save protected-api https://api.example.com/protected -t "your-token-here"
fluxapi req @protected-api

Custom Headers

For other authentication methods, use custom headers:

# API Key authentication
fluxapi req https://api.example.com/data -H "X-API-Key=your-api-key"

# Basic authentication (base64 encoded)
fluxapi req https://api.example.com/data -H "Authorization=Basic dXNlcjpwYXNz"

# Custom token format
fluxapi req https://api.example.com/data -H "X-Auth-Token=your-custom-token"

🎨 Response Formatting

FluxAPI CLI provides beautiful, colored output for API responses:

  • Status Codes: Color-coded by status (green for 2xx, yellow for 3xx, red for 4xx, etc.)
  • JSON Responses: Syntax highlighted and pretty-printed
  • Error Messages: Clear error formatting with helpful details

πŸ“‚ Configuration Storage

FluxAPI CLI stores your saved requests in a local configuration file using the conf package. The configuration is stored in:

  • Linux/macOS: ~/.config/fluxapi/config.json
  • Windows: %APPDATA%/fluxapi/config.json

πŸ”§ Advanced Usage

Complex JSON Bodies

For complex JSON bodies, you can use files:

# Save JSON to a file
echo '{"complex": {"nested": "data"}}' > body.json

# Use the file content
fluxapi req https://api.example.com/complex -m POST -b "$(cat body.json)"

Multiple Headers and Query Parameters

fluxapi req https://api.example.com/data \
  -H "Content-Type=application/json" \
  -H "Accept=application/json" \
  -H "User-Agent=MyApp/1.0" \
  -q "page=1" \
  -q "limit=50" \
  -q "sort=name"

Environment-Based Workflows

# Set base URL and token via environment
export API_BASE="https://api.staging.example.com"
export AUTH_TOKEN="staging-token-123"

# Use in requests
fluxapi req $API_BASE/users
fluxapi save staging-users $API_BASE/users -t $AUTH_TOKEN

🀝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™‹β€β™‚οΈ Support

πŸ† Acknowledgments


Made with ❀️ by M-Skilla

About

FluxAPI CLI is a lightweight, cross-platform command-line interface for interacting with APIs. Built as a companion to the FluxAPI Desktop client, it allows developers and testers to send HTTP requests, inspect responses, and manage API workflows directly from the terminal.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published