Skip to content

Proxy Templates

Proxy templates let you control how proxy credentials are formatted — whether you need a simple URL, an ip:port:login:pass string, or a custom format for a tool like AdsPower, Dolphin Anty, or GoLogin.

A template is a string with placeholders that get replaced with actual proxy data when you call format_with_template() on a PortInfo object.

PlaceholderDescription
\{protocol\}Proxy protocol (socks5, http, …)
\{ip\}Proxy host address
\{port\}Proxy port number
\{login\}Authentication login
\{password\}Authentication password
\{id\}Port ID
\{name\}Port name
\{external_ip\}External IP address
\{refresh_link\}Refresh IP link

The library ships with 18 ready-to-use templates accessible through the interactive wizard or the GeoPicker:

#FormatExample
1Standard URLsocks5://user:pass@1.2.3.4:8080
2HTTP URLhttp://user:pass@1.2.3.4:8080
3SOCKS5 URLsocks5://user:pass@1.2.3.4:8080
4ip:port:login:password1.2.3.4:8080:user:pass
5protocol://ip:port:login:passwordsocks5://1.2.3.4:8080:user:pass
6URL with refresh linksocks5://user:pass@host:port[refresh_url]
7Full URL with namesocks5://user:pass@host:port:name[refresh_url]
from asockslib import ASocksClient
async with ASocksClient(api_key="sk-...") as client:
ports = await client.list_ports()
for port in ports.items:
# Standard URL
print(port.proxy_url)
# Custom format
print(port.format_with_template("\{ip\}:\{port\}:\{login\}:\{password\}"))
# With protocol prefix
print(port.format_with_template("\{protocol\}://\{login\}:\{password\}@\{ip\}:\{port\}"))
Terminal window
# The wizard prompts you to select a template
asocks wizard
Terminal window
# Default format (standard URL)
asocks get --country US --count 5
# Custom template
asocks get --country US --count 5 --proxy-template "\{ip\}:\{port\}:\{login\}:\{password\}"
# Export with template
asocks get --country US --count 10 --proxy-template "\{ip\}:\{port\}:\{login\}:\{password\}" --output proxies.txt

You can also create and manage templates on the ASocks server:

from asockslib import ASocksClient, CreateTemplateRequest
async with ASocksClient(api_key="sk-...") as client:
# Create a template
req = CreateTemplateRequest(
label="My Custom Format",
template="socks5://\{login\}:\{password\}@\{ip\}:\{port\}",
)
result = await client.create_template(req)
# List templates
data = await client.list_templates()
# Delete template
await client.delete_template(template_id=123)