Skip to main content
HTTP GET and POST requests with automatic JSON parsing.
import http

Functions

FunctionDescription
http.get(url)GET request, returns response body
http.get(url, headers)GET with custom headers
http.post(url, body)POST request with body
http.post(url, body, headers)POST with body and headers
All requests are async under the hood. Responses are automatically parsed as JSON if content-type matches. Otherwise, raw string.

Examples

import http

# Simple GET
data = http.get("https://api.github.com/users/octocat")
# data is automatically a Dict if JSON response
print(data.login)

# GET with headers
headers = {"Authorization": "Bearer sk-abc123"}
data = http.get("https://api.example.com/me", headers)

# POST with JSON body
body = {"name": "Alex", "email": "alex@example.com"}
result = http.post("https://api.example.com/users", body)
print(result)

Compile Flag

cargo build --release --no-default-features --features mod_http