Rust Core API¶
Low-level Rust functions exposed to Python via PyO3.
Warning
These are low-level APIs. Most users should use the high-level AsyncClient instead.
core
¶
Playfast core module - High-performance Google Play scraping
This module provides low-level Rust functions for advanced users. Most users should use the high-level API from playfast.batch instead.
All functions release the GIL for true parallel execution.
Note: gil_used = false declares this module is safe to run without the GIL.
This only affects Python 3.14t (free-threading). On Python 3.13 and earlier,
this attribute is ignored and has no effect.
__all__ = ['parse_app_page', 'parse_review_batch', 'parse_search_results', 'extract_continuation_token', 'parse_batchexecute_list_response', 'build_list_request_body', 'parse_batchexecute_reviews_response', 'build_reviews_request_body', 'fetch_and_parse_app', 'fetch_and_parse_reviews', 'fetch_and_parse_search', 'fetch_and_parse_list', 'fetch_and_parse_apps_batch', 'fetch_and_parse_reviews_batch', 'fetch_and_parse_search_batch', 'fetch_and_parse_list_batch', 'extract_apk_info', 'extract_manifest_raw', 'parse_manifest_from_apk', 'extract_classes_from_apk', 'search_classes', 'search_methods', 'decode_bytecode', 'extract_constants', 'extract_method_calls', 'extract_methods_bytecode', 'get_method_bytecode_from_apk', 'create_method_resolver', 'resolve_method_from_apk', 'create_expression_builder', 'reconstruct_expressions_from_apk', 'decompile_class_from_apk', 'parse_resources_from_apk', 'analyze_entry_points_from_apk', 'build_call_graph_from_apk', 'build_call_graph_from_apk_parallel', 'create_data_flow_analyzer', 'find_flows_from_apk', 'find_webview_flows_from_apk', 'find_file_flows_from_apk', 'find_network_flows_from_apk', 'analyze_webview_flows_from_apk', 'create_webview_analyzer_from_apk', 'RustAppInfo', 'RustReview', 'RustSearchResult', 'RustPermission', 'RustDexClass', 'RustDexMethod', 'RustDexField', 'RustReferencePool', 'RustManifestInfo', 'IntentFilterData', 'ActivityIntentFilter', 'RustInstruction', 'MethodSignature', 'MethodResolverPy', 'ReconstructedExpression', 'ExpressionBuilderPy', 'DecompiledClass', 'DecompiledMethod', 'PyResourceResolver', 'PyResolvedResource', 'EntryPoint', 'ComponentType', 'PyEntryPointAnalyzer', 'CallGraph', 'CallPath', 'MethodCall', 'PyCallGraphBuilder', 'Flow', 'DataFlow', 'DataFlowAnalyzer', 'ClassFilter', 'MethodFilter', 'GpapiClient']
module-attribute
¶
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
__doc__ = 'Playfast core module - High-performance Google Play scraping\n\nThis module provides low-level Rust functions for advanced users.\nMost users should use the high-level API from playfast.batch instead.\n\nAll functions release the GIL for true parallel execution.\n\nNote: `gil_used = false` declares this module is safe to run without the GIL.\nThis only affects Python 3.14t (free-threading). On Python 3.13 and earlier,\nthis attribute is ignored and has no effect.'
module-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__file__ = '/home/runner/work/playfast/playfast/python/playfast/core.abi3.so'
module-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__name__ = 'playfast.core'
module-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
__package__ = 'playfast'
module-attribute
¶
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
analyze_entry_points_from_apk(apk_path)
builtin
¶
Analyze entry points from APK
analyze_webview_flows_from_apk(apk_path, max_depth)
builtin
¶
Backward compatibility: analyze_webview_flows_from_apk
build_call_graph_from_apk(apk_path, class_filter)
builtin
¶
Build a call graph from an APK file
build_call_graph_from_apk_parallel(apk_path, class_filter)
builtin
¶
Build a call graph from an APK file (parallel version - optimized)
build_list_request_body(category, collection, num=100)
builtin
¶
Build request body for batchexecute list API
This function generates the HTTP POST body required for the Google Play batchexecute API. Use this with Python's aiohttp for async HTTP + Rust parsing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str | None
|
Category code (e.g., "GAME_ACTION"), None for all apps |
required |
collection
|
str
|
Collection type (e.g., "topselling_free") |
required |
num
|
int
|
Number of results (default: 100, max: 250) |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
URL-encoded POST body ready for HTTP request |
Example
body = build_list_request_body("GAME_ACTION", "topselling_free", 200)
Use with aiohttp:¶
async with session.post(url, data=body) as response: ... text = await response.text() ... apps = parse_batchexecute_list_response(text)
build_reviews_request_body(app_id, sort, continuation_token, lang, country)
builtin
¶
Build request body for batchexecute reviews API
This function generates the HTTP POST body required for fetching reviews from the Google Play batchexecute API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_id
|
str
|
App package ID (e.g., "com.spotify.music") |
required |
sort
|
int
|
Sort order (1=newest, 2=highest rating, 3=most helpful) |
required |
continuation_token
|
str | None
|
Token for pagination (None for first page) |
required |
lang
|
str
|
Language code (e.g., "en") |
required |
country
|
str
|
Country code (e.g., "us") |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
URL-encoded POST body ready for HTTP request |
Example
body = build_reviews_request_body("com.spotify.music", 1, None, "en", "us")
Use with aiohttp:¶
async with session.post(url, data=body) as response: ... text = await response.text() ... reviews, next_token = parse_batchexecute_reviews_response(text)
create_data_flow_analyzer(apk_path)
builtin
¶
Create a data flow analyzer from APK
create_expression_builder(dex_data)
builtin
¶
Create an expression builder from DEX data
create_method_resolver(dex_data)
builtin
¶
Create a method resolver from DEX data (Python API)
create_webview_analyzer_from_apk(apk_path)
builtin
¶
Backward compatibility: create_webview_analyzer_from_apk
decode_bytecode(bytecode)
builtin
¶
Decode bytecode into instructions
decompile_class_from_apk(apk_path, class_name)
builtin
¶
Decompile entire class from APK
extract_apk_info(apk_path)
builtin
¶
Extract APK information including DEX count and manifest presence
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
apk_path
|
str
|
Path to the APK file |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
tuple[int, bool, bool, list[str]]
|
Dictionary with keys: dex_count, has_manifest, has_resources, dex_files |
Raises:
| Type | Description |
|---|---|
Exception
|
If APK cannot be opened or is invalid |
extract_classes_from_apk(apk_path, parallel=True)
builtin
¶
Extract all classes from an APK file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
apk_path
|
str
|
Path to the APK file |
required |
parallel
|
bool
|
Use parallel processing (default: True) |
True
|
Returns:
| Type | Description |
|---|---|
list[RustDexClass]
|
list[RustDexClass]: List of all classes from all DEX files |
Raises:
| Type | Description |
|---|---|
Exception
|
If APK cannot be opened or DEX parsing fails |
extract_constants(bytecode)
builtin
¶
Extract constant values from bytecode
extract_continuation_token(html)
builtin
¶
Extract continuation token for pagination
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
The HTML content |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Continuation token if found, None otherwise |
extract_manifest_raw(apk_path)
builtin
¶
Extract AndroidManifest.xml from APK (returns raw binary XML)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
apk_path
|
str
|
Path to the APK file |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
Raw AndroidManifest.xml binary data |
Raises:
| Type | Description |
|---|---|
Exception
|
If APK cannot be opened or manifest not found |
extract_method_calls(bytecode)
builtin
¶
Extract method calls from bytecode
extract_methods_bytecode(apk_path, classes)
builtin
¶
Extract bytecode for methods from classes in an APK
This is a simplified version that extracts bytecode for methods by searching through DEX files in the APK.
fetch_and_parse_app(app_id, lang, country, _timeout=30)
builtin
¶
Fetch and parse app information (combined HTTP + parsing, GIL-free)
This function performs both HTTP request and parsing in Rust, releasing the GIL for true parallel execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_id
|
str
|
The app package ID (e.g., "com.spotify.music") |
required |
lang
|
str
|
Language code (e.g., "en") |
required |
country
|
str
|
Country code (e.g., "us") |
required |
timeout
|
int
|
Request timeout in seconds (default: 30) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RustAppInfo |
RustAppInfo
|
Parsed app information |
Raises:
| Type | Description |
|---|---|
Exception
|
If request or parsing fails |
fetch_and_parse_apps_batch(requests)
builtin
¶
Batch fetch and parse multiple app pages in parallel (TRUE parallelism in Rust!)
This function processes multiple app requests concurrently within a single
Rust async runtime, avoiding the overhead of multiple block_on calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requests
|
list[tuple]
|
List of (app_id, lang, country) tuples |
required |
Returns:
| Type | Description |
|---|---|
list[RustAppInfo]
|
list[RustAppInfo]: List of parsed app information (same order as input) |
Raises:
| Type | Description |
|---|---|
Exception
|
If any request fails |
Example
requests = [ ... ("com.spotify.music", "en", "us"), ... ("com.netflix.mediaclient", "en", "us"), ... ("com.whatsapp", "en", "us"), ... ] apps = fetch_and_parse_apps_batch(requests)
fetch_and_parse_list(category, collection, lang, country, num=100, _timeout=30)
builtin
¶
Fetch and parse list results (combined HTTP + parsing, GIL-free)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str | None
|
Category code (e.g., "GAME_ACTION"), None for all apps |
required |
collection
|
str
|
Collection type (e.g., "topselling_free") |
required |
lang
|
str
|
Language code |
required |
country
|
str
|
Country code |
required |
num
|
int
|
Number of results (default: 100, max: 250) |
100
|
timeout
|
int
|
Request timeout in seconds (default: 30) |
required |
Returns:
| Type | Description |
|---|---|
list[RustSearchResult]
|
list[RustSearchResult]: List of apps in the category/collection |
Raises:
| Type | Description |
|---|---|
Exception
|
If request or parsing fails |
fetch_and_parse_list_batch(requests)
builtin
¶
Batch fetch and parse multiple list requests in parallel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requests
|
list[tuple]
|
List of (category, collection, lang, country, num) tuples where category can be None |
required |
Returns:
| Type | Description |
|---|---|
list[list[RustSearchResult]]
|
list[list[RustSearchResult]]: List of result lists (same order as input) |
Raises:
| Type | Description |
|---|---|
Exception
|
If any request fails |
Example
requests = [ ... (None, "topselling_free", "en", "us", 100), ... ("GAME_ACTION", "topselling_free", "en", "kr", 100), ... ] results = fetch_and_parse_list_batch(requests)
fetch_and_parse_reviews(app_id, lang, country, sort=1, continuation_token=None, _timeout=30)
builtin
¶
Fetch and parse reviews (combined HTTP + parsing, GIL-free)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_id
|
str
|
The app package ID |
required |
lang
|
str
|
Language code |
required |
country
|
str
|
Country code |
required |
sort
|
int
|
Sort order (1=newest, 2=highest, 3=most helpful) |
1
|
continuation_token
|
str | None
|
Token for pagination |
None
|
timeout
|
int
|
Request timeout in seconds (default: 30) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[list[RustReview], str | None]
|
(list[RustReview], str | None) - Reviews and next token |
Raises:
| Type | Description |
|---|---|
Exception
|
If request or parsing fails |
fetch_and_parse_reviews_batch(requests)
builtin
¶
Batch fetch and parse multiple review requests in parallel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requests
|
list[tuple]
|
List of (app_id, lang, country, sort, continuation_token) tuples |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[list[RustReview], str | None]]
|
list[tuple]: List of (reviews, next_token) tuples (same order as input) |
Raises:
| Type | Description |
|---|---|
Exception
|
If any request fails |
fetch_and_parse_search(query, lang, country, _timeout=30)
builtin
¶
Fetch and parse search results (combined HTTP + parsing, GIL-free)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Search query string |
required |
lang
|
str
|
Language code |
required |
country
|
str
|
Country code |
required |
timeout
|
int
|
Request timeout in seconds (default: 30) |
required |
Returns:
| Type | Description |
|---|---|
list[RustSearchResult]
|
list[RustSearchResult]: List of search results |
Raises:
| Type | Description |
|---|---|
Exception
|
If request or parsing fails |
fetch_and_parse_search_batch(requests)
builtin
¶
Batch fetch and parse multiple search queries in parallel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requests
|
list[tuple]
|
List of (query, lang, country) tuples |
required |
Returns:
| Type | Description |
|---|---|
list[list[RustSearchResult]]
|
list[list[RustSearchResult]]: List of search results (same order as input) |
Raises:
| Type | Description |
|---|---|
Exception
|
If any request fails |
find_file_flows_from_apk(apk_path, max_depth)
builtin
¶
Convenience: Find file I/O flows from APK
find_flows_from_apk(apk_path, sink_patterns, max_depth)
builtin
¶
Find flows from entry points to sink patterns
find_network_flows_from_apk(apk_path, max_depth)
builtin
¶
Convenience: Find network flows from APK
find_webview_flows_from_apk(apk_path, max_depth)
builtin
¶
Convenience: Find WebView flows from APK
get_method_bytecode_from_apk(apk_path, class_name, method_name)
builtin
¶
Get bytecode for a specific method by name
Searches through all DEX files in an APK until it finds the method.
parse_app_page(html, app_id)
builtin
¶
Parse app information from HTML (CPU-intensive, GIL-free operation)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
The HTML content of the app page |
required |
app_id
|
str
|
The app ID (e.g., "com.spotify.music") |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RustAppInfo |
RustAppInfo
|
Parsed app information |
Raises:
| Type | Description |
|---|---|
Exception
|
If parsing fails |
parse_batchexecute_list_response(response_text)
builtin
¶
Parse batchexecute API response for list/category results (CPU-intensive, GIL-free operation)
This parses the response from Google Play's batchexecute API endpoint used for category/collection listings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response_text
|
str
|
The raw text response from batchexecute API |
required |
Returns:
| Type | Description |
|---|---|
list[RustSearchResult]
|
list[RustSearchResult]: List of parsed app results |
Raises:
| Type | Description |
|---|---|
Exception
|
If parsing fails |
parse_batchexecute_reviews_response(response_text)
builtin
¶
Parse batchexecute API response for reviews
This parses the response from Google Play's batchexecute API endpoint used for fetching reviews.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response_text
|
str
|
The raw text response from batchexecute API |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[list[RustReview], str | None]
|
(list[RustReview], str | None) - Reviews and next continuation token |
Raises:
| Type | Description |
|---|---|
Exception
|
If parsing fails |
parse_manifest_from_apk(apk_path)
builtin
¶
Parse AndroidManifest.xml from APK
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
apk_path
|
str
|
Path to the APK file |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RustManifestInfo |
RustManifestInfo
|
Parsed manifest information including package name, version, permissions, activities, services, etc. |
Raises:
| Type | Description |
|---|---|
Exception
|
If APK cannot be opened, manifest not found, or parsing fails |
parse_resources_from_apk(apk_path)
builtin
¶
Parse resources.arsc from APK
parse_review_batch(html)
builtin
¶
Parse batch of reviews from HTML (CPU-intensive, GIL-free operation)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
The HTML content containing reviews |
required |
Returns:
| Type | Description |
|---|---|
list[RustReview]
|
list[RustReview]: List of parsed reviews |
Raises:
| Type | Description |
|---|---|
Exception
|
If parsing fails |
parse_search_results(html)
builtin
¶
Parse search results from HTML
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
The HTML content of search results page |
required |
Returns:
| Type | Description |
|---|---|
list[RustSearchResult]
|
list[RustSearchResult]: List of search results |
Raises:
| Type | Description |
|---|---|
Exception
|
If parsing fails |
reconstruct_expressions_from_apk(apk_path, class_name, method_name)
builtin
¶
Reconstruct expressions from APK
resolve_method_from_apk(apk_path, method_idx)
builtin
¶
Resolve method index from APK
Searches through all DEX files in the APK until it finds the method index.
search_classes(apk_path, filter, limit=None, parallel=True)
builtin
¶
Search for classes matching a filter in an APK
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
apk_path
|
str
|
Path to the APK file |
required |
filter
|
ClassFilter
|
Filter criteria for class search |
required |
limit
|
int | None
|
Maximum number of results (default: None = no limit) |
None
|
parallel
|
bool
|
Use parallel processing (default: True) |
True
|
Returns:
| Type | Description |
|---|---|
list[RustDexClass]
|
list[RustDexClass]: List of matching classes |
Raises:
| Type | Description |
|---|---|
Exception
|
If APK cannot be opened or search fails |
search_methods(apk_path, class_filter, method_filter, limit=None, parallel=True)
builtin
¶
Search for methods matching a filter in specific classes from an APK
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
apk_path
|
str
|
Path to the APK file |
required |
class_filter
|
ClassFilter
|
Filter for selecting classes |
required |
method_filter
|
MethodFilter
|
Filter for selecting methods |
required |
limit
|
int | None
|
Maximum number of results (default: None = no limit) |
None
|
parallel
|
bool
|
Use parallel processing (default: True) |
True
|
Returns:
| Type | Description |
|---|---|
list[RustDexMethod]
|
list[tuple[RustDexClass, RustDexMethod]]: List of (class, method) tuples |
Raises:
| Type | Description |
|---|---|
Exception
|
If APK cannot be opened or search fails |
options: show_source: false show_root_heading: true show_if_no_docstring: false filters: - "!^_" - "!^__" members: - parse_app_page - parse_review_batch - parse_search_results - parse_batchexecute_list_response - parse_batchexecute_reviews_response - fetch_and_parse_app - fetch_and_parse_reviews - fetch_and_parse_search - fetch_and_parse_list - build_list_request_body - build_reviews_request_body - extract_continuation_token - RustAppInfo - RustReview - RustSearchResult - RustPermission