Create proxy replacement
This endpoint lets you create a proxy replacements which replaces proxies from your proxy list.
The proxies_removed
and proxies_added
must always match.
Cannot create proxy replacement if plan.pool_filter
is residential
.
POST https://proxy.webshare.io/api/v2/proxy/replace/
Parameters
Attributes | Type | Description |
---|---|---|
to_replace | dict | Dictionary indicating which proxies to replace. |
replace_with | list | List of dictionaries indicating which proxies to replace with. |
dry_run | bool | You can dry-run a replacement to learn number of proxies removed/added prior to actually replacing the proxy list. |
Request & Response
create_replacement.py
import requests
response = requests.post(
"https://proxy.webshare.io/api/v2/proxy/replace/",
json={
"to_replace": {"type": "ip_range", "ip_ranges": ["1.2.3.0/24"]},
"replace_with": [{"type": "country", "country_code": "US"}],
"dry_run": False
},
headers={"Authorization": "Token APIKEY"}
)
response.json()
The commands above return JSON structured like this:
response.json
{
"id": 98315,
"reason": "proxy_replaced",
"to_replace": {"type": "ip_range", "ip_ranges": ["1.2.3.0/24"]},
"replace_with": [{"type": "country", "country_code": "US"}],
"dry_run": false,
"state": "completed",
"proxies_removed": 1,
"proxies_added": 1,
"created_at": "2022-07-26T21:25:13.966946-07:00",
"completed_at": "2022-07-26T21:25:13.966946-07:00",
}
400 Error Types
Error Code | HTTP Code | Description |
---|---|---|
proxies_removed_doesnt_match_added | 400 | There is a mismach between added and replaced proxies. |
not_enough_replacements_in_subscription | 400 | Account holder doesn't have enough proxy replacements. |