# Chiavi API e IP consentiti

> API LocalSERP Proxy: API keys con autorizzazioni e IP allowlist (fino a 10 IP) per accedere ai proxy senza password, con esempi per curl, Python e Node.js.

- URL: https://localserpproxy.com/it/docs/api/api-keys/
- Ultimo aggiornamento: 2026-10-15
- Publisher: LocalSERP Proxy (https://localserpproxy.com)

Crea e revoca chiavi API con autorizzazioni limitate e gestisci gli IP consentiti: fino a 10 IP di origine possono usare i proxy senza nome utente e password.

**Endpoint in questa pagina**

- `GET /v1/api-keys`: Elenca le API keys
- `POST /v1/api-keys`: Crea un’API key
- `DELETE /v1/api-keys/{keyId}`: Revoca un’API key
- `GET /v1/ip-whitelist`: Elenca gli IP nell’allowlist
- `POST /v1/ip-whitelist`: Aggiungi un IP o un intervallo all’allowlist
- `DELETE /v1/ip-whitelist/{entryId}`: Rimuovi una voce dall’allowlist

URL di base `https://localserpproxy.com/api/v1`. Per autenticazione, errori e limiti, consulta la [panoramica dell’API](https://localserpproxy.com/it/docs/api/).

## Elenca le API keys

`GET /v1/api-keys`

Autenticazione: chiave API nell'intestazione `Authorization: Bearer API_KEY`.

**Risposta** `200 OK`

```json
{
  "data": [
    {
      "id": "key_5n2v8q",
      "name": "Rotation script",
      "prefix": "pk_4f9a2c",
      "scopes": [
        "read",
        "proxies"
      ],
      "createdAt": "2026-10-05T14:03:11Z",
      "lastUsedAt": null
    }
  ],
  "limit": 20
}
```

*curl*

```bash
curl -s "https://localserpproxy.com/api/v1/api-keys" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.get(f"{API}/api-keys", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/api-keys`, {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## Crea un’API key

`POST /v1/api-keys`

L’intero `secret` viene restituito una sola volta.

Autenticazione: chiave API nell'intestazione `Authorization: Bearer API_KEY`.

**Corpo della richiesta**

| Campo | Tipo | Obbligatorio | Descrizione |
| --- | --- | --- | --- |
| `name` | string | Sì | max. 60 caratteri |
| `scopes` | array of `read` · `proxies` · `billing` | Sì | — |

*Esempio*

```json
{
  "name": "Rotation script",
  "scopes": [
    "read",
    "proxies"
  ]
}
```

**Risposta** `201 Created`

```json
{
  "id": "key_5n2v8q",
  "name": "Rotation script",
  "prefix": "pk_4f9a2c",
  "scopes": [
    "read",
    "proxies"
  ],
  "createdAt": "2026-10-05T14:03:11Z",
  "lastUsedAt": null,
  "secret": "pk_4f9a2c8e1b7d3f6a9c2e5b8d1f4a7c0e"
}
```

*curl*

```bash
curl -s -X POST "https://localserpproxy.com/api/v1/api-keys" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Rotation script","scopes":["read","proxies"]}'
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.post(f"{API}/api-keys", headers=HEADERS, json={"name": "Rotation script", "scopes": ["read", "proxies"]}, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/api-keys`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ name: 'Rotation script', scopes: ['read', 'proxies'] }),
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## Revoca una chiave API

`DELETE /v1/api-keys/{keyId}`

Autenticazione: chiave API nell'intestazione `Authorization: Bearer API_KEY`.

**Parametri**

| Nome | In | Tipo | Obbligatorio | Descrizione |
| --- | --- | --- | --- | --- |
| `keyId` | path | string | Sì | — |

**Risposta** `204 No Content`

Nessun corpo: il codice di stato è la risposta.

*curl*

```bash
curl -s -X DELETE "https://localserpproxy.com/api/v1/api-keys/key_5n2v8q" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.delete(f"{API}/api-keys/key_5n2v8q", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.status_code)  # 204: done
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/api-keys/key_5n2v8q`, {
  method: 'DELETE',
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(res.status); // 204: done
```

## Elenca gli IP consentiti

`GET /v1/ip-whitelist`

Autenticazione: chiave API nell'intestazione `Authorization: Bearer API_KEY`.

**Risposta** `200 OK`

```json
{
  "data": [
    {
      "id": "ipw_8c1k2m",
      "cidr": "203.0.113.24",
      "label": "Office server",
      "createdAt": "2026-10-05T14:03:11Z"
    }
  ],
  "limit": 10
}
```

*curl*

```bash
curl -s "https://localserpproxy.com/api/v1/ip-whitelist" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.get(f"{API}/ip-whitelist", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/ip-whitelist`, {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## Aggiungi un IP o un intervallo agli IP consentiti

`POST /v1/ip-whitelist`

Accetta un indirizzo IPv4, un CIDR IPv4 da /24 a /32, un indirizzo IPv6 o un CIDR IPv6 da /48 a /128. Gli intervalli privati, di loopback e riservati vengono rifiutati (`422`). Attivo sul gateway entro 60 s.

Autenticazione: chiave API nell'intestazione `Authorization: Bearer API_KEY`.

**Corpo della richiesta**

| Campo | Tipo | Obbligatorio | Descrizione |
| --- | --- | --- | --- |
| `cidr` | string | Sì | — |
| `label` | string | No | max. 60 caratteri |

*Esempio*

```json
{
  "cidr": "203.0.113.24",
  "label": "Office server"
}
```

**Risposta** `201 Created`

```json
{
  "id": "ipw_8c1k2m",
  "cidr": "203.0.113.24",
  "label": "Office server",
  "createdAt": "2026-10-05T14:03:11Z"
}
```

*curl*

```bash
curl -s -X POST "https://localserpproxy.com/api/v1/ip-whitelist" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cidr":"203.0.113.24","label":"Office server"}'
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.post(f"{API}/ip-whitelist", headers=HEADERS, json={"cidr": "203.0.113.24", "label": "Office server"}, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/ip-whitelist`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ cidr: '203.0.113.24', label: 'Office server' }),
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## Rimuovi una voce dagli IP consentiti

`DELETE /v1/ip-whitelist/{entryId}`

Autenticazione: chiave API nell'intestazione `Authorization: Bearer API_KEY`.

**Parametri**

| Nome | In | Tipo | Obbligatorio | Descrizione |
| --- | --- | --- | --- | --- |
| `entryId` | path | string | Sì | — |

**Risposta** `204 No Content`

Nessun corpo: il codice di stato è la risposta.

*curl*

```bash
curl -s -X DELETE "https://localserpproxy.com/api/v1/ip-whitelist/ipw_8c1k2m" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.delete(f"{API}/ip-whitelist/ipw_8c1k2m", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.status_code)  # 204: done
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/ip-whitelist/ipw_8c1k2m`, {
  method: 'DELETE',
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(res.status); // 204: done
```

---

LocalSERP Proxy: LocalSERP Proxy è un servizio di proxy residenziali negli Stati Uniti per verificare risultati di ricerca locali, annunci e prezzi città per città, con pagamento in criptovalute e senza caricare documenti di identità.
