Skip to main content

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. Signed release artifacts are published to PyPI and npm through GitHub Trusted Publishing and npm provenance.

Status

Runtime Source Package registry status
Python python/ nexalayer 0.1.1
Node / TypeScript node/ @nexalayer/sdk 0.1.1

Installation

Python:

pip install nexalayer

Node / TypeScript:

npm install @nexalayer/sdk

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:

中文文档

Error handling

  • Check backend_ready=true before creating paid sessions after registration.
  • Use Idempotency-Key for create, rotate, renew, and recharge operations.
  • Do not log proxy.full_url in 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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nexalayer 0.1.1
File Size Uploaded
nexalayer-0.1.1.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nexalayer 0.1.1
File Interpreter ABI Platform
nexalayer-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.6 kB

Release files / nexalayer-0.1.1.tar.gz

Download URL nexalayer-0.1.1.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c7e03e64875dd365a1797f394a2eca8e91b756c47215aa68b557063305794633
BLAKE2b-256 checksum
How to use checksums
55754b5b5a7f35de0622f82c717698184a371c186eb5906f050497f39eea9db9
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 16, 2026.

Transparency log

Release files / nexalayer-0.1.1-py3-none-any.whl

Download URL nexalayer-0.1.1-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2f2c30b2b8301b8f4b5b3b46d3ed820859e67d7e25482ae27837599b99c0bfb
BLAKE2b-256 checksum
How to use checksums
d27cd20799c5883febc392989cd1a004775dc54274d49e55f9d47882f6bc2b20
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 16, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.5

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release 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