LOCALHOST
All pages
Start

Quick start

A key, a request and a site, in a few minutes.

  1. Make a key. In the panel, open API keys, name the key and tick Sites and apps (read and write). The key starts with lh_ and is shown once: keep it somewhere safe.
  2. Say hello. Put the key in the Authorization header. GET /me is the cheapest call there is.
    export API=https://api.localhost.co.zw
    export LH_API_KEY=lh_…
    
    curl "$API/me" -H "Authorization: Bearer $LH_API_KEY"
    # {"account": "mukoko-hardware", "name": "Mukoko Hardware"}
  3. Run something. A site is a container image on a port. It gets an address under sites.localhost.co.zw straight away; your own name can point at it later.
    curl -X POST "$API/sites/" \
      -H "Authorization: Bearer $LH_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"slug": "shop", "image": "nginx:alpine", "port": 80, "size": "S"}'

    The answer carries desired_state and observed_state; the second catches up with the first within a minute. GET /sites/shop/logs shows what the app printed.

  4. Or do the same from a terminal. lh wraps these calls and follows a build as it runs.
    $ curl -fsSL https://api.localhost.co.zw/cli/install.sh | sh # installs lh (or: pipx install localhost-cli) $ lh login API key: •••••••• Signed in as Mukoko Hardware (mukoko-hardware). $ lh create shop --repo mukoko/shop Created shop from mukoko/shop (main). Build #1 has started. … detected Next.js · building · health check passed Live: https://shop.sites.localhost.co.zw $ lh env-set shop DATABASE_URL # asks for the value, so it stays out of your history $ lh logs shop --tail 50
  5. Deploy from Git. Connect a repository and every push to its branch builds and goes live with no downtime. Deploying from Git has the whole path, including tags, pull-request previews and rollback.

Where next

Keys and permissions

What a key may do, acting for a client, paid calls and Idempotency-Key.

Read →

API reference

Every endpoint with its parameters, permission and an example you can paste.

Browse →

Connected assistants

Let an AI assistant do these steps for you, within what you allow.

Connect →