Skip to main content

Official Python SDK for LinkSnap — short links, QR codes, click analytics, custom domains, workspaces, and billing with Huudis OIDC device-flow auth.

Project description

linksnap (Python)

Official Python SDK for LinkSnap. Resource-namespaced client for short links, QR codes, click analytics, custom domains, workspaces, billing, and API keys — with Huudis OIDC device-flow auth and the Forjio multi-profile credentials store.

Python parity with @forjio/linksnap-node.

Install

pip install forjio-linksnap

Quickstart

from forjio_linksnap import LinkSnapClient

# Static API key (CI / headless):
ls = LinkSnapClient(api_key="lk_live_...")
link = ls.links.create({"url": "https://example.com/long/path", "slug": "promo"})
print(link["id"], link["slug"])

stats = ls.stats.show(link["slug"])
print(stats["totalClicks"])
ls.close()

Sign in with Huudis (device flow)

from forjio_linksnap import (
    LinkSnapClient,
    Session,
    start_device_flow,
    poll_device_token,
)
import webbrowser

ISSUER = "https://huudis.com"
CLIENT_ID = "oc_linksnap_cli"

# 1. Start the device flow
start = start_device_flow(issuer=ISSUER, client_id=CLIENT_ID)
print(f"Open {start.verification_uri} and enter {start.user_code}")
webbrowser.open(start.verification_uri_complete or start.verification_uri)

# 2. Poll for the user's approval
tokens = poll_device_token(
    issuer=ISSUER, client_id=CLIENT_ID, device_code=start.device_code, interval=start.interval
)

# 3. Persist the session (~/.linksnap/credentials, ini-format)
from forjio_linksnap import ProfileData
session = Session(brand="linksnap", profile="default")
session.save(
    ProfileData(
        access_token=tokens.access_token,
        expires_at=tokens.expires_at,
        issuer=ISSUER,
        client_id=CLIENT_ID,
        refresh_token=tokens.refresh_token,
        scope=tokens.scope,
    )
)

# 4. Build a client backed by the session — auto-refreshes on expiry
ls = LinkSnapClient(session=session)
me = ls.account.me()
print(me)

Resource surface

Namespace Methods
client.links list, get, create, update, delete, bulk, export, import_csv
client.stats show, export, workspace
client.qr list, get, create, delete, download, stats
client.tags list
client.domains list, add, verify, remove
client.billing plans, plan, subscription, usage, history, invoices, checkout, cancel, downgrade
client.workspace show, rename, members.list, members.add, members.remove
client.api_keys list, create, delete
client.account me, update, change_password, delete
client.health() unauthenticated health probe

Every method accepts an optional auth_token= keyword to override the client-level bearer for a single call (same shape as the Node SDK's (args, authToken?) calling convention).

Errors

from forjio_linksnap import LinkSnapError

try:
    ls.links.create({})
except LinkSnapError as e:
    print(e.code, e.message, e.status, e.request_id)

LinkSnapError carries .code / .message / .status / .request_id / .details — parity with the Node SDK's LinkSnapError (= @forjio/sdk ApiError).

Source

https://github.com/hachimi-cat/saas-linksnap/tree/master/sdk/python

License

MIT

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

forjio_linksnap-0.1.1.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forjio_linksnap-0.1.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file forjio_linksnap-0.1.1.tar.gz.

File metadata

  • Download URL: forjio_linksnap-0.1.1.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for forjio_linksnap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 136652cd6b04f0a163ccd4647fa5d67fdbcc66aec49bcd7a7c480b2f0c590704
MD5 36725da4c81fb77b16b4fe0927f19c8f
BLAKE2b-256 0ffffb1bc0961ffed3b7612cec618a8ba337124a6d16501f35588c5664708d1d

See more details on using hashes here.

File details

Details for the file forjio_linksnap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: forjio_linksnap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for forjio_linksnap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8ef998c791c98023c6124e6875007f452cdd778ba0d9a0011cd45642c93df40
MD5 2503a4d796910dfa0c5a65c102a0f676
BLAKE2b-256 2845474f286c37a889ca6a6ca25ac5c6df0ad3ce1daa7147f1b718acc97e5cbf

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