HARP logo

API proxy

Available in HARP · Documentation

An API proxy sits between your application and the backend APIs it calls, whether in-house, private or public. It gives that traffic one controlled point, where you add caching, observability and resilience without changing the calling application.

HARP implements this topology as an outbound reverse proxy, sidecar style: you run it close to your application, on the same server or in the same virtual network, so the network distance it adds to each call stays minimal. It maps a local listening port to a fixed remote backend, and your code calls the proxy instead of the API directly.

YourapplicationHARPlocalhost:4000Remote APIapi.example.comHTTPHTTPS

What an API proxy does

The proxy receives each request from the client, applies cross-cutting logic such as caching, request and response manipulation and failure handling, then forwards it to the backend. The client keeps talking to a stable endpoint while the proxy absorbs the messy details of the upstream APIs: rate limits, unstable latency, outages and billed quotas.

API proxy compared to an API gateway

API proxies and API gateways are related but solve different problems. What sets them apart is the direction of the traffic they handle.

  • An API proxy handles outbound traffic: the requests your application sends to the APIs it consumes. It stands in front of the APIs you depend on.
  • An API gateway handles inbound traffic: the requests clients send to the APIs you expose. It acts as a central entry point, aggregates services, translates between protocols and distributes incoming load across them.

A proxy can take on some gateway-style tasks, but a dedicated gateway is the better fit when you need to publish and orchestrate many of your own APIs. The right choice depends on whether you are protecting the APIs you consume (proxy) or the APIs you serve (gateway). See the API gateway page for how HARP relates to it.

Why HARP fits the API proxy role

HARP is an open-source, self-hosted HTTP API Runtime Platform. Each problem of the topology has a capability at runtime, without changing your application code:

  • A third-party API goes down: with a liveness algorithm set, circuit breaking takes a failing URL out of the pool; it comes back after a probe succeeds; without a probe, when you bring it back from the dashboard or HARP restarts. Probes check every URL, failed ones included. Fallback URLs join the pool when it drops below min_pool_size.
  • A quota is billed or rate-limited: the HTTP cache built on RFC 9111 answers repeated calls the way the API allows, so fewer of them reach the backend.
  • An API behaves in ways you cannot change: rules written in Python adjust requests and responses as they pass through.
  • You cannot see what your application sends: a built-in dashboard, a traffic history, Prometheus metrics and a /healthz endpoint for liveness and readiness checks.
  • One URL is not enough: requests are spread across the URLs of a remote's active pool.

Points of attention

A proxy in the path is a trade-off. Plan for these before you rely on it:

  • An extra hop and an extra point of failure. Every call crosses one more process. Running HARP on the same server or in the same virtual network keeps the added latency small, but if HARP is down, your application cannot reach the API. The circuit breaker protects you from a failing backend, not from a failing proxy, so monitor its liveness endpoint.
  • Cache freshness. The cache stores only what the API's headers allow, and serves a response until it goes stale. A short-lived change upstream can stay invisible for that time. Check the Cache-Control of the APIs you cache, and correct it with a rule when they are wrong.
  • TLS stops at the proxy. Your application speaks plain HTTP to the local proxy, and the proxy speaks HTTPS to the API. Secrets and authentication headers cross localhost in clear: keep the proxy on the same host or on a private network you trust.

Configuration

Configuration is declarative: you describe endpoints, their listening ports and each endpoint's remote URLs, and HARP handles the rest. The excerpt below is TOML; HARP also reads YAML and JSON files. A command-line form is also available for quick testing.

This configuration maps port 4000 to https://api.example.com/:

toml
[[proxy.endpoints]]
name = "example"
port = 4000
url = "https://api.example.com/"

Your application called https://api.example.com. Now it calls http://localhost:4000; HARP forwards each request to the remote API.

  • Topologies: the API gateway handles the APIs you serve, a different job from the outbound calls this page covers.
  • A third-party API with a rate limit: see Cost management and Performance optimization.
  • Multi-region failover: see Resilience, for fallback URLs, which join the pool when it drops below min_pool_size, and probes: each remote can have one healthcheck probe, sent to every URL.