HTTP Client

Send HTTP requests with full control over methods, headers, body, and query parameters.

HTTP Methods

Supported Methods

atra supports all standard HTTP methods. You can specify the method as the first argument or use the -X / --method flag.

# Method as first argument

atra GET https://api.example.com/users

atra POST https://api.example.com/users name:John

atra PUT https://api.example.com/users/1 name:Jane

atra PATCH https://api.example.com/users/1 status:active

atra DELETE https://api.example.com/users/1

# Using -X / --method flag

atra -X POST https://api.example.com/users

atra --method PUT https://api.example.com/users/1

HEAD Request

Use the -I / --head flag to send a HEAD request and see only the response headers.

# Using -I flag

atra -I https://api.example.com/users

# Using --head flag

atra --head https://api.example.com/users

Default Method

When no method is specified, atra defaults to GET. Specify the method explicitly for POST, PUT, PATCH, and DELETE requests.

# Defaults to GET

atra https://api.example.com/users

# Specify POST explicitly when sending data

atra POST https://api.example.com/users name:John

Headers

Custom Headers

Add headers with -H / --header. You can use this flag multiple times to add multiple headers.

# Single header

atra GET https://api.example.com/data -H "Content-Type: application/json"

# Multiple headers

atra GET https://api.example.com/data \

-H "Authorization: Bearer token123" \

-H "Accept: application/json" \

-H "X-Request-Id: abc-123"

Headers Block

Use --headers to add multiple headers at once as comma-separated pairs or as a JSON object.

# Comma-separated format

atra GET https://api.example.com/data \

--headers "Accept: application/json, X-Api-Key: my-key"

User-Agent & Referer

Dedicated flags for commonly used headers.

# Set User-Agent with -A / --user-agent

atra GET https://api.example.com/data -A "MyApp/2.0"

atra GET https://api.example.com/data --user-agent "MyApp/2.0"

# Set Referer with -e / --referer

atra GET https://api.example.com/data -e "https://example.com"

atra GET https://api.example.com/data --referer "https://example.com"

Request Body

JSON Body (Default)

The simplest way to send JSON. Use key:value pairs directly as arguments — atra automatically constructs a JSON object and sets Content-Type to application/json.

# Key:value pairs become JSON

atra POST https://api.example.com/users \

name:John \

email:[email protected] \

age:30

Sends:

{"name": "John", "email": "[email protected]", "age": 30}

Raw Body with -d / --data / --body

Send a raw body string using any of these equivalent flags: -d, --data, or --body. All three are aliases for the same flag.

# Using -d (short form)

atra POST https://api.example.com/users \

-H "Content-Type: application/json" \

-d '{"name": "John", "email": "[email protected]"}'

# Using --data (long form)

atra POST https://api.example.com/users \

-H "Content-Type: application/json" \

--data '{"name": "John", "email": "[email protected]"}'

# Using --body (long form alias)

atra POST https://api.example.com/users \

-H "Content-Type: application/json" \

--body '{"name": "John", "email": "[email protected]"}'

Note: Raw body (-d) does not auto-set Content-Type — add it manually with -H. Content-Type is set automatically for: key:value pairs (application/json), form data (application/x-www-form-urlencoded), and multipart uploads (multipart/form-data).

Body from File

Use the @filename prefix to read the body from a file. This works with -d, --data, and --body.

# Read body from a JSON file

atra POST https://api.example.com/users -d @payload.json

atra POST https://api.example.com/users --data @payload.json

atra POST https://api.example.com/users --body @payload.json

# Read body from any file

atra POST https://api.example.com/import \

-d @data.xml -H "Content-Type: application/xml"

Form Data

Use -f / --form to send URL-encoded form data instead of JSON. The Content-Type is set to application/x-www-form-urlencoded.

# URL-encoded form data

atra POST https://api.example.com/login \

-f -d "username=john&password=secret"

# Using --form

atra POST https://api.example.com/login \

--form -d "username=john&password=secret"

Multipart Form Data

Use -F / --file to send multipart form data — perfect for file uploads. You can use this flag multiple times for multiple fields.

# Upload a file

atra POST https://api.example.com/upload -F "[email protected]"

# File with additional fields

atra POST https://api.example.com/upload \

-F "[email protected]" \

-F "description=My document" \

-F "tags=important"

Note: When using key:value pairs, atra treats numeric values as numbers in JSON (not strings). Use age:30 for a number or include quotes for a string value.

Reading from Stdin

Pipe URL from Stdin

atra can read the URL from standard input, making it easy to use with pipes.

# Pipe a URL from echo

echo "https://api.example.com/users" | atra

# Read URL from a file

cat url.txt | atra

Quick Reference

Body Flags at a Glance

FlagAliasDescription
-d--data, --bodyRaw body data or @file
-f--formSend as URL-encoded form
-F--fileMultipart form field (repeatable)
-H--headerAdd custom header (repeatable)
--headersAdd multiple headers at once
-A--user-agentSet User-Agent header
-e--refererSet Referer header
-X--methodOverride HTTP method
-I--headSend HEAD request