NexaLayer SDK
Managed network sessions for Playwright, Browser Use, AI agents, and automation scripts.
Keep using proxies. Stop managing them.
中文:代理继续使用,代理管理交给 NexaLayer。
This repository contains the Python and Node/TypeScript SDK source. Release automation publishes signed release artifacts to PyPI and npm after registry ownership and secrets are configured.
Status
| Runtime | Source | Package registry status |
|---|---|---|
| Python | python/ |
Package name nexalayer; release workflow configured |
| Node / TypeScript | node/ |
Package name @nexalayer/sdk; release workflow configured |
Installation
Python from repository root:
python3 -m venv .venv
. .venv/bin/activate
pip install -e ".[dev]"
Node from repository root:
cd node
npm install
npm run build
Authentication
export NEXALAYER_BASE_URL=https://api.nexalayer.net/v1
export NEXALAYER_API_KEY=agk_your_key
The SDK uses X-API-Key for Agent requests.
60-second Python example
This example auto-selects a dynamic product, creates a session, reports telemetry, reads health, and terminates the session in cleanup.
import os
import time
import uuid
import requests
from nexalayer import NexaLayerClient
api_key = os.environ["NEXALAYER_API_KEY"]
client = NexaLayerClient(api_key=api_key)
session_id = None
def data(resp):
return resp.get("data", resp)
try:
products = data(client.get_products(type="dynamic"))
product = next(p for p in products.get("items", []) if p.get("product_no"))
session = client.create_session(
session_type="dynamic",
product_no=product["product_no"],
quantity=1,
protocol="socks5",
rotation_mode="on_demand",
idempotency_key=f"py-{uuid.uuid4()}",
)
session_id = session.session_id
for _ in range(60):
current = data(client.get_session(session_id))
if current.get("status") == "active":
proxy_url = current["proxy"]["full_url"]
break
time.sleep(2)
else:
raise TimeoutError("Session did not become active")
res = requests.get(
"https://httpbin.org/ip",
proxies={"http": proxy_url, "https": proxy_url},
timeout=30,
)
client.report_event(
session_id,
event_type="success" if res.ok else "http_error",
status_code=res.status_code,
target_host="httpbin.org",
)
print(client.get_session_health(session_id))
finally:
if session_id:
client.terminate_session(session_id)
Dynamic Session
Use a dynamic session when your automation can rotate after errors such as timeout, 403, 429, or explicit blocks.
session = client.create_session(
session_type="dynamic",
product_no="selected_from_products_api",
quantity=1,
protocol="socks5",
rotation_mode="on_demand",
)
Static Session
Use a static session when you need fixed network identity for a longer-lived task.
session = client.create_session(
session_type="static",
product_no="selected_from_products_api",
quantity=1,
duration=30,
protocol="socks5",
)
Telemetry
client.report_event(
session_id,
event_type="timeout",
status_code=0,
target_host="example.com",
)
Health
health = client.get_session_health(session_id)
timeout, captcha, block, and repeated HTTP errors are not neutral noise; report them so NexaLayer can score the session and recommend rotate or pause.
Cleanup
Always terminate sessions you no longer need:
try:
...
finally:
if session_id:
client.terminate_session(session_id)
Playwright
Use the public Playwright examples:
- Chinese: https://github.com/NexaLayer/nexalayer-examples/tree/main/playwright/basic-session
- English: https://github.com/NexaLayer/nexalayer-examples/tree/main/playwright/basic-session
中文文档
- 中文快速开始: https://docs.nexalayer.net/zh/quick-start
- Playwright 中文 Demo: https://docs.nexalayer.net/zh/examples
- API 文档: https://docs.nexalayer.net/api-reference/openapi
Error handling
- Check
backend_ready=truebefore creating paid sessions after registration. - Use
Idempotency-Keyfor create, rotate, renew, and recharge operations. - Do not log
proxy.full_urlin production without redaction because it can contain proxy credentials. - Respect target website terms and applicable law.
Contributing
See CONTRIBUTING.md.
Security
Do not open public issues with API keys, cookies, account passwords, proxy credentials, or target-site secrets. See SECURITY.md.
Metadata
Release files for nexalayer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nexalayer-0.1.0.tar.gz | 9.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nexalayer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.5 kB
Release files / nexalayer-0.1.0.tar.gz
| Download URL | nexalayer-0.1.0.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81c406347c13f17d97a242732a14f6b5a5fc50cf115edd89b5fa541abd03c711
|
|
BLAKE2b-256 checksum How to use checksums |
5a23d4bd8dfdf9338f4d9f5da7c8bac9ad19af38b544558d0e598ceaafacffd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / nexalayer-0.1.0-py3-none-any.whl
| Download URL | nexalayer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
efd94ce7420f116eca0a40a83ecfcc6146fd32761fc2e4287ae1b7223258e1c0
|
|
BLAKE2b-256 checksum How to use checksums |
9726ddf461959091e9147e5dc596ee62aec0609eefeefd97fd13aa6423c69fe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency log