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.5.tar.gz (14.9 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.5-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nexrade_req-1.0.5.tar.gz
Algorithm Hash digest
SHA256 61e38d4a37d6077cb89a73217049705bacb6b45f5960829c4e38b348635dbc54
MD5 d87765829468f2117ceb4662a59df08c
BLAKE2b-256 1f82978a0c8d7237306c1b74e58575ff10d450c3720ee1bb0896c494e5b186e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for nexrade_req-1.0.5.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.5-py3-none-any.whl.

File metadata

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

File hashes

Hashes for nexrade_req-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0979ab9372aba91b47cbbd0edc9f104183877fe97b06a803eb48ec2da4950cf4
MD5 8e07786342535c711834be36cd9b4566
BLAKE2b-256 b8f87f3910bf5b4850fa780f1d178ff926900c6bcff5efc188c9fa69bd3d466a

See more details on using hashes here.

Provenance

The following attestation bundles were made for nexrade_req-1.0.5-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

This release

1.0.5 This release

2 files

1.0.4

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