kamsekam
Finds the smallest version of an HTTP request that still produces the same response. Takes a request, replays it while removing parts, and prints what is left.
Install
uv tool install kamsekam # the kamsekam command
uv tool install 'kamsekam[impersonate]' # adds browser impersonation using curl_cffi
Usage
Everything after -- is parsed as a curl command:
$ kamsekam -- curl 'https://data.services.jetbrains.com/products?code=TC&release.type=eap%2Crc%2Crelease&fields=distributions%2Clink%2Cname%2Creleases&_=1789067502753' \
--compressed \
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:155.0) Gecko/20100101 Firefox/155.0' \
-H 'Accept: */*' \
-H 'Accept-Language: en' \
-H 'Accept-Encoding: gzip, deflate, br, zstd' \
-H 'Origin: https://www.jetbrains.com' \
-H 'DNT: 1' \
-H 'Sec-GPC: 1' \
-H 'Connection: keep-alive' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: same-site' \
-H 'Priority: u=4' \
-H 'TE: trailers'
input GET https://data.services.jetbrains.com/products · 20 atoms · 503 bytes
baseline 200 application/json 176949B sha256:67308c6c7677
minimised 21 requests · 20 atoms → 2 · 388 bytes saved
keep query:code ?code=TC
keep query:fields ?fields=distributions%2Clink%2Cname%2Creleases
drop 18 removed: header:user-agent, header:accept, header:accept-language, header:accept-encoding[0], header:accept-encoding[1], header:accept-encoding[2], header:accept-encoding[3], header:origin, header:dnt, header:sec-gpc, header:connection, header:sec-fetch-dest, header:sec-fetch-mode, header:sec-fetch-site, header:priority, header:te, query:release.type, query:_
curl 'https://data.services.jetbrains.com/products?code=TC&fields=distributions%2Clink%2Cname%2Creleases'
How it works
- The request is sent once and the response recorded as a signature
(status, content-type, body size, body sha256). - It is split into atoms: each header, each element of a comma-separated
header (
Accept: a, b, cgives three), each cookie, each query parameter, and each form field or top-level JSON key. - Delta debugging removes subsets of atoms and replays, keeping any removal that leaves the signature unchanged, then renders what survived.
The algorithm is ddmin (Zeller & Hildebrandt) 1. It sends the request hundreds of times, so use it only on idempotent requests.
HAR archives
With a HAR file and no --format override, every GET entry is minimised in
place, the rest of the archive copied unchanged.
kamsekam -o minimal.har session.har
kamsekam session.har # writes session-minimal.har, then -1, -2, ...
Options
| Option | |
|---|---|
-f, --format |
curl, har, httpie, http, json; comma-separated |
-o, --output |
write to a file instead of stdout |
--impersonate ID |
replay via curl_cffi with a browser TLS fingerprint |
--match |
signature fields that must hold: status,type,hash (default), or size when a body embeds a token or timestamp and its sha256 never repeats |
--baseline-runs N |
baseline replays used to detect unstable responses (default 2) |
--keep PATTERN |
never remove matching atoms, e.g. --keep 'header:authorization' |
--dry-run |
list atoms and exit without sending anything |
An unstable baseline is detected and --match relaxed automatically. Run
kamsekam --help for the rest.
Library
Minimized requests are returned as httpx2.Request objects, but are also available
as curl strings.
import httpx2
from kamsekam import minimise, to_curl, uncurl
uncurl("curl https://e.test -H 'a: b' --compressed") # -> httpx2.Request; to_curl() reverses it
result = minimise(httpx2.Request("GET", url, headers={"x-a": "1"}), impersonate="chrome131")
result.as_httpx2() # httpx2.Request, minimised
result.to_curl() # command string; also result.kept / .removed / .stats
License
Licensed under Unlicense
-
https://doi.org/10.1109/32.988498 "Simplifying and Isolating Failure-Inducing Input", IEEE Transactions on Software Engineering" ↩
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 kamsekam-0.1.0.tar.gz.
File metadata
- Download URL: kamsekam-0.1.0.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7e583e3b900ce9b8d3e1b96925310f5479093df74d3bbb45816b2fee6456d03
|
|
| MD5 |
bbd82b9dbc21a22be0d572e3bbb83a55
|
|
| BLAKE2b-256 |
2ad3ac96ae10c4334f2fded26ba350c55f61598813e7a7f8ea2f188f7e477631
|
Provenance
The following attestation bundles were made for kamsekam-0.1.0.tar.gz:
Publisher:
release.yml on captn3m0/kamsekam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kamsekam-0.1.0.tar.gz -
Subject digest:
c7e583e3b900ce9b8d3e1b96925310f5479093df74d3bbb45816b2fee6456d03 - Sigstore transparency entry: 2787687197
- Sigstore integration time:
-
Permalink:
captn3m0/kamsekam@f54a6057ce633e58f2f9a7aa183ab32fe25c63d1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/captn3m0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f54a6057ce633e58f2f9a7aa183ab32fe25c63d1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file kamsekam-0.1.0-py3-none-any.whl.
File metadata
- Download URL: kamsekam-0.1.0-py3-none-any.whl
- Upload date:
- Size: 35.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15e5210d8808d7cad386b4cc4242913338ce8d765228e8f0e8c9c72feada9749
|
|
| MD5 |
a9e8af6cc3aafc01ec70e6ca47cbbf9e
|
|
| BLAKE2b-256 |
adc6f58ebe2c5f1c8cb501705dfe7a6d55cc3170c0cf7e9df00b621506723083
|
Provenance
The following attestation bundles were made for kamsekam-0.1.0-py3-none-any.whl:
Publisher:
release.yml on captn3m0/kamsekam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kamsekam-0.1.0-py3-none-any.whl -
Subject digest:
15e5210d8808d7cad386b4cc4242913338ce8d765228e8f0e8c9c72feada9749 - Sigstore transparency entry: 2787687204
- Sigstore integration time:
-
Permalink:
captn3m0/kamsekam@f54a6057ce633e58f2f9a7aa183ab32fe25c63d1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/captn3m0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f54a6057ce633e58f2f9a7aa183ab32fe25c63d1 -
Trigger Event:
push
-
Statement type: