# Webhook Integration

You can even collect the scraped data to your favorite database. You just need to add a webhook URL and the scraped data will be submitted to your target destination.

### Where to add the Webhook URL?

Once you log in to your dashboard you can click on Add Webhook URL button.

<figure><img src="https://3220516214-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvE2Vtwnb3KioBGnU6f6o%2Fuploads%2FjqxSR3iC8NYIq1VwXtYB%2Fimage.png?alt=media&#x26;token=9c1ccfd9-30e3-4cba-ae5c-04e48648caab" alt=""><figcaption></figcaption></figure>

### Once you click&#x20;

Once you click on that button you will find a box where you will be asked to paste your webhook url.&#x20;

<figure><img src="https://3220516214-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvE2Vtwnb3KioBGnU6f6o%2Fuploads%2FSE61VW4VOp66SU0G7xct%2Fimage.png?alt=media&#x26;token=1020d30c-908a-411d-a544-e767d1a03bbc" alt=""><figcaption></figcaption></figure>

You will also be asked to name this webhook. This name should be unique as it will be later used to identify the target storage URL. This webhook URL should be a POST API.\ <br>

### Parameters <a href="#parameters" id="parameters"></a>

| Parameter         | Description                                                                                                                                                                                               |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| api\_key required | <p>Your personal API key. Available on your dashboard <br><br>Type: <em><strong>String</strong></em></p>                                                                                                  |
| url required      | <p>URL of the page you want to scrape. <br><br>Type: <em><strong>String</strong></em></p>                                                                                                                 |
| dynamic           | <p>It tells our server whether you want to render JS or not. It can be either <strong>true or false</strong>. By default it is <strong>true</strong>. <br><br>Type: <em><strong>Boolean</strong></em></p> |
| webhook\_id       | <p>This is the name of the webhook.<br><br>Type: <em><strong>String</strong></em></p>                                                                                                                     |

### Usage

{% tabs %}
{% tab title="Curl" %}

<pre class="language-bash"><code class="lang-bash"><strong>curl "https://api.scrapingdog.com/webhook?api_key=5e5a97e5b1ca5b194f42da86&#x26;webhook_id=random_name&#x26;url=http://httpbin.org/ip&#x26;dynamic=false"
</strong></code></pre>

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.scrapingdog.com/webhook"

params = {
    "api_key": "5e5a97e5b1ca5b194f42da86",
    "url": "http://httpbin.org/ip",
    "dynamic": "false",
    "webhook_id":"random_name"
}

response = requests.get(url, params=params)

print(response.text)
```

{% endtab %}

{% tab title="Nodejs" %}

```javascript
const axios = require('axios');

const apiUrl = 'https://api.scrapingdog.com/webhook';
const apiKey = '5e5a97e5b1ca5b194f42da86';
const targetUrl = 'http://httpbin.org/ip';
const dynamic = false;
const webhookName = "random_name"

const params = {
  api_key: apiKey,
  url: targetUrl,
  dynamic: dynamic.toString(),
  webhook_id:webhookName
};

axios
  .get(apiUrl, { params })
  .then((response) => {
    if (response.status === 200) {
      console.log(response.data);
    } else {
      console.error(`Failed to retrieve data. Status code: ${response.status}`);
    }
  })
  .catch((error) => {
    console.error('An error occurred:', error.message);
  });



```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$apiUrl = 'https://api.scrapingdog.com/webhook';
$apiKey = '5e5a97e5b1ca5b194f42da86';
$targetUrl = 'http://httpbin.org/ip';
$dynamic = false;
$webhook_id = "random_name"

$queryParams = [
    'api_key' => $apiKey,
    'url' => $targetUrl,
    'dynamic' => $dynamic,
    'webhook_id' => $webhook_id
];

$queryString = http_build_query($queryParams);

$fullUrl = $apiUrl . '?' . $queryString;

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $fullUrl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

if ($response === false) {
    echo 'cURL error: ' . curl_error($curl);
} else {
    $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ($httpCode === 200) {
        echo $response;
    } else {
        echo 'Failed to retrieve data. Status code: ' . $httpCode;
    }
}

curl_close($curl);
?>

```

{% endtab %}

{% tab title="Ruby" %}

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

api_url = 'https://api.scrapingdog.com/webhook'
api_key = '5e5a97e5b1ca5b194f42da86'
target_url = 'http://httpbin.org/ip'
dynamic = false
webhook_id = 'random_name'

uri = URI.parse(api_url)
params = {
  'api_key' => api_key,
  'url' => target_url,
  'dynamic' => dynamic
  'webhook_id' = > webhook_id
}

uri.query = URI.encode_www_form(params)

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri.request_uri)

response = http.request(request)

if response.code == '200'
  puts response.body
else
  puts "Failed to retrieve data. Status code: #{response.code}"
end

```

{% endtab %}

{% tab title="Java" %}

```
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class ScrapingDogAPITest {
    public static void main(String[] args) {
        try {
            String apiUrl = "https://api.scrapingdog.com/webhook";
            String apiKey = "5e5a97e5b1ca5b194f42da86";
            String targetUrl = "http://httpbin.org/ip";
            String webhook_id = "random_name";
            boolean dynamic = false;

            // Construct the query parameters
            Map<String, String> params = new HashMap<>();
            params.put("api_key", apiKey);
            params.put("url", targetUrl);
            params.put("webhook_id", webhook_id);
            params.put("dynamic", String.valueOf(dynamic));

            // Build the query URL
            StringBuilder query = new StringBuilder(apiUrl);
            query.append("?");
            for (Map.Entry<String, String> entry : params.entrySet()) {
                query.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
            }
            String queryUrl = query.toString().substring(0, query.length() - 1);

            // Create an HTTP connection and set up the request
            URL url = new URL(queryUrl);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");

            // Get the response code
            int responseCode = connection.getResponseCode();

            if (responseCode == HttpURLConnection.HTTP_OK) {
                // Read and print the response
                BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String inputLine;
                StringBuilder response = new StringBuilder();

                while ((inputLine = in.readLine()) != null) {
                    response.append(inputLine);
                }

                in.close();
                System.out.println(response.toString());
            } else {
                System.out.println("Failed to retrieve data. Status code: " + responseCode);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}
{% endtabs %}

### Response <a href="#response" id="response"></a>

```json
{
    "sid": "4286cfd7-4752-4f6b-8cc6-df01a8ac3ce3"
}
```

###
