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.0.0.tar.gz (7.6 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.0.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for remote_curl_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0a60d73810170714004798d3d1185cd24011cf406a0df121209eb5a8fdfad0ed
MD5 4f1ef2cfe70f0ffa2df7f892c60719db
BLAKE2b-256 c9404aaa8598919ab5ed8f5a1abc6d6e3fc34dd6bafebbb4f3b556e33c2a4d1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for remote_curl_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9dfc29093bd99cc86c4e5af0f980bb3bdb14ccb11fcb94d4f5bd6ac629492c3
MD5 3c82cb230eb45e7afafddb31ae2e6f87
BLAKE2b-256 2f39f09c5e7b4c5126c0770677475891928a3a059b4ead99884f24501f3eddcf

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