IPython magics and helpers for working with HTTP requests
Project description
reqtools
reqtools is a super simple ipython extension that allows you to pretty-print HTTP responses and convert between requests code and curl commands.
installation
pip install magic-reqtools
manually loading:
# Inside an IPython shell
%load_ext reqtools
Automatic loading:
echo "c.InteractiveShellApp.extensions = ['reqtools']" > ~/.ipython/profile_default/ipython_config.py
Usage
# Load the extension
In [1]: %load_ext reqtools
# `curl` magic
In [2]: %curl https://www.affirmations.dev/
Out[2]: <Response [200]>
In [3]: response = _
# `res` magic
In [4]: %res response
================================================================================
Status: 200 OK
URL: https://www.affirmations.dev/
--------------------------------------------------------------------------------
Headers:
Content-Length: 54
Content-Type: application/json; charset=utf-8
...
--------------------------------------------------------------------------------
Body:
{
"affirmation": "Your mind is full of brilliant ideas"
}
================================================================================
Out[4]: <Response [200]>
# `req` magic
In [5]: %req response.request
================================================================================
Method: GET
URL: https://www.affirmations.dev/
--------------------------------------------------------------------------------
Headers:
User-Agent: python-requests/2.32.5
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
--------------------------------------------------------------------------------
Body:
<empty>
================================================================================
Out[5]: <PreparedRequest [GET]>
In [6]: response_body = json.loads(bytes.decode(response.content))
# `jq` magic (add `-q` for quiet)
In [7]: %jq response_body .affirmation
"Your mind is full of brilliant ideas"
Out[7]: 'Your mind is full of brilliant ideas'
In [8]: %jq -q response_body .affirmation
Out[8]: 'Your mind is full of brilliant ideas'
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
magic_reqtools-0.2.0.tar.gz
(6.3 kB
view details)
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 magic_reqtools-0.2.0.tar.gz.
File metadata
- Download URL: magic_reqtools-0.2.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
858b79aecfe1a5811f87b10f9213bc3745909125ce523c20273daef0a3bae041
|
|
| MD5 |
736c51ab779e2aec2e0e86d4ab33579e
|
|
| BLAKE2b-256 |
cf3948b0cebeaa2c7e32dda5fb9db277dc231a8309bf2a906c67129a3fe4bf64
|
File details
Details for the file magic_reqtools-0.2.0-py3-none-any.whl.
File metadata
- Download URL: magic_reqtools-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e79aaa4230efac17564d95c350a158b04f057a5ea3e7d151e861a1380f2ca947
|
|
| MD5 |
8ba89447e4b5461678a0b6a11e033d7d
|
|
| BLAKE2b-256 |
7ae60a851c160b7e4f2a941d0bd1969f4621f01380beeed637cd8a6f70f5a1bc
|