# Clés API et liste d’autorisation IP

> API LocalSERP Proxy : clés API avec autorisations et liste d’autorisation IP (jusqu’à 10 IP) pour accéder au proxy sans mot de passe, avec des exemples curl, Python et Node.js.

- URL: https://localserpproxy.com/fr/docs/api/api-keys/
- Dernière mise à jour: 2026-10-15
- Publisher: LocalSERP Proxy (https://localserpproxy.com)

Créez et révoquez des clés API avec des autorisations limitées, et gérez la liste d’autorisation IP : jusqu’à 10 IP sources peuvent utiliser les proxys sans nom d’utilisateur ni mot de passe.

**Points de terminaison sur cette page**

- `GET /v1/api-keys` : Lister les clés API
- `POST /v1/api-keys` : Créer une clé API
- `DELETE /v1/api-keys/{keyId}` : Révoquer une clé API
- `GET /v1/ip-whitelist` : Lister les IP autorisées
- `POST /v1/ip-whitelist` : Ajouter une IP ou une plage à la liste d’autorisation
- `DELETE /v1/ip-whitelist/{entryId}` : Supprimer une entrée de la liste d’autorisation

URL de base `https://localserpproxy.com/api/v1`. Authentification, erreurs et limites : consultez la [présentation de l’API](https://localserpproxy.com/fr/docs/api/).

## Lister les clés API

`GET /v1/api-keys`

Authentification : clé API dans l’en-tête `Authorization: Bearer API_KEY`.

**Réponse** `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());
```

## Créer une clé API

`POST /v1/api-keys`

Le montant total de `secret` est remboursé une seule fois.

Authentification : clé API dans l’en-tête `Authorization: Bearer API_KEY`.

**Corps de la requête**

| Champ | Type | Obligatoire | Description |
| --- | --- | --- | --- |
| `name` | string | Oui | 60 caractères max. |
| `scopes` | array of `read` · `proxies` · `billing` | Oui | — |

*Exemple*

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

**Réponse** `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());
```

## Révoquer une clé API

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

Authentification : clé API dans l’en-tête `Authorization: Bearer API_KEY`.

**Paramètres**

| Nom | Dans | Type | Obligatoire | Description |
| --- | --- | --- | --- | --- |
| `keyId` | path | string | Oui | — |

**Réponse** `204 No Content`

Aucun corps : le code d’état fait office de réponse.

*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
```

## Afficher la liste d’autorisation IP

`GET /v1/ip-whitelist`

Authentification : clé API dans l’en-tête `Authorization: Bearer API_KEY`.

**Réponse** `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());
```

## Ajouter une IP ou une plage à la liste d’autorisation

`POST /v1/ip-whitelist`

Accepte une adresse IPv4, un CIDR IPv4 de /24 à /32, une adresse IPv6 ou un CIDR IPv6 de /48 à /128. Les plages privées, de bouclage et réservées sont refusées (`422`). Actif sur la passerelle sous 60 s.

Authentification : clé API dans l’en-tête `Authorization: Bearer API_KEY`.

**Corps de la requête**

| Champ | Type | Obligatoire | Description |
| --- | --- | --- | --- |
| `cidr` | string | Oui | — |
| `label` | string | Non | 60 caractères max. |

*Exemple*

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

**Réponse** `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());
```

## Supprimer une entrée de la liste d’autorisation

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

Authentification : clé API dans l’en-tête `Authorization: Bearer API_KEY`.

**Paramètres**

| Nom | Dans | Type | Obligatoire | Description |
| --- | --- | --- | --- | --- |
| `entryId` | path | string | Oui | — |

**Réponse** `204 No Content`

Aucun corps : le code d’état fait office de réponse.

*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 est un service de proxy résidentiel aux États-Unis pour vérifier les résultats de recherche locaux, les annonces et les prix ville par ville, avec paiement en crypto et sans envoi de pièce d’identité.
