A simple and elegant HTTP client for Python
Project description
awesome_request
A simple and elegant HTTP client for Python — zero dependencies, pure stdlib.
Installation
pip install awesome_request
Quick Start
import awesome_request as ar
# Simple GET
resp = ar.get("https://httpbin.org/get")
print(resp.status_code) # 200
print(resp.json) # parsed JSON body
# GET with query parameters
resp = ar.get("https://httpbin.org/get", params={"page": 1, "limit": 20})
# POST JSON
resp = ar.post(
"https://httpbin.org/post",
json_data={"name": "Alice", "age": 30},
)
resp.raise_for_status() # raises HTTPError if 4xx/5xx
print(resp.json)
# POST form data
resp = ar.post(
"https://httpbin.org/post",
data={"username": "alice", "password": "secret"},
)
# PUT / PATCH / DELETE
ar.put("https://httpbin.org/put", json_data={"id": 1, "name": "Bob"})
ar.patch("https://httpbin.org/patch", json_data={"name": "Bob"})
ar.delete("https://httpbin.org/delete")
Sessions
Use a Session to share a base URL and default headers across multiple requests.
from awesome_request import Session
session = Session(base_url="https://api.example.com", timeout=10)
session.headers["Authorization"] = "Bearer YOUR_TOKEN"
users = session.get("/users").json
post = session.post("/posts", json_data={"title": "Hello"}).json
API Reference
Module-level functions
| Function | Description |
|---|---|
ar.get(url, *, params, headers, timeout) |
Send GET request |
ar.post(url, *, params, headers, data, json_data, timeout) |
Send POST request |
ar.put(url, *, ...) |
Send PUT request |
ar.patch(url, *, ...) |
Send PATCH request |
ar.delete(url, *, params, headers, timeout) |
Send DELETE request |
ar.head(url, *, params, headers, timeout) |
Send HEAD request |
ar.request(method, url, **kwargs) |
Send any HTTP request |
Response object
| Attribute / Method | Description |
|---|---|
.status_code |
HTTP status code (int) |
.ok |
True if status is 2xx |
.text |
Body decoded as string |
.json |
Body parsed as JSON |
.content |
Raw body bytes |
.headers |
Response headers dict |
.url |
Final URL |
.raise_for_status() |
Raise HTTPError on 4xx/5xx |
Session(base_url, headers, timeout)
Persistent session for shared config. Has the same .get(), .post(), .put(), .patch(), .delete(), .head(), and .request() methods as module level.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file awesome_request-0.1.0.tar.gz.
File metadata
- Download URL: awesome_request-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17bd58ff6b3c849295c6fcb634658c71f1588ce021f7ad712f921cc2014afff7
|
|
| MD5 |
83f6d41ba0fab1f8a212233243750123
|
|
| BLAKE2b-256 |
9b6251b3777901ed1a245d8996be84a61e6c15c97d29554d03929740b6250f9e
|
File details
Details for the file awesome_request-0.1.0-py3-none-any.whl.
File metadata
- Download URL: awesome_request-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
beca9d1dd57d29db3a21c8f7f5dcb0febbe99f9f0ba0be34282bcd6b7078aa11
|
|
| MD5 |
0626e0a652cd7dd399b02ae40d1eb3df
|
|
| BLAKE2b-256 |
10c9a9979d70fb05dc458be7d15cd4f2147dd1c3677757ce26be7bc40f9cb357
|