Skip to main content

pybatchexecute

Python package to ease interactions with Google's batchexecute batch RPC system. It assists in preparing requests for it and decoding responses returned from it.

This package codifies the research of Ryan Kovatch1 and Boudewijn van Groos2 about Google's /batchexecute endpoint used accross Google Web applications.

Usage

Prepare a request

>>> from pybatchexecute import PreparedBatchExecute
>>>
>>> # RPCs to call
>>> rpc1 = {"rpcid": "rpc1id", "args": ["some", "args"]}
>>> rpc2 = {"rpcid": "rpc2id", "args": ["some", "args"]}
>>>
>>> # Prepare request
>>> pbe = PreparedBatchExecute(
...     rpcs=[rpc1, rpc2],
...     host="example.com",
...     app="example",
... )
>>>
>>> # Access request attributes
>>> pbe.url
'https://example.com/_/example/data/batchexecute'
>>> pbe.headers
{'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'}
>>> pbe.params
{'rpcids': 'rpc1id,rpc2id', '_reqid': 3807}
>>> pbe.data
{'f.req': '[[["rpc1id","[\\"some\\",\\"args\\"]",null,"1"],["rpc2id","[\\"some\\",\\"args\\"]",null,"2"]]]'}

Use the url, headers, params and data attributes (optionally combined with your own, e.g. an at parameter1 or a Cookie header1 for authenticated requests) to make a POST request with the HTTP library of your choice (e.g. requests).

Decode a response

>>> from pybatchexecute import decode
>>>
>>> # Raw response
>>> # (from a request made with no `rt` parameter)
>>> raw_reponse = r"""
... )]}'
...
... [["wrb.fr","rpc1id","[\"some\",\"response1\"]",null,null,null,1],
... ["wrb.fr","rpc2id","[\"some\",\"response2\"]",null,null,null,2],
... ["di",38],
... ["af.httprm",37,"5314567270682293609",6],
... ["e",4,null,null,643]]
... """
>>>
>>> # Decode response
>>> # List of tuples (index, rpcid, response)
>>> decode(raw)
[(1, 'rpc1id', ['some', 'response1']), (2, 'rpc2id', ['some', 'response2'])]

Documentation

See docs/ for more:

Disclaimer

This project is not affiliated with Google. It is intended for use in accordance with Google's Terms of Service.

Licence

The MIT License (MIT) Copyright © 2023 Pierre Nicolas Durette

  1. Deciphering Google’s mysterious 'batchexecute' system 2 3

  2. November 2020 Google Translate API Changes

Release files for pybatchexecute 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybatchexecute 1.0.0
File Size Uploaded
pybatchexecute-1.0.0.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pybatchexecute 1.0.0
File Interpreter ABI Platform
pybatchexecute-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.1 kB

Release files / pybatchexecute-1.0.0.tar.gz

Download URL pybatchexecute-1.0.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2955e3f1a4b3f7b8a8136038d63c7cc9fd06ea4f3a79d6a60f6a62f3a13e0b3a
BLAKE2b-256 checksum
How to use checksums
b21e4f43e10a7c027d34ea68e98c7c9e78de07f27c63071b57f1694592648ca2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / pybatchexecute-1.0.0-py3-none-any.whl

Download URL pybatchexecute-1.0.0-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d205c8c1e2993b71ff9cbf7901a3dd5f8fae55da04e1ffac353bacc796e67a5b
BLAKE2b-256 checksum
How to use checksums
4c92089fe5adf48e556fb8ee0a1ae67375011c1e9406514edadba1fca6751ecf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page