The JSON Response feature transforms ZenRows’ standard HTML output into a structured JSON object containing the page content, network requests, and optional execution reports. This format provides comprehensive insights into page behavior, making it ideal for debugging, monitoring network activity, and analyzing dynamic content loading patterns.When you enable JSON Response with json_response=true, ZenRows captures not only the final HTML content but also all XHR, Fetch, and AJAX requests made during page rendering. This gives you complete visibility into how modern web applications load and update their content.
The JSON Response parameter requires js_render=true to function, as it monitors network activity and JavaScript execution within the browser environment.
JSON Response intercepts and records most network activity during JavaScript rendering, creating a comprehensive report of the page’s behavior. The browser monitors every HTTP request made by the page, including background API calls, resource loading, and dynamic content updates.This process captures:
All XHR and Fetch requests with full request/response details
The final rendered HTML content
Optional JavaScript instruction execution reports
Optional screenshot data of the rendered page
Complete request and response headers for network analysis
The data is structured in a JSON format making it easy to programmatically analyze page behavior and extract specific information from network requests.
This example returns a JSON object containing the HTML content and any network requests made during page rendering, instead of just the raw HTML string.
The JSON Response contains several key fields that provide different types of information. Here’s a complete example of what a typical JSON response looks like:
html - The complete rendered HTML content of the page as a string. This content is JSON-encoded and contains the final DOM state after all JavaScript execution and dynamic loading.
xhr - An array containing all XHR, Fetch, and AJAX requests made during page rendering. Each request object includes:
url - The complete URL of the request
body - The response body content
status_code - HTTP status code (200, 404, 500, etc.)
method - HTTP method used (GET, POST, PUT, DELETE, etc.)
headers - Response headers from the server
request_headers - Headers sent with the original request
js_instructions_report(Optional - only present when using JavaScript Instructions) - Detailed execution report including:
instructions_duration - Total execution time in milliseconds
instructions_executed - Number of instructions processed
instructions_succeeded - Number of successful instructions
instructions_failed - Number of failed instructions
instructions - Array of individual instruction details with parameters, success status, and timing
screenshot(Optional - only present when using the Screenshot feature) - Screenshot data containing:
AJAX-loaded content - When page content is loaded dynamically via XHR calls, JSON Response captures these API requests so you can access the raw data directly from the network calls rather than parsing it from the rendered HTML
API-dependent data - Content that appears after external API calls
Progressive loading - Pages that load content in stages
Conditional content - Elements that appear based on user state or preferences
Real-time applications - Capture live data feeds and WebSocket-like communications
Search platforms - Monitor search API calls and result loading patterns
Network troubleshooting - Identify failed requests or slow API calls
Content loading analysis - Understand how content loads in stages
Performance monitoring - Track request timing and response sizes
Integration testing - Verify that all expected API calls are made
Security analysis - Monitor for unexpected network activity
JavaScript Instructions debugging - When using JavaScript Instructions, JSON Response provides detailed execution reports to help debug instruction failures and timing issues
Focus on relevant requests to avoid information overload
Python
Copy
Ask AI
def filter_relevant_requests(xhr_requests, filters): """ Filter XHR requests based on specified criteria """ relevant_requests = [] for request in xhr_requests: include_request = True # Apply filters if 'methods' in filters: if request['method'] not in filters['methods']: include_request = False if 'status_codes' in filters: if request['status_code'] not in filters['status_codes']: include_request = False if 'url_contains' in filters: if not any(pattern in request['url'] for pattern in filters['url_contains']): include_request = False if 'exclude_extensions' in filters: if any(request['url'].endswith(ext) for ext in filters['exclude_extensions']): include_request = False if include_request: relevant_requests.append(request) return relevant_requests# Filter for API calls onlyapi_filters = { 'methods': ['GET', 'POST'], 'status_codes': [200, 201, 202], 'url_contains': ['/api/', '.json', '/v1/', '/v2/'], 'exclude_extensions': ['.css', '.js', '.png', '.jpg', '.gif', '.svg'],}api_requests = filter_relevant_requests(json_data['xhr'], api_filters)print(f"Found {len(api_requests)} relevant API requests")
When JSON responses become too large and exceed your plan’s limits:Response size exceeded error: If your response exceeds the maximum size allowed by your plan, you’ll receive an error indicating the limit has been reached.Solutions:
Upgrade your plan - Higher-tier plans support larger response sizes
Use Block Resources parameter - Remove unnecessary content like images, stylesheets, and scripts:
Filter XHR requests - Focus on specific API endpoints rather than capturing all network activity
Use shorter wait times - Reduce the time window to capture fewer requests
The Block Resources parameter can significantly reduce response sizes by preventing the loading of images, CSS files, JavaScript files, and fonts that aren’t essential for your scraping needs.
When expected API calls don’t appear in the XHR array:
1
Verify if XHR requests are actually made
Python
Copy
Ask AI
# Check if any requests were capturedif not json_data.get('xhr'): print("No network requests captured - verify page makes AJAX calls")else: print(f"Captured {len(json_data['xhr'])} requests")
2
Increase wait time for slow requests
Python
Copy
Ask AI
params = { 'js_render': 'true', 'json_response': 'true', 'wait': '10000', # Wait 10 seconds for slow API calls}
3
Use `wait_for` to ensure content loads
Python
Copy
Ask AI
params = { 'js_render': 'true', 'json_response': 'true', 'wait_for': '.api-loaded-content', # Wait for specific content}
The json_response parameter doesn’t increase the request cost. You pay the JavaScript Render (5 times the standard price) regardless of the wait value you choose.
Yes, the json_response parameter requires js_render=true because it monitors network activity that occurs during JavaScript execution. Without JavaScript rendering, there would be no XHR/Fetch requests to capture.
Will json_response capture all network requests made by the page?
JSON Response captures XHR, Fetch, and AJAX requests made during the page rendering process. It does not capture initial resource loading (like CSS, images, or the main HTML request), but focuses on dynamic API calls and background requests.
How large can the JSON response become?
The size depends on the number of network requests and their response sizes. Pages with many API calls can generate large JSON responses. Consider filtering requests or processing data in chunks for very active pages.
Can I get only the XHR data without the HTML content?
No, the JSON Response always includes both HTML and XHR data. However, you can ignore the HTML field in your processing and focus only on the XHR array if that’s all you need.
What happens if a network request fails during page loading?
Failed requests are still captured in the XHR array with their actual status codes (e.g., 404, 500). This allows you to analyze both successful and failed network activity.
Does json_response work with Premium Proxy?
Yes, JSON Response works perfectly with Premium Proxy. Network monitoring occurs within the browser environment, regardless of the type of proxy used.
Can I use json_response to monitor WebSocket connections?
No, JSON Response only captures HTTP-based requests (XHR, Fetch, AJAX). WebSocket connections use a different protocol and are not captured in the XHR array.
How do I handle pages that make requests after user interactions?
Use JavaScript Instructions to simulate user interactions (such as clicks and scrolls) before capturing the page. This will trigger additional network requests that will be included in the JSON response.