Skip to content

WeihanLi/dotnet-httpie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

844 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

dotnet-HTTPie

๐Ÿ“– ๆŸฅ็œ‹ไธญๆ–‡ๆ–‡ๆกฃ

dotnet-HTTPie dotnet-HTTPie Latest GitHub Action Build Status Docker Pulls Ask DeepWiki

Modern, user-friendly command-line HTTP client for the .NET ecosystem

dotnet-httpie is a .NET tool that brings the power and simplicity of HTTPie to .NET developers. It's designed for testing, debugging, and interacting with APIs and HTTP servers with an intuitive command-line interface.

httpie

โœจ Key Features

  • ๐Ÿš€ Simple & Intuitive: Human-friendly syntax for HTTP requests
  • ๐Ÿ“ File Execution: Run .http and .rest files for repeatable testing
  • ๐Ÿ”„ cURL Support: Execute cURL commands directly
  • ๐Ÿณ Docker Ready: Available as a Docker image for containerized environments
  • ๐Ÿ”— Request Chaining: Reference previous responses in subsequent requests
  • ๐ŸŒ Environment Support: Multiple environment configurations
  • ๐Ÿ“Š Load Testing: Built-in load testing capabilities
  • ๐Ÿ” Authentication: Support for various auth methods (JWT, API keys, Basic auth)
  • โฌ‡๏ธ File Downloads: Download files with progress indicators
  • ๐Ÿ” JSON Schema Validation: Validate API responses against schemas
  • ๐Ÿ’พ Request Caching: Cache requests for improved performance
  • ๐ŸŽฏ Middleware System: Extensible request/response pipeline

๐Ÿš€ Quick Start

Installation

Install the latest stable version:

dotnet tool update --global dotnet-httpie

Or install the latest preview:

dotnet tool update --global dotnet-httpie --prerelease

Your First Request

# Simple GET request
dotnet-http httpbin.org/get

# POST with JSON data  
dotnet-http POST httpbin.org/post name=John age:=30

# With custom headers
dotnet-http GET httpbin.org/headers Authorization:"Bearer token"

๐Ÿ“– Documentation

Topic Description
๐Ÿ‡จ๐Ÿ‡ณ ไธญๆ–‡ๆ–‡ๆกฃ Chinese documentation / ็ฎ€ไฝ“ไธญๆ–‡ๅฎŒๆ•ดๆ–‡ๆกฃ
๐Ÿ“‹ Installation Guide Detailed installation instructions for all platforms
โšก Quick Start Get up and running in minutes
๐ŸŒ HTTP Requests Complete guide to making HTTP requests
๐Ÿ“„ File Execution Execute .http/.rest files
๐Ÿณ Docker Usage Using dotnet-httpie with Docker
๐Ÿ’ก Common Use Cases Practical examples and patterns
๐Ÿ”ง Full Documentation Complete documentation index

๐Ÿ’ซ Command Syntax

dotnet-http [flags] [METHOD] URL [ITEM [ITEM]]

Request Items

Type Syntax Example Description
Query Parameters name==value search==httpie URL query string parameters
Headers name:value Authorization:Bearer token HTTP request headers
JSON Data name=value name=John JSON request body fields
Raw JSON name:=value age:=30, active:=true Raw JSON values (numbers, booleans, objects)

๐ŸŽฏ Examples

Basic Requests

# GET request with query parameters
dotnet-http GET httpbin.org/get search==httpie limit==10

# POST request with JSON data
dotnet-http POST httpbin.org/post name=John email=john@example.com age:=30

# PUT request with headers
dotnet-http PUT api.example.com/users/123 \
  Authorization:"Bearer token" \
  name="John Smith" \
  active:=true

Advanced Usage

# Complex JSON with nested objects
dotnet-http POST api.example.com/users \
  name=John \
  address[city]=Seattle \
  address[zipcode]:=98101 \
  tags:='["developer", "api"]'



# Download files
dotnet-http GET api.example.com/files/report.pdf --download

Real-World API Examples

# GitHub API
dotnet-http GET api.github.com/users/octocat

# Create GitHub issue (with authentication)
dotnet-http POST api.github.com/repos/owner/repo/issues \
  Authorization:"token your-token" \
  title="Bug report" \
  body="Description of the issue"

