### Python Source: https://github.com/akjong/webshare-rs/blob/master/docs/downloads/get_download_token.md Example of how to get a download token using Python. ```python import requests response = requests.post( "https://proxy.webshare.io/api/v2/download_token/activity/", headers={"Authorization": "Token APIKEY"} ) response.json() ``` -------------------------------- ### JavaScript Source: https://github.com/akjong/webshare-rs/blob/master/docs/downloads/get_download_token.md Example of how to get a download token using JavaScript. ```javascript fetch("https://proxy.webshare.io/api/v2/download_token/activity/", { "method": "POST", "headers": { "Authorization": "Token APIKEY" } }).then(response => response.json()) .then(data => console.log(data)) ``` -------------------------------- ### Start Verification Request Source: https://github.com/akjong/webshare-rs/blob/master/docs/idverification/start.md Example of how to start an ID verification using a POST request. ```Python import requests response = requests.post( "https://proxy.webshare.io/api/v2/idverification/start/", json={} ) response.json() ``` ```Javascript fetch("https://proxy.webshare.io/api/v2/idverification/start/", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({}) }) .then(response => response.json()) .then(data => console.log(data)); ``` ```cURL curl -X POST https://proxy.webshare.io/api/v2/idverification/start/ -H "Content-Type: application/json" -d "{} ``` -------------------------------- ### Ordering Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/index.md Example of how to use the 'ordering' parameter in a GET request. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v2/payment/transaction/?ordering=status,-created_at" ) response.json() ``` -------------------------------- ### Python example Source: https://github.com/akjong/webshare-rs/blob/master/docs/subscription/assets.md Example of how to get available assets using Python. ```python import requests import json response = requests.get( "https://proxy.webshare.io/api/v2/subscription/available_assets/", headers={"Authorization": "Token APIKEY"} ) response.json() ``` -------------------------------- ### Quick Start Example Source: https://github.com/akjong/webshare-rs/blob/master/README.md A basic example demonstrating how to initialize the client, list proxies, and fetch user profile information. ```rust use webshare_rs::{WebshareClient, Result}; #[tokio::main] async fn main() -> Result<()> { let client = WebshareClient::builder() .api_key("your_api_key_here") .build()?; // List your proxies (first page, 25 per page) let proxies = client.proxy_list().list(25, 0).await?; println!("Total proxies: {}", proxies.count); for proxy in proxies.results { println!(" {}:{} ({})", proxy.proxy_address, proxy.port, proxy.country_code); } // Fetch your user profile let profile = client.user_profile().retrieve().await?; println!("Logged in as: {} {}", profile.first_name, profile.last_name); Ok(()) } ``` -------------------------------- ### Get proxy replacement example Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxy-replacement/proxy_replacement/proxy_replacement_retrieve.md This example shows how to retrieve an existing proxy replacement using its ID. It also demonstrates how to target a specific plan using the `plan_id` query parameter. ```Python import requests response = requests.post( "https://proxy.webshare.io/api/v3/proxy/replace//", headers={"Authorization": "Token APIKEY"} ) response.json() ``` ```cURL GET https://proxy.webshare.io/api/v3/proxy/replace/{ID}/ or in case of targeting a specific plan POST https://proxy.webshare.io/api/v3/proxy/replace/{ID}/?plan_id= ``` -------------------------------- ### Search Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/index.md Example of how to use the 'search' parameter in a GET request. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v2/payment/transaction/?search=Free" ) response.json() ``` -------------------------------- ### Javascript example Source: https://github.com/akjong/webshare-rs/blob/master/docs/subscription/assets.md Example of how to get available assets using Javascript. ```javascript fetch("https://proxy.webshare.io/api/v2/subscription/available_assets/", { "headers": { "Authorization": "Token APIKEY" }, "method": "GET" }) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err)); ``` -------------------------------- ### Python Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxy-config/get_proxy_config.md Example of how to get proxy config using Python. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v3/proxy/config?plan_id=PLAN-ID", headers={ "Authorization": "Token APIKEY" } ) response.json() ``` -------------------------------- ### cURL Source: https://github.com/akjong/webshare-rs/blob/master/docs/downloads/get_download_token.md Example of how to get a download token using cURL. ```bash curl -X POST https://proxy.webshare.io/api/v2/download_token/activity/ \ -H "Authorization: Token APIKEY" ``` -------------------------------- ### Python example Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxy-config/get_proxy_status.md This is a Python example of how to get the proxy status. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v3/proxy/list/status?plan_id=PLAN-ID", headers={ "Authorization": "Token APIKEY" } ) response.json() ``` -------------------------------- ### cURL example Source: https://github.com/akjong/webshare-rs/blob/master/docs/subscription/assets.md Example of how to get available assets using cURL. ```curl curl -X GET "https://proxy.webshare.io/api/v2/subscription/available_assets/" \ -H "Authorization: Token APIKEY" ``` -------------------------------- ### Python Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/idverification/retrieve.md Example of how to retrieve ID verification using Python. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v2/idverification/", headers={"Authorization": "Token APIKEY"} ) response.json() ``` -------------------------------- ### Python Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/ipauthorization/list.md Example of how to list IP authorizations using Python. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v2/proxy/ipauthorization/", headers={"Authorization": "Token APIKEY"} ) response.json() ``` -------------------------------- ### Get Referral Config Source: https://github.com/akjong/webshare-rs/blob/master/docs/referral.md Example of how to retrieve the referral config object using Python, Javascript, and cURL. ```Python import requests response = requests.get( "https://proxy.webshare.io/api/v2/referral/credit/", headers={"Authorization": "Token APIKEY"} ) response.json() ``` ```Javascript fetch("https://proxy.webshare.io/api/v2/referral/config/", { "headers": { "Authorization": "Token APIKEY" }, "method": "GET" }) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err)); ``` ```cURL curl -X GET "https://proxy.webshare.io/api/v2/referral/config/" \ -H "Authorization: Token APIKEY" ``` -------------------------------- ### Python Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/referral/referral_info.md Example of how to retrieve referral code information using Python requests. ```python import requests response = requests.get("https://proxy.webshare.io/api/v2/referral/code/info/?referral_code={referral_code}") response.json() ``` -------------------------------- ### Filtering Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/index.md Example demonstrating various filtering methods (exact, multi, greater than, less than, contains) in a GET request. ```python import requests response = requests.get( "https://proxy.webshare.io/api/payment/transaction/?status=completed,refunded&amount__lt=1337" ) response.json() ``` -------------------------------- ### Proxy Configuration JSON Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxy-config.md An example of the JSON format for proxy configuration. ```json { "id": 1, "state": "completed", "countries": {"US": 5, "FR": 100}, "available_countries": {"US": 95}, "unallocated_countries": {}, "ip_ranges_24": {"10.1.1.0/24": 5, "10.1.3.0/24": 100}, "ip_ranges_16": {"10.1.0.0/16": 105}, "ip_ranges_8": {"10.0.0.0/8": 105}, "available_ip_ranges_24": {"1.2.3.0/24": 100}, "available_ip_ranges_16": {"1.2.0.0/16": 100}, "available_ip_ranges_8": {"1.0.0.0/8": 100}, "asns": {"6137": ["ASN NAME", 105]}, "available_asns": {"9421": ["ASN NAME", 105]}, "username": "username", "password": "password", "request_timeout": 86400, "request_idle_timeout": 900, "ip_authorization_country_codes": ["US", "FR"], "auto_replace_invalid_proxies": true, "auto_replace_low_country_confidence_proxies": false, "auto_replace_out_of_rotation_proxies": false, "auto_replace_failed_site_check_proxies": false, "proxy_list_download_token": "aa87abbc...zz", "is_proxy_used": false, "created_at": "2022-06-14T11:58:10.246406-07:00", "updated_at": "2022-06-14T11:58:10.246406-07:00" } ``` -------------------------------- ### Curl example Source: https://github.com/akjong/webshare-rs/blob/master/docs/verification/submit_evidence.md Example of submitting evidence using curl. ```bash curl "https://proxy.webshare.io/api/v2/verification/flow//submit_evidence/" \ -F "explanation=We+use+proxies+to+scrape+pricing+information+from+e-commerce+websites.&files=@evidence.jpg" \ -H "Authorization: Token APIKEY" ``` -------------------------------- ### Get Subscription Source: https://github.com/akjong/webshare-rs/blob/master/docs/subscription.md Example of how to retrieve subscription details using Python, Javascript, and cURL. ```Python import requests response = requests.get( "https://proxy.webshare.io/api/v2/subscription/", headers={"Authorization": "Token APIKEY"} ) response.json() ``` ```Javascript fetch("https://proxy.webshare.io/api/v2/subscription/", { "headers": { "Authorization": "Token APIKEY" }, "method": "GET" }).then(response => response.json()).then(data => console.log(data)) ``` ```cURL curl -X GET https://proxy.webshare.io/api/v2/subscription/ \ -H "Authorization: Token APIKEY" ``` -------------------------------- ### Installation with cargo add Source: https://github.com/akjong/webshare-rs/blob/master/README.md Use cargo add to install the webshare-rs crate. ```sh cargo add webshare-rs ``` -------------------------------- ### Get Pricing Information Source: https://github.com/akjong/webshare-rs/blob/master/docs/subscription/pricing.md Example of how to retrieve pricing information using the Webshare API with Python. ```python import requests import json response = requests.get( "https://proxy.webshare.io/api/v2/subscription/pricing/", { "query": json.dumps( { "proxy_type": "shared", "proxy_subtype": "default", "proxy_countries": {"US": 100}, "bandwidth_limit": 5000, "on_demand_refreshes_total": 0, "automatic_refresh_frequency": 0, "proxy_replacements_total": 0, "subusers_total": 3, "term": "monthly", "is_unlimited_ip_authorizations": False, "is_high_concurrency": False, "is_high_priority_network": False, "with_tax": True, } ) }, headers={"Authorization": "Token APIKEY"} ) response.json() ``` -------------------------------- ### Curl example Source: https://github.com/akjong/webshare-rs/blob/master/docs/verification/thresholds.md Example of how to retrieve verification thresholds using curl. ```bash curl "https://proxy.webshare.io/api/v2/verification/thresholds/" \ -H "Authorization: Token APIKEY" ``` -------------------------------- ### GET Request Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxystats/list_activity.md This example shows how to make a GET request to list proxy activity. ```http GET https://proxy.webshare.io/api/v2/proxy/activity/ or in case of targeting a specific plan GET https://proxy.webshare.io/api/v2/proxy/activity/?plan_id= ``` -------------------------------- ### Python example for downloading proxy activity list Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxystats/download_activity.md This snippet shows how to make a GET request to the download activity API using Python's requests library. ```python import requests response = requests.get( "api/v2/proxy/activity/download/", { "download_token": DOWNLOAD_TOKEN } ) response.text ``` -------------------------------- ### Federated Access Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/index.md Example of how to use federated access by adding the 'X-Webshare-Federated-Access' header. ```python import requests response = requests.get("https://proxy.webshare.io/api/v2/profile/", headers={ "Authorization": "Token APIKEY", "X-Webshare-Federated-Access": "" }) response.json() ``` -------------------------------- ### Javascript Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/referral/referral_info.md Example of how to retrieve referral code information using Javascript fetch. ```javascript fetch("https://proxy.webshare.io/api/v2/referral/code/info/?referral_code={referral_code}").then(response => response.json()).then(data => console.log(data)); ``` -------------------------------- ### Curl Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/verification/categories.md Example of how to retrieve verification categories using curl. ```bash curl "https://proxy.webshare.io/api/v2/verification/categories/" \ -H "Authorization: Token APIKEY" ``` -------------------------------- ### cURL Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/referral/referral_info.md Example of how to retrieve referral code information using cURL. ```bash curl -X GET "https://proxy.webshare.io/api/v2/referral/code/info/?referral_code={referral_code}" ``` -------------------------------- ### Plan Object Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/subscription/plan.md An example of the Plan object in JSON format, illustrating its attributes and their typical values. ```json { "id": 2, "status": "active", "bandwidth_limit": 50.0, "monthly_price": 9.99, "yearly_price": 49.99, "proxy_type": "shared", "proxy_subtype": "default", "proxy_count": 1000, "proxy_countries": {"ZZ": 1000}, "required_site_checks": ["google_search"], "on_demand_refreshes_total": 0, "on_demand_refreshes_used": 0, "on_demand_refreshes_available": 0, "automatic_refresh_frequency": 0, "automatic_refresh_last_at": null, "automatic_refresh_next_at": null, "proxy_replacements_total": 10, "proxy_replacements_used": 0, "proxy_replacements_available": 10, "subusers_total": 3, "subusers_used": 0, "subusers_available": 3, "is_unlimited_ip_authorizations": true, "is_high_concurrency": true, "is_high_priority_network": false, "created_at": "2022-06-14T11:58:10.246406-07:00", "updated_at": "2022-06-14T11:58:10.246406-07:00" } ``` -------------------------------- ### Python requests example Source: https://github.com/akjong/webshare-rs/blob/master/docs/verification/submit_evidence.md Example of submitting evidence using the Python requests library. ```python import requests response = requests.post( "https://proxy.webshare.io/api/v2/verification/flow//submit_evidence/", data={"explanation": "We use proxies to scrape pricing information from e-commerce websites."}, files={"files":[open("evidence.jpg")]}, headers={"Authorization": "Token APIKEY"} ) response.json() ``` -------------------------------- ### Python requests example Source: https://github.com/akjong/webshare-rs/blob/master/docs/verification/thresholds.md Example of how to retrieve verification thresholds using Python requests. ```python import requests response = requests.get("https://proxy.webshare.io/api/v2/verification/thresholds/") response.json() ``` -------------------------------- ### Python Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/subuser/refresh_proxy_list.md Example of how to refresh the proxy list of a sub-user using Python. ```python import requests response = requests.post( "https://proxy.webshare.io/api/v2/subuser//refresh/", headers={"Authorization": "Token APIKEY"} ) response.json() ``` -------------------------------- ### Pagination Example (Python) Source: https://github.com/akjong/webshare-rs/blob/master/docs/index.md Example demonstrating how to use pagination parameters (page and page_size) in a request to the proxy list endpoint. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v2/proxy/list/?page=4&page_size=10" ) response.json() ``` -------------------------------- ### Python example Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxy-config/get_proxy_stats.md Python code to get proxy stats. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v3/proxy/list/stats?plan_id=PLAN-ID", headers={ "Authorization": "Token APIKEY" } ) response.json() ``` -------------------------------- ### Just Format Command Source: https://github.com/akjong/webshare-rs/blob/master/specs/2026-02-22-01-webshare-api-sdk-rewrite/tasks.md Command to run project formatting. ```bash just format ``` -------------------------------- ### WebshareClient Usage Example Source: https://github.com/akjong/webshare-rs/blob/master/specs/2026-02-22-01-webshare-api-sdk-rewrite/tasks.md An example demonstrating how to use the WebshareClient to list API keys. ```rust #!/usr/bin/env //! Webshare API client for Rust //! //! # Example //! ```no_run //! use webshare_rs::WebshareClient; //! //! #[tokio::main] //! async fn main() -> webshare_rs::Result<()> //! { //! let client = WebshareClient::new("your-api-token")?; //! let keys = client.list_api_keys(None, None).await?; //! println!("{:?}", keys); //! Ok(()) //! } //! ``` pub mod client; pub mod error; pub mod pagination; pub mod models; pub mod api; pub use client::{WebshareClient, WebshareClientBuilder}; pub use error::{WebshareError, Result}; pub use pagination::PaginatedResponse; ``` -------------------------------- ### Example of replacing proxies by country Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxy-replacement/proxy_replacement.md Demonstrates how to specify proxy replacement rules using country codes for both the proxies to be replaced and the proxies to replace with. ```plaintext ## To Replace to_replace: { type: "country", country_code: "US", count: 10 } ## Replace with replace_with: [ { type: "country", country_code: "FR", count: 5 }, { type: "country", country_code: "TR", count: 5 } ] ``` -------------------------------- ### Create API Key Source: https://github.com/akjong/webshare-rs/blob/master/docs/apikeys/create.md Example of creating an API key using Python. ```Python import requests response = requests.post( "https://proxy.webshare.io/api/v2/apikey/", json={"label": "server1 key"}, headers={"Authorization": "Token APIKEY"}) response.json() ``` ```Javascript fetch("https://proxy.webshare.io/api/v2/apikey/", { method: "POST", body: JSON.stringify({"label": "server1 key"}), headers: { "Authorization": "Token APIKEY", "Content-Type": "application/json" } }).then(response => response.json()) ``` ```cURL curl -X POST https://proxy.webshare.io/api/v2/apikey/ \ -H "Authorization: Token APIKEY" \ -H "Content-Type: application/json" \ -d '{"label": "server1 key"}' ``` -------------------------------- ### Python Source: https://github.com/akjong/webshare-rs/blob/master/docs/twofactorauth/get-2fa-method.md This is a Python example of how to get the current 2FA method. ```python import requests response = requests.post( "https://proxy.webshare.io/api/v2/twofactorauth/method/current/", json={ "password": "newpassword1234", "new_email": "newemail@webshare.io" }, headers={"Authorization": "Token APIKEY"} ) assert response.status_code == 204 ``` -------------------------------- ### Purchase a plan Source: https://github.com/akjong/webshare-rs/blob/master/docs/subscription/purchase_plan.md Example of how to purchase a new plan using the Webshare API. ```python import requests response = requests.post( "https://proxy.webshare.io/api/v2/subscription/checkout/purchase/", json={ "proxy_type": "shared", "proxy_subtype": "default", "proxy_countries": {"US": 100}, "bandwidth_limit": 5000, "on_demand_refreshes_total": 0, "automatic_refresh_frequency": 0, "proxy_replacements_total": 0, "subusers_total": 3, "is_unlimited_ip_authorizations": False, "is_high_concurrency": False, "is_high_priority_network": False, "term": "monthly", "payment_method": 3, "recaptcha": "...", }, headers={"Authorization": "Token APIKEY"}, ) response.json() ``` ```javascript const response = await fetch("https://proxy.webshare.io/api/v2/subscription/checkout/purchase/", { method: "POST", headers: { "Authorization": "Token APIKEY", "Content-Type": "application/json", }, body: JSON.stringify({ proxy_type: "shared", proxy_subtype: "default", proxy_countries: {"US": 100}, bandwidth_limit: 5000, on_demand_refreshes_total: 0, automatic_refresh_frequency: 0, proxy_replacements_total: 0, subusers_total: 3, is_unlimited_ip_authorizations: false, is_high_concurrency: false, is_high_priority_network: false, term: "monthly", payment_method: 3, recaptcha: "...", }), }); const data = await response.json(); ``` ```curl curl -X POST https://proxy.webshare.io/api/v2/subscription/checkout/purchase/ \ -H "Authorization: Token APIKEY" \ -H "Content-Type: application/json" \ -d '{ \ "proxy_type": "shared", \ "proxy_subtype": "default", \ "proxy_countries": {"US": 100}, \ "bandwidth_limit": 5000, \ "on_demand_refreshes_total": 0, \ "automatic_refresh_frequency": 0, \ "proxy_replacements_total": 0, \ "subusers_total": 3, \ "is_unlimited_ip_authorizations": false, \ "is_high_concurrency": false, \ "is_high_priority_network": false, \ "term": "monthly", \ "payment_method": 3, \ "recaptcha": "..." \ }' ``` -------------------------------- ### Get IP Authorization Request Source: https://github.com/akjong/webshare-rs/blob/master/docs/ipauthorization/retrieve.md Example GET requests to retrieve an IP authorization, with and without a specific plan ID. ```http GET https://proxy.webshare.io/api/v2/proxy/ipauthorization// ``` ```http GET https://proxy.webshare.io/api/v2/proxy/ipauthorization//?plan_id= ``` -------------------------------- ### Python Source: https://github.com/akjong/webshare-rs/blob/master/docs/ipauthorization/create.md Example of creating an IP authorization using Python. ```python import requests response = requests.post( "https://proxy.webshare.io/api/v2/proxy/ipauthorization/", json={"ip_address": "10.1.2.3"}, headers={"Authorization": "Token APIKEY"}) response.json() ``` -------------------------------- ### Get Public IP Address Source: https://github.com/akjong/webshare-rs/blob/master/docs/ipauthorization/whatsmyip.md This example shows how to get your public IP address using the API. ```Python import requests response = requests.get( "https://proxy.webshare.io/api/v2/proxy/ipauthorization/whatsmyip/", headers={"Authorization": "Token APIKEY"} ) response.json() ``` ```Javascript fetch("https://proxy.webshare.io/api/v2/proxy/ipauthorization/whatsmyip/", { "headers": { "Authorization": "Token APIKEY" } }).then(response => response.json()).then(json => console.log(json)) ``` ```cURL curl -X GET https://proxy.webshare.io/api/v2/proxy/ipauthorization/whatsmyip/ \ -H "Authorization: Token APIKEY" ``` -------------------------------- ### Just Lint Command Source: https://github.com/akjong/webshare-rs/blob/master/specs/2026-02-22-01-webshare-api-sdk-rewrite/tasks.md Command to run project linting. ```bash just lint ``` -------------------------------- ### Pagination Example Source: https://github.com/akjong/webshare-rs/blob/master/README.md Demonstrates how to handle paginated responses, accessing count, next, previous, and results. ```rust use webshare_rs::{WebshareClient, Result}; #[tokio::main] async fn main() -> Result<()> { let client = WebshareClient::builder() .api_key(std::env::var("WEBSHARE_API_KEY").unwrap()) .build()?; let page = client.proxy_list().list(100, 0).await?; println!("{} total proxies, showing {}", page.count, page.results.len()); Ok(()) } ``` -------------------------------- ### Python Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxystats/list_activity.md This Python code snippet demonstrates how to fetch proxy activity data. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v2/proxy/activity/", { "timestamp__lte":"2022-09-09T23:34:00.095501-07:00", "timestamp__gte":"2022-08-09T23:34:00.095501-07:00" }, headers={"Authorization": "Token APIKEY"} ) response.json() ``` -------------------------------- ### Python Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxy-list/download.md Example of how to download the proxy list using Python's requests library. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v2/proxy/list/download/{TOKEN}/-/any/username/direct/san%20francisco/" ) response.text ``` -------------------------------- ### Create replacement with ASN Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxy-replacement/proxy_replacement/proxy_replacement_create.md This example demonstrates creating a proxy replacement targeting a specific ASN. ```python 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": "asn", "asn_numbers": [2914]}], "dry_run": False }, headers={"Authorization": "Token APIKEY"} ) response.json() ``` ```json { "id": 98315, "reason": "proxy_replaced", "to_replace": {"type": "ip_range", "ip_ranges": ["1.2.3.0/24"]}, "replace_with": [{"type": "asn", "asn_numbers": [2914]}], "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" } ``` -------------------------------- ### Python Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/ipauthorization/retrieve.md Python code to retrieve an IP authorization using the requests library. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v2/proxy/ipauthorization//", headers={"Authorization": "Token APIKEY"} ) response.json() ``` -------------------------------- ### IP Authorization Response Structure Source: https://github.com/akjong/webshare-rs/blob/master/docs/ipauthorization/retrieve.md Example JSON structure of a successful IP authorization response. ```json { "id": 1337, "ip_address": "10.1.2.3", "created_at": "2022-06-14T11:58:10.246406-07:00", "last_used_at": null } ``` -------------------------------- ### Download replaced list Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxy-replacement/replaced_proxy/download.md Example of how to download the replaced proxy list using Python. ```Python import requests response = requests.get( "https://proxy.webshare.io/api/v2/proxy/list/replaced/download/", { "download_token": DOWNLOAD_TOKEN, "search": "san francisco", "country_codes": "-", "proxy_protocol": "any", "authentication_type": "username", "mode": "direct" } ) response.text ``` -------------------------------- ### Get Referral Credit - Python Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/referral/referral_credit.md Python code to retrieve a specific referral credit by its ID using the Webshare API. ```python import requests response = requests.get( "https://proxy.webshare.io/api/v2/referral/credit/{ID}/", headers={"Authorization": "Token APIKEY"} ) response.json() ``` -------------------------------- ### Create replacement with IP range Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxy-replacement/proxy_replacement/proxy_replacement_create.md This example shows how to create a proxy replacement targeting a specific IP range. ```python 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": "ip_range", "ip_ranges": ["1.2.3.4/8"]}], "dry_run": False }, headers={"Authorization": "Token APIKEY"} ) response.json() ``` ```json { "id": 98315, "reason": "proxy_replaced", "to_replace": {"type": "ip_range", "ip_ranges": ["1.2.3.0/24"]}, "replace_with": [{"type": "ip_range", "ip_ranges": ["1.2.3.4/8"]}], "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" } ``` -------------------------------- ### Update Sub-user Request Examples Source: https://github.com/akjong/webshare-rs/blob/master/docs/subuser/update.md Examples of how to update a sub-user using Python, Javascript, and cURL. The examples show how to send a PATCH request to the API endpoint. ```Python import requests response = requests.patch( "https://proxy.webshare.io/api/v2/subuser//", json={"label":"newlabel"}, headers={"Authorization": "Token APIKEY"} ) response.json() ``` ```Javascript fetch("https://proxy.webshare.io/api/v2/subuser//", { method: "PATCH", headers: { "Authorization": "Token APIKEY", "Content-Type": "application/json" }, body: JSON.stringify({"label": "newlabel"}) }).then(response => response.json()).then(data => console.log(data)); ``` ```cURL curl -X PATCH https://proxy.webshare.io/api/v2/subuser// \ -H "Authorization: Token APIKEY" \ -H "Content-Type: application/json" \ -d '{"label":"newlabel"}' ``` -------------------------------- ### Create replacement with country Source: https://github.com/akjong/webshare-rs/blob/master/docs/proxy-replacement/proxy_replacement/proxy_replacement_create.md This example shows how to create a proxy replacement targeting a specific country. ```python import requests response = requests.post( "https://proxy.webshare.io/api/v3/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() ``` ```json { "id": 98315, "to_replace": {"type": "ip_range", "ip_ranges": ["1.2.3.0/24"]}, "replace_with": [{"type": "country", "country_code": "US"}], "dry_run": false, "state": "validating", "proxies_removed": null, "proxies_added": null, "reason": "", "error": null, "error_code": null, "created_at": "2022-07-26T21:25:13.966946-07:00", "dry_run_completed_at": null, "completed_at": null } ``` -------------------------------- ### Python Request Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/twofactorauth/enter-2fa-code.md Example of how to send a POST request to the 2FA code authentication API using Python. ```python import requests response = requests.post( "https://proxy.webshare.io/api/v2/twofactorauth/codeauth/", json={ "code": "164123", "recaptcha": "..." }, headers={"Authorization": "Token APIKEY"} ) assert response.status_code == 204 ``` -------------------------------- ### Verification Object Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/verification.md An example of the verification object in JSON format. ```json { "id": 1, "type": "acceptable_use_violation", "state": "inflow", "started_at": "2022-06-14T11:58:10.246406-07:00", "updated_at": "2022-06-14T11:58:10.246406-07:00", "needs_evidence": false } ``` -------------------------------- ### Python Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/subscription/customize.md Example of how to use the customize endpoint in Python to retrieve available proxy options. ```python import requests import json response = requests.get( "https://proxy.webshare.io/api/v2/subscription/customize/", { "query": json.dumps( { "proxy_type": "shared", "proxy_subtype": "default", "proxy_countries": {"ZZ": 100}, } ) }, headers={"Authorization": "Token APIKEY"} ) response.json() ``` -------------------------------- ### Installation with Cargo.toml Source: https://github.com/akjong/webshare-rs/blob/master/README.md Add webshare-rs to your project's dependencies in Cargo.toml. ```toml [dependencies] webshare-rs = "0.1" ``` -------------------------------- ### Notification Object JSON Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/notifications.md An example of the notification object in JSON format. ```json { "id": 13, "type": "too_much_bandwidth_too_little_proxies", "is_dismissable": true, "context": { "plan": 22 }, "created_at": "2022-06-14T11:58:10.246406-07:00", "updated_at": "2022-06-14T11:58:10.246406-07:00", "dismissed_at": null, } ``` -------------------------------- ### Response JSON Example Source: https://github.com/akjong/webshare-rs/blob/master/docs/verification/limits.md This is an example of the JSON response structure for verification limits. ```json { "proxy_state": "active" } ``` -------------------------------- ### Example Response JSON Source: https://github.com/akjong/webshare-rs/blob/master/docs/subuser/masquerade.md Example JSON response structure when masquerading as a sub-user. ```json { "id": 1, "state": "completed", "countries": {"US":5, "FR":100}, "available_countries": {"US": 95}, "unallocated_countries": {}, "ip_ranges_24": {"10.1.1.0/24": 5, "10.1.3.0/24": 100}, "ip_ranges_16": {"10.1.0.0/16": 105}, "ip_ranges_8": {"10.0.0.0/24": 105}, "available_ip_ranges_24": {"1.2.3.0/24": 100}, "available_ip_ranges_16": {"1.2.3.0/24": 100}, "available_ip_ranges_8": {"1.2.3.0/24": 100}, "username": "username", "password": "password", "request_timeout": 86400, "request_idle_timeout": 900, "ip_authorization_country_codes": ["US", "FR"], "auto_replace_invalid_proxies": true, "auto_replace_low_country_confidence_proxies": false, "proxy_list_download_token": "aa87abbc...zz", "created_at": "2022-06-14T11:58:10.246406-07:00", "updated_at": "2022-06-14T11:58:10.246406-07:00" } ```