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.

Reason this release was yanked:

Contain missing API path

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.0.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.0-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: forjio_linksnap-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 29e3e5c029146735666ef906cf6230274145dd6f1f25c466c4f8c46b82548539
MD5 2afbca37cde5a842fdfc795a8637bc54
BLAKE2b-256 158a9c204d7b8620fd57c17d28e27558e9bb859dcbb8325b3fc62b9d2df76ac6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: forjio_linksnap-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce04e5cc182409c9a96ba5dc8bb7c825a0756a2b4dee981283a1767ede15e522
MD5 9be6513436170993f9e9f2662cdf7cf7
BLAKE2b-256 1ae6af87efeb7c532ee112869b0418cee05b6ab3586dae5e17f709351c7c8fa9

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