Skip to main content

Remote curl-based API requester over SSH

Project description

remote-curl-client

Send HTTP requests from a remote machine (over SSH) using curl, and receive structured responses locally in Python.

This is useful when:

  • The remote network has different routing, VPN access, or firewalls.
  • You need to debug connectivity from the remote host's perspective.
  • You want a lightweight alternative to installing a full API stack remotely.

✨ Features

  • All HTTP methods (GET, POST, PUT, DELETE, etc.).
  • Pass any additional curl flags.
  • Headers, query params, and request bodies (string or JSON dict).
  • Follow redirects, toggle SSL verification, set timeouts.
  • Retry with exponential backoff + jitter.
  • Structured RemoteResponse object (status, headers, body, raw headers).
  • Password or SSH-key auth (Paramiko).

🚀 Install

From PyPI (after release):

pip install remote-curl-client

🔧 Quick Start

from remote_curl_client import RemoteCurlClient

client = RemoteCurlClient(
    hostname="10.37.65.78",
    username="user",
    key_filename="~/.ssh/id_rsa",  # or password="..."
)

resp = client.request(
    method="GET",
    url="https://httpbin.org/get",
    params={"q": "remote"},
    headers={"User-Agent": "RemoteCurlClient/1.0"},
    retries=3,
    backoff_factor=0.5,
)

print(resp.status_code)
print(resp.headers)
print(resp.body[:200])

📨 POST JSON

data = {"hello": "remote world"}

resp = client.request(
    method="POST",
    url="https://httpbin.org/post",
    data=data,  # dict -> JSON serialized
    headers={"Authorization": "Bearer token123"},
    timeout=10,
)

🔁 Retries & Backoff

resp = client.request(
    method="GET",
    url="https://httpbin.org/status/500",
    retries=4,          # total attempts = 1 + 4 = 5
    backoff_factor=1.0, # 1s, 2s, 4s, 8s...
    max_backoff=5.0,    # cap
)

⚙️ Extra curl flags

Anything curl supports can be passed through:

resp = client.request(
    method="GET",
    url="https://example.com",
    curl_args=["--compressed", "--http2"],
)

🔐 SSH with Password

client = RemoteCurlClient(
    hostname="10.37.65.78",
    username="user",
    password="your_password"
)

🧪 Testing Locally Against localhost

If you have SSH to localhost and curl installed, you can quickly validate:

client = RemoteCurlClient("localhost", "youruser")
resp = client.request("GET", "https://httpbin.org/get")
print(resp.status_code)

📄 License

MIT License. See LICENSE.

Project details


Download files

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

Source Distribution

remote_curl_client-1.4.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

remote_curl_client-1.4.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file remote_curl_client-1.4.0.tar.gz.

File metadata

  • Download URL: remote_curl_client-1.4.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for remote_curl_client-1.4.0.tar.gz
Algorithm Hash digest
SHA256 04884d5f0c0cd61f0c8521fc76fe92c084c33ba0c3a4198c9d9bd0420fc0b774
MD5 434a50a37c67d4ff9ef936fe8141ffd2
BLAKE2b-256 3aa5a4cb4db7f0b8a73b68e9cf762b514aaecbd359f2091a7aa1cae19ac6a602

See more details on using hashes here.

File details

Details for the file remote_curl_client-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for remote_curl_client-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81fad6330fc1730f19450ccf7a4b39455428e4324437d7f8f46120202c3fc297
MD5 72204be31376e86ed41193da5b9dd9d6
BLAKE2b-256 535aa9f19c486a86d112cb409b4378ee46fec6d03303bacc655cb8c27d062f6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page