Skip to main content

nexrade-req

PyPI Python 3.9+ License: MIT

Fast Python HTTP client for trading bots — bypasses exchange rate limits by routing requests through Nexrade relay nodes.

Part of the Nexrade ecosystem.


How it works

Your bot
   │
   ▼
nexrade-req  ──(no api_key)──▶  direct request to exchange
   │
   └──(with api_key)──▶  https://api.nexrade.com/market-data ──▶  exchange
                         (rotates IPs, bypasses rate limits)
  • Without api_key: behaves like a normal fast HTTP client
  • With api_key: routes through api.nexrade.com/market-data — each request gets a fresh IP, bypassing exchange rate limits

Installation

pip install nexrade-req

Quick start

import nexrade_req as req

# Simple GET (no relay)
r = req.get("https://api.binance.com/api/v3/ticker/price", params={"symbol": "BTCUSDT"})
print(r.status_code, r.json())

# POST
r = req.post("https://httpbin.org/post", json={"key": "value"})
print(r.json())

Using the relay network (bypass rate limits)

from nexrade_req import Client

client = Client(api_key="your_nexrade_api_key")

# All requests are routed through Nexrade relay nodes
r = client.get("https://api.binance.com/api/v3/ticker/price", params={"symbol": "ETHUSDT"})
print(r.json())

Get your API key at nexrade.com or self-host a relay proxy with nexrade-node.


Session (connection reuse)

from nexrade_req import Client

with Client(api_key="your_key") as c:
    r1 = c.get("https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT")
    r2 = c.get("https://api.binance.com/api/v3/ticker/price?symbol=ETHUSDT")

Custom relay nodes

from nexrade_req import Client

client = Client(
    api_key="your_key",
    base_urls=["https://your-own-relay.example.com"],
    endpoint="market-data",
    timeout=10,
    max_retries=3,
)

Fallback client

FallbackClient retries through the relay, then falls back to a direct request if all relay attempts fail.

from nexrade_req import FallbackClient

r = FallbackClient.get(
    "https://api.binance.com/api/v3/ticker/price",
    params={"symbol": "BTCUSDT"},
    max_retries=3,
)
print(r.json())

API reference

Top-level functions

import nexrade_req as req

req.get(url, **kwargs)
req.post(url, data=None, json=None, **kwargs)
req.put(url, data=None, **kwargs)
req.patch(url, data=None, **kwargs)
req.delete(url, **kwargs)
req.head(url, **kwargs)
req.options(url, **kwargs)
req.request(method, url, **kwargs)

Client constructor

Parameter Default Description
api_key None Nexrade API key — enables relay routing
base_urls ("https://api.nexrade.com",) List of relay base URLs
endpoint "market-data" Relay endpoint path
max_retries 1 Retry attempts on failure
timeout 6 Request timeout in seconds
is_random_base_url True Rotate relay nodes randomly
auto_mode False Smart failover — see below

Smart auto-mode (relay ⇄ direct failover)

When auto_mode=True the client watches every relay response. If the relay signals a limit (HTTP 429 / 503, or X-RateLimit-Remaining: 0), the client immediately switches to direct-mode — subsequent requests skip the relay and go straight to the upstream exchange — for the duration of the relay's Retry-After header (default 60 s). Once the cooldown elapses, the client flips back to relay automatically.

client = Client(api_key="your_key", auto_mode=True)

r = client.get("https://api.binance.com/api/v3/ticker/price",
               params={"symbol": "BTCUSDT"})

print(client.mode)              # "relay" or "direct"
print(client.cooldown_remaining) # seconds left in the current cooldown

This protects you from paying a relay-attempt tax when nexrade is already rate-limiting you, and it recovers without any caller intervention.

Common request kwargs

Argument Description
params Query string dict
data Form body or raw bytes
json JSON body
headers Extra HTTP headers
timeout Override timeout per request
proxies Proxy dict {"https": "http://..."}
verify TLS certificate verification

Response

Attribute Description
.status_code HTTP status code
.text Response body as string
.content Response body as bytes
.json() Parse body as JSON
.headers Response headers
.url Final URL
.raise_for_status() Raise on 4xx/5xx

Exceptions

from nexrade_req.exceptions import NexradeException

try:
    r = client.get("https://api.binance.com/...")
except NexradeException as e:
    print("All relay attempts failed:", e)

License

MIT — see LICENSE.


Part of Nexrade

Product Description
nexrade-node Multi-language relay node server
nexrade-req Python HTTP client with relay routing

Download files

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

Source Distribution

nexrade_req-1.0.4.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

nexrade_req-1.0.4-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file nexrade_req-1.0.4.tar.gz.

File metadata

  • Download URL: nexrade_req-1.0.4.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for nexrade_req-1.0.4.tar.gz
Algorithm Hash digest
SHA256 35797fd5eb207804fc621cdd249cb1e9414b1063366e76ad64863f5a31f8244d
MD5 c5427a7d14f479d125bbe1b2e25b7f36
BLAKE2b-256 8f06d0fdd806513fd46f6cc863fa0486a267806ccc144297e68df9157a15a041

See more details on using hashes here.

Provenance

The following attestation bundles were made for nexrade_req-1.0.4.tar.gz:

Publisher: release.yml on nexrade/nexrade-req

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nexrade_req-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: nexrade_req-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for nexrade_req-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7ac15117a6f27278085d81fc6c43966cca44f46316a1f35f52c9966489bb9877
MD5 60d626db29b68dd65445be941dff5152
BLAKE2b-256 7e514d4367ca605936b070af7daccf558168d06f4f08858c057ffbb26df39ce4

See more details on using hashes here.

Provenance

The following attestation bundles were made for nexrade_req-1.0.4-py3-none-any.whl:

Publisher: release.yml on nexrade/nexrade-req

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.0.5

2 files

This release

1.0.4 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