# API Integration (NEW)

The Website Unblocker API allows you to retrieve public web content through a simple HTTP endpoint without managing proxy infrastructure directly. It is designed to provide an accessible alternative to our proxy-based integration while retaining the same anti-bot capabilities, support for dynamic pages, and flexible request customization.

### Key Features

* Direct HTTP POST interface with JSON body
* No proxy string required
* Optional JavaScript rendering for dynamic pages
* Optional geolocation&#x20;
* Works with your existing NetNut credentials via Basic Auth

### API Setup

#### Endpoint

```url
https://unblocker.netnut.io/unblock
```

#### Authentication

Use HTTP Basic Authentication:

```json
Authorization: Basic base64(username:password)
```

***

#### Request Body Schema

```json
{
  "url": "https://example.com",     // Required
  "country": "us",                  // Optional
  "js_render": false,               // Optional, default is false
  "sid": "987654321",               // Optional
  "format": "html",                 // Optional, default is "html"
  "method": "GET"                   // Optional, default is "GET"
}
```

* **url**: The target page to fetch. *(Required)*

* **country**: Country geolocation for the request (`us` - United States, `uk` - United Kingdom, `fr` - France).\
  Default country is dynamically chosen for each URL. *(Optional)*

* **js\_render**: Set to `true` to enable JavaScript rendering for dynamic content. Boolean type. Defaults to `false`. *(Optional)*

  > ⚡ Note: We recommend keeping `js_render` disabled (`false`) unless the site requires it. Using `false` avoids unnecessary rendering; enable only when needed for dynamic content.

* **sid**: Maintain a sticky session by reusing the same IP across multiple requests. Accepts numeric values only (0–9). Recommended: 9-digit number for best stickiness. *(Optional)*

* **format**: Controls the response format.
  * `html` → returns HTML (default).
  * `raw` → returns the original format served by the URL (HTML if the page is HTML, JSON if the endpoint serves JSON). *(Optional)*

* **method**: HTTP method. Currently only supported value is `GET`. *(Optional)*

***

### Example Usage

{% tabs %}
{% tab title="cURL" %}
{% code lineNumbers="true" %}

```bash
curl -X POST https://unblocker.netnut.io/unblock \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic base64(username:password)" \
  -d '{
    "url": "https://example.com",
    "country": "fr",
    "format": "raw",
    "js_render": true,
    "sid":"987654321"
  }'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
from base64 import b64encode

headers = {
    "Authorization": "Basic " + b64encode(b"username:password").decode(),
    "Content-Type": "application/json"
}

body = {
    "url": "https://example.com",
    "country": "us",
    "format": "raw",
    "js_render": False,
}

response = requests.post("https://unblocker.netnut.io/unblock", headers=headers, json=body)
print(response.text)
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```javascript
const username = 'your_username';
const password = 'your_password';
const auth = Buffer.from(`${username}:${password}`).toString('base64');

const headers = {
  'Authorization': `Basic ${auth}`,
  'Content-Type': 'application/json'
};

const body = {
  url: 'https://example.com',
  country: 'us',
  format: 'raw',
  js_render: false
};

fetch('https://unblocker.netnut.io/unblock', {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(body)
})
.then(response => {
  if (!response.ok) throw new Error(`HTTP error ${response.status}`);
  return response.text(); // or use .json() if expecting JSON
})
.then(data => {
  console.log(data);
})
.catch(error => {
  console.error('Error:', error.message);
});


```

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

***

#### Response Format

#### HTML (Default)

```html
<!DOCTYPE html>
<html>
<head>...</head>
<body>...</body>
</html>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.netnut.io/netnut-documentation/netnut-scraper-apis/website-unblocker/api-integration-new.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
