kevinbringard/tailscale-python-client

Python bindings for the TailScale API

★ 7Forks 4PythonGitHub ↗Compare

README

tailscale-python-client

Python bindings for the Tailscale API.

Requirements

  • Python 3.11+
  • Poetry (for development)

Installation

pip install tailscale-agent

Quick start

API key auth

from tailscale_agent.tailscale_agent import Tailscale

client = Tailscale(
    api_key='tskey-api-...',
    base_url='https://api.tailscale.com/api/v2',
    tailnet='example.com',
)

resp = client.get_devices()
print(resp.json())

OAuth auth

client = Tailscale(
    api_key='',  # replaced after token exchange
    base_url='https://api.tailscale.com/api/v2',
    tailnet='example.com',
)
client.get_oauth_token(
    client_id='your-oauth-client-id',
    client_secret='your-oauth-client-secret',
)

See the Tailscale OAuth guide for how to create an OAuth client.

Documentation

Development

# Install dependencies
poetry install

# Run unit tests
poetry run pytest tests/ -v -m "not smoke"

# Run live smoke tests (requires credentials)
export TAILSCALE_OAUTH_CLIENT_ID=...
export TAILSCALE_OAUTH_CLIENT_SECRET=...
export TAILSCALE_TAILNET=...
poetry run pytest tests/test_smoke.py -v -m smoke

This project is developed with the assistance of Claude Code by Anthropic.

Contributors

kevinbringarddependabot[bot]hamaadmemon

Issues