Skip to main content

ip2vn

SDK Python chính thức của IP2.VN — điều khiển proxy xoay IP dân cư Viettel cho bên làm tool tích hợp. Không phụ thuộc thư viện ngoài (chỉ dùng urllib chuẩn), cần Python 3.8+.

pip install ip2vn

Mô hình giới thiệu (hoa hồng 10%)

Tool của bạn nhúng mã giới thiệu công khai của bạn và đưa người dùng đăng ký qua IP2.ref_link('MÃ'). Người dùng tự mua proxy, tự tạo key theo từng cổng rồi dán vào tool; bạn ăn 10% chi tiêu của họ.

An toàn: chỉ nhúng mã giới thiệu (công khai). TUYỆT ĐỐI không nhúng key, mật khẩu hay token vào tool phát đi — tool nào cũng bung xem được. Key là của chính người dùng cuối, không phải của bạn.

Dùng

from ip2vn import IP2, IP2Error

# Link đưa cho người dùng để họ gắn với bạn:
print(IP2.ref_link("MÃ_GIỚI_THIỆU_CỦA_BẠN"))   # https://ip2.vn/?ref=...

# Người dùng dán key cổng của họ vào tool của bạn:
cong = IP2("ip2_xxxxxxxxxxxx")

tin = cong.info()        # host, port, ip, cooldown, expire_at, ...
kq  = cong.rotate()      # { ip, previous_ip, took, next_allowed_in }
cong.auto(300)           # hẹn tự xoay mỗi 300s (0 để tắt, thấp nhất 180)
ls  = cong.history(limit=20)
cong.renew(30)           # gia hạn 1/7/30 ngày, trừ ví người dùng

# Chuỗi proxy sẵn dùng (user/pass proxy do người dùng nhập):
px = cong.proxy("u", "p")
print(px["url"])   # http://u:p@host:port
print(px["tho"])   # host:port:u:p

try:
    cong.rotate()
except IP2Error as e:
    print(e.code, e.message, e.retry_after)

Khoá theo mã giới thiệu (tuỳ chọn)

Muốn tool chỉ chạy cho khách đã đăng ký qua bạn? Truyền ref là mã giới thiệu của bạn — SDK hỏi máy chủ xem chủ key có phải khách của bạn không, không phải thì mọi lệnh ném IP2Error code sai_ref:

cong = IP2(key_nguoi_dung, ref="MÃ_GIỚI_THIỆU_CỦA_BẠN")
cong.rotate()   # chỉ chạy nếu key thuộc khách bạn giới thiệu

Không truyền ref thì không khoá gì. Lưu ý: đây là khoá mềm — phép kiểm đúng ở máy chủ, nhưng quyết định khoá nằm trong SDK nên người bẻ khoá tool vẫn qua được, và chỉ chặn lệnh đi qua SDK, không chặn ai cắm thẳng host:port:user:pass.

Phương thức

Gọi Trả về
info() host, port, line, ip, protocol, auto, cooldown, expire_at, rotations
rotate(wait=True) ip, previous_ip, took, next_allowed_in
auto(giây) auto, every, next_at
history(limit, since) total, items[{ip, at}]
renew(1|7|30) days_added, charged, wallet_balance, expire_at
proxy(username, password, protocol) host, port, url, tho
IP2.ref_link(mã) https://ip2.vn/?ref=mã

Lỗi ném ra IP2Error với .code (máy đọc), .message (tiếng Việt), .status (HTTP), .retry_after (giây, khi dính cooldown).

Cổng nghe cả HTTP lẫn SOCKS5 trên cùng một port — chọn giao thức chỉ đổi cách viết chuỗi, không đổi port.

MIT © IP2.VN

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ip2vn-1.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ip2vn-1.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file ip2vn-1.1.0.tar.gz.

File metadata

  • Download URL: ip2vn-1.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for ip2vn-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5d2da956d5d5d6a49240d4bc1faca8a496039ea5f1ab03cdf18c2ce351e26538
MD5 24999ccd08e81867c56d77d4a135523d
BLAKE2b-256 63f7e16233ae4cc710ea0deeb1a64c0d3511a9a6d5252e1d0ad4260a4b5e4a4c

See more details on using hashes here.

File details

Details for the file ip2vn-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: ip2vn-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for ip2vn-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2e159c881ec71c09f735a707df37b77400e904dfa6fdb8ff7a159256f8d43c9
MD5 7895918c4684738a56d6e49530db0c91
BLAKE2b-256 a20a9f96f7cdcef8806e78cbb91fad2452a5e13b6d655869ead3e9eae845e5c1

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page