# JSON API with multiple data types
dotnet-http POST api.example.com/orders \
  Authorization:"Bearer jwt-token" \
  customer_id:=12345 \
  items:='[{"id": 1, "qty": 2}, {"id": 2, "qty": 1}]' \
  urgent:=true \
  notes="Please handle with care"

๐Ÿ“ File Execution

Execute HTTP requests from .http and .rest files:

# Execute HTTP file
dotnet-http exec requests.http

# Execute with specific environment
dotnet-http exec api-tests.http --env production

# Execute cURL commands
dotnet-http exec commands.curl --type curl

Example .http file:

@baseUrl = https://api.example.com
@token = your-jwt-token

###

# @name getUsers
GET {{baseUrl}}/users
Authorization: Bearer {{token}}

###

# @name createUser  
POST {{baseUrl}}/users
Authorization: Bearer {{token}}
Content-Type: application/json

{
  "name": "John Doe",
  "email": "john@example.com"
}

###

# Reference previous response
GET {{baseUrl}}/users/{{createUser.response.body.id}}
Authorization: Bearer {{token}}

Environment Support

Create http-client.env.json:

{
  "development": {
    "baseUrl": "http://localhost:3000",
    "token": "dev-token"
  },
  "production": {
    "baseUrl": "https://api.example.com", 
    "token": "prod-token"
  }
}

๐Ÿณ Docker

Use dotnet-httpie without installing .NET:

# Basic usage
docker run --rm weihanli/dotnet-httpie:latest httpbin.org/get

# POST with data  
docker run --rm weihanli/dotnet-httpie:latest POST httpbin.org/post name=test

# Execute HTTP files
docker run --rm -v $(pwd):/workspace -w /workspace \
  weihanli/dotnet-httpie:latest exec requests.http

# With environment variables
docker run --rm -e API_TOKEN="your-token" \
  weihanli/dotnet-httpie:latest GET api.example.com/protected \
  Authorization:"Bearer $API_TOKEN"

Create an alias for easier usage:

# Add to your shell profile (.bashrc, .zshrc, etc.)
alias http='docker run --rm weihanli/dotnet-httpie:latest'

# Now use it like the installed version
http GET httpbin.org/get
http POST httpbin.org/post name=John

๐Ÿ”ง Advanced Features

Authentication

  • JWT Tokens: Authorization:"Bearer token"
  • API Keys: X-API-Key:"key" or api_key==key
  • Basic Auth: --auth username:password or Authorization:"Basic base64"

File Operations

  • Form data: --form field=value
  • Download: --download flag
  • Send raw data: --raw "data"

Request Features

  • Query parameters: param==value
  • Custom headers: Header-Name:"value"
  • JSON data: field=value or field:=rawjson
  • Form data: --form flag
  • Raw data: --raw "data"

Execution Modes

  • Offline mode: --offline (preview requests)
  • Debug mode: --debug (detailed logging)
  • Environment: --env production

Response Handling

  • Body only: --body flag
  • Follow redirects: --follow
  • JSON processing: Pipe to jq for advanced processing

๐Ÿš€ Use Cases

  • API Development: Test endpoints during development
  • API Documentation: Executable examples in documentation
  • CI/CD Testing: Automated API testing in pipelines
  • Load Testing: Built-in load testing capabilities
  • Integration Testing: Test service-to-service communication
  • Debugging: Inspect HTTP requests and responses
  • Scripting: Automate API interactions in shell scripts

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

  1. Report Issues: Found a bug? Open an issue
  2. Feature Requests: Have an idea? Open an issue
  3. Documentation: Help improve the docs
  4. Code: Submit pull requests for bug fixes or features

Development Setup

# Clone the repository
git clone https://github.com/WeihanLi/dotnet-httpie.git
cd dotnet-httpie

# Build the project
dotnet build

# Run tests
dotnet test

# Install locally for testing
dotnet pack
dotnet tool install --global --add-source ./artifacts dotnet-httpie

๐Ÿ“š Resources

๐Ÿ™ Acknowledgments

  • Inspired by the amazing HTTPie project
  • Built with โค๏ธ for the .NET community
  • Special thanks to all contributors

๐Ÿ“„ License

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


โญ Star this repository if you find it useful!

๐Ÿ  Homepage โ€ข ๐Ÿ“– Documentation โ€ข ๐Ÿณ Docker Hub โ€ข ๐Ÿ“ฆ NuGet

About

Amazing HTTP command-line tool powered by .NET, inspired by httpie

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages