# SDKs

Source: https://tiltas.openpanel.sh/docs/sdks

> Put one program on your Network, not the whole computer. Libraries for Go, Python, Node.js and C.

The Tiltas SDKs put a single program on your Network. The program joins with a Join key and becomes a
[Server](/docs/devices/join-keys) of its own: it gets its own address and name, serves only on the Network, and calls other
Devices and Services by name. Nothing else on the computer joins the Network, and the program needs no root, no TUN
device and no Tiltas app.

Use them for:

- an internal API or admin page that only your Network can open, with no port on the public internet;
- a job, worker or CI step that calls a database or Service at home or in another cloud by name;
- a containerised app that joins on start and leaves on stop, without a sidecar.

<a>
<o title="Quickstart" href="/docs/sdks/quickstart" description="A server and a client on your Network in five minutes." />

<o title="Go" href="/docs/sdks/go" description="tiltas.openpanel.sh/go: Listen, Dial, an HTTP client and WhoIs." />

<o title="Python" href="/docs/sdks/python" description="pip install tiltas: sockets, urlopen and WhoIs; FastAPI example." />

<o title="Node.js" href="/docs/sdks/node" description="npm install tiltas: listen, fetch, dial and whois; Express example." />

<o title="C" href="/docs/sdks/c" description="libtiltas and tiltas.h, for bindings in other languages." />

<o title="Limitations" href="/docs/sdks/limitations" description="What the SDKs do not do yet." />
</a>

<Component type="warn" title="Beta">
The SDKs work and are tested on every change, but the packages are not on the Go, PyPI and npm registries yet. Each
page says how to install from a build until they are.
</Component>

## How it works

The SDKs are built on Tailscale's `tsnet`, at the version the Tiltas engine is built from, and speak to the Panel the way
the Tiltas apps do:

1. The program trades its Join key with the Panel for a one-time key to its Network's Coordinator.
2. It connects to the Coordinator and gets an address, like every Device. Traffic goes directly between Devices, and
   through a Relay only when a direct connection is impossible.
3. It tells the Panel it is up. From then on it shows in the console under Devices, as a Server, with the name you gave
   it.
4. When it stops, it leaves the Network, unless you made it persistent.

The network runs inside your process, in user space. The program's own sockets on the computer are not touched: the
Network is reached only through the SDK's listen and dial calls.

## Who can reach it

A program joined with the SDK is a Server, and Access rules apply to it as to any Device:

- Nobody reaches it until an Access rule or a [Service](/docs/services) lets them. To open its port 80 to a Group,
  make a Web Service that points at it, or an Access rule with it as the destination.
- It reaches nothing until an Access rule lets it. A Join key with Groups puts every copy of the program into those
  Groups, so one rule covers them all.
- Each running copy is a Device, and counts against your plan's Device allowance while it runs.

To know who is calling, ask the SDK (`WhoIs` in Go, `whois` in Python and Node). It answers from the Coordinator's own
record of the address the connection came from, so a caller cannot forge it. Do not trust headers for this.

## Keep the Join key out of your code

The SDKs read the Join key only from the `TILTAS_JOIN_KEY` environment variable or from a file (`TILTAS_JOIN_KEY_FILE`,
or the `JoinKeyFile` option), never from a function argument. Pass it as a secret of your platform (a Docker or
Kubernetes secret, your CI's secret store), never in an image or a repository. The SDKs never print it, and they
remove Join keys, Device tokens and Coordinator keys from every log line and error.

If a key leaks, revoke it under Join keys in the console. Devices that already joined stay; remove them under Devices.

## Environment

| Variable | What |
|---|---|
| `TILTAS_JOIN_KEY` | The Join key. |
| `TILTAS_JOIN_KEY_FILE` | A file that holds the Join key, such as `/run/secrets/tiltas_join_key`. |
| `TILTAS_NAME` | The Device name to ask for. Default: the computer's host name. The Panel makes it unique, so a second `api` becomes `api-2`. |
| `TILTAS_PANEL` | The Panel. Default `https://tiltas.openpanel.sh`. Must be `https`. |
| `TILTAS_LIBRARY` | Python and Node.js: a libtiltas to load instead of the one the package carries. |

Options set in code win over the environment.
