-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_proxy.py
More file actions
43 lines (37 loc) · 1.64 KB
/
basic_proxy.py
File metadata and controls
43 lines (37 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
Minimal NikaProxy HTTP-proxy example.
Sends one HTTPS GET through the NikaProxy residential network. The destination
sees the request coming from a residential IP (not your machine's), but the
TLS handshake itself is between YOUR `requests` library and the destination —
this is the plain "residential" mode where we just route bytes, not the TLS
Pro mode where we sign your handshake with a browser fingerprint.
Run:
export NIKA_API_KEY="nka_..."
export NIKA_PROXY_PASSWORD="px_..."
python basic_proxy.py
"""
import os
import requests
API_KEY = os.environ["NIKA_API_KEY"]
PROXY_PASSWORD = os.environ["NIKA_PROXY_PASSWORD"]
# Proxy URL anatomy:
# http://USERNAME:PASSWORD@gateway:port
#
# USERNAME = your API key, with optional `-key-value` modifiers tacked on:
# -country-US force a US exit
# -session-NAME sticky session (same NAME → same exit IP)
# -session-NAME-min-30 sticky for 30 minutes (5/10/15/20/60 valid)
# -profile-chrome_131 TLS Pro/Ultra fingerprint pin
# -coord-win11 TLS Ultra: L4+L7 coordination to a Win11 exit
#
# Here we ask for any US exit, rotating (no session pin → fresh IP each call).
proxy_user = f"{API_KEY}-country-US"
proxies = {
"http": f"http://{proxy_user}:{PROXY_PASSWORD}@proxy.nikaproxy.com:8080",
"https": f"http://{proxy_user}:{PROXY_PASSWORD}@proxy.nikaproxy.com:8080",
}
# `httpbin.org/ip` echoes the source IP it sees — handy for proving the proxy
# is actually swapping the egress address.
r = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=30)
r.raise_for_status()
print("Exit IP seen by destination:", r.json()["origin"])