Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Minimal Request Finder is a analysis tool to determine the minimum valid API request data (including headers, query params, and payload) required to receive a valid response from an endpoint. It is designed to help in the process of reverse engineering complex third party API's and identifying the smallest, most efficient request that can be made.
minimalrequest
is a analysis tool to determine the minimum valid API request data (including headers, query params, and payload) required to receive a valid response from an endpoint. It is designed to help in the process of reverse engineering complex third party API's and identifying the smallest, most efficient request that can be made.
pip install minimalrequest
minimalrequest
works by applying a simple algorithm to pare down requests.
All functionality is exposed through the minimal_request_finder
function.
from minimalrequest import minimal_request_finder
Initial requests can be passed as a curl command:
result = minimal_request_finder(
curl="""
curl -XPOST -H 'header-one: one' -H 'header-two: two' -H 'header-three: three' -H "Content-Type: application/json" -d '{
"property1": {"subproperty1": "one", "subproperty2": "two"},
"property2": [1, 2, 3, 4, 5]
}' 'https://api.com/endpoint/v1/test?param1=1¶m2=2¶m3=3'
"""
)
or can be passed as individual arguments:
result = minimal_request_finder(
http_method="post",
url="https://api.com/endpoint/v1/test",
query_params={"param1": "value", "param2": "value"},
headers={"Content-Type": "application/json"},
payload={"requestData": {"query": "test", "pages": 2}}
)
Results are returned as a MinimalRequestResult
which contains the url
and minimal query_params
, headers
, and payload
.
The minimal_request_finder
function accepts an equivalency_mode
argument to change the method used to check equivalency between the reference response and test responses.
Setting the equivalency_mode
to exact
(it's default value) will only consider the test response and reference to be equivalent when their parsed Python object representations are exactly the same (==
). This mode is intended for API's with a completely deterministic output based on each input.
The types
equivalency mode compares each response object property or array element for data type equivalency rather than exact values. This mode can be useful any time an API response should have constant data structure, but some amount of variable or random content, such as a timestamp or hash value.
The types
mode works with the types_check_exact_list_equivalency
flag (defaults to True
). If set to False
, the equivalency check allows the number of elements in arrays throughout the response to vary in length between the test and reference response as long as any existing array elements pass the type check. This flag can be useful if your API response contains arrays of variable or random length, such as events over a given time period.
For highly variable API responses that might not work with other modes, the size
equivalency mode can be used. This check converts the reference and test responses into JSON string representations and passes equivalency if the test response size in bytes is within some percent tolerance of the reference response size. The size_equivalency_tolerance
argument (default value of 0.05) sets this tolerance value.
FAQs
Minimal Request Finder is a analysis tool to determine the minimum valid API request data (including headers, query params, and payload) required to receive a valid response from an endpoint. It is designed to help in the process of reverse engineering complex third party API's and identifying the smallest, most efficient request that can be made.
We found that minimalrequest demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.