# Full JSON Response

The default response body received from the BrowserAPI contains the plain HTML scraped from the targeted URL. This approach is ideal for HTML parsing, however it can be harder to integrate with third party apps that only accept JSON format.

If you want BrowserAPI to organise the response in a JSON format, all you have to do is to add `json_response=1` to your request. The format of the response will then be:

<table><thead><tr><th width="241">Element</th><th width="115" align="center">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>headers</code></td><td align="center"><code>Object</code></td><td><code>key</code> : <code>value</code> pair of haders received from the server.</td></tr><tr><td><code>initial-status-code</code></td><td align="center"><code>int</code></td><td>Status code received from the server.</td></tr><tr><td><code>resolved-url</code></td><td align="center"><code>string</code></td><td>URL in case of redirects.</td></tr><tr><td><code>body</code></td><td align="center"><code>string</code></td><td>Scraped content.</td></tr><tr><td><code>type</code></td><td align="center"><code>string</code></td><td>Response type. Can be <code>html</code> , <code>json</code> or <code>b64</code> (for files, images, PDFs etc.)</td></tr><tr><td><code>screenshot</code></td><td align="center"><code>string</code></td><td>base64 encrypted image.</td></tr><tr><td><code>cookies</code></td><td align="center"><code>Array</code></td><td>Array of cookies sent from the server.</td></tr><tr><td><code>xhr</code></td><td align="center"><code>Array</code></td><td>Array of XHR / Ajax requests sent by the browser durring scraping.</td></tr><tr><td><code>metadata</code></td><td align="center"><code>Object</code></td><td>Microdata and JSON-LD extracted from the HTML file.</td></tr></tbody></table>

Your full **GET** request should then be sent to the following address:

{% code overflow="wrap" %}

```
https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=<TARGETED_URL>&json_response=1
```

{% endcode %}

### Full JSON Response Integration Examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl --request GET --url "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://httpbin.org/&screenshot=1&json_response=1&extract_rules=%7B%22paragraphs%22%3A%7B%22selector%22%3A%20%22p%22%2C%22output%22%3A%22html%22%7D%7D"
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}
{% code overflow="wrap" %}

```javascript
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.webscrapingapi.com",
  "port": null,
  "path": "/v1?api_key=<YOUR_API_KEY>&url=https://httpbin.org/&screenshot=1&json_response=1&extract_rules=%7B%22paragraphs%22%3A%7B%22selector%22%3A%20%22p%22%2C%22output%22%3A%22html%22%7D%7D",
  "headers": {}
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests

API_KEY = '<YOUR_API_KEY>'
SCRAPER_URL = 'https://api.webscrapingapi.com/v1'

TARGET_URL = 'https://httpbin.org/'

PARAMS = {
    "api_key":API_KEY,
    "url": TARGET_URL,
    "screenshot":1,
    "render_js":1,
    "extract_rules":'{"paragraphs":{"selector": "p","output":"html"}}',
    "json_response":1
}

response = requests.get(SCRAPER_URL, params=PARAMS)

print(response)
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code overflow="wrap" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://httpbin.org/&screenshot=1&json_response=1&extract_rules=%7B%22paragraphs%22%3A%7B%22selector%22%3A%20%22p%22%2C%22output%22%3A%22html%22%7D%7D",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code overflow="wrap" %}

```go
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://httpbin.org/&screenshot=1&json_response=1&extract_rules=%7B%22paragraphs%22%3A%7B%22selector%22%3A%20%22p%22%2C%22output%22%3A%22html%22%7D%7D"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code overflow="wrap" %}

```java
HttpResponse<String> response = Unirest.get("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://httpbin.org/&screenshot=1&json_response=1&extract_rules=%7B%22paragraphs%22%3A%7B%22selector%22%3A%20%22p%22%2C%22output%22%3A%22html%22%7D%7D")
  .asString();
```

{% endcode %}
{% endtab %}

{% tab title=".NET" %}
{% code overflow="wrap" %}

```csharp
var client = new RestClient("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://httpbin.org/&screenshot=1&json_response=1&extract_rules=%7B%22paragraphs%22%3A%7B%22selector%22%3A%20%22p%22%2C%22output%22%3A%22html%22%7D%7D");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code overflow="wrap" %}

```ruby
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://httpbin.org/&screenshot=1&json_response=1&extract_rules=%7B%22paragraphs%22%3A%7B%22selector%22%3A%20%22p%22%2C%22output%22%3A%22html%22%7D%7D")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="danger" %} <mark style="color:red;">**Important!**</mark> The `url` parameter has to be encoded.

*( i.e. **\&url=https%3A%2F%2Fwww\.webscrapingapi.com%2F** )*
{% endhint %}

<details>

<summary>Response Example</summary>

{% code overflow="wrap" %}

```
{
    "headers": {
        "access-control-allow-credentials": "true",
        "access-control-allow-origin": "*",
        "content-length": "9593",
        "content-type": "text/html; charset=utf-8",
        "date": "Fri, 23 Sep 2022 09:05:27 GMT",
        "server": "gunicorn/19.9.0"
    },
    "cost": 1,
    "initial-status-code": 200,
    "resolved-url": "https://httpbin.org/",
    "body": "{\"screenshot\":\"/9j/4AAQSkZJRgABAQAAAQABAAD/...",
    "cookies": [],
    "evaluate_results": "{\"paragraphs\":[\"<p>A simple HTTP Request &amp; Response Service.\\n                                        <br>\\n                                        <br>\\n                                        <b>Run locally: </b>\\n                                        <code>$ docker run -p 80:80 kennethreitz/httpbin</code>\\n                                    </p>\"]}",
    "xhr": [],
    "metadata": {
        "microdata": {
            "items": []
        },
        "json-ld": []
    }
}
```

{% endcode %}

</details>
