Skip to main content

The official Python SDK for dco.ink - A minimalist and developer-friendly URL shortener

Project description

dcoink - Official Python SDK for dco.ink

The official, beautifully typed Python SDK for dco.ink - the minimalist, privacy-first URL shortener.

Installation

pip install dcoink

Quick Start (Anonymous Mode)

You don't even need an account to start shortening URLs! The SDK provides a blazing-fast anonymous mode.

import dcoink

link = dcoink.shorten("https://example.com/a-very-long-url-that-needs-shortening")

print(f"Short URL: {link.short_url}")
# Output: https://dco.ink/xyz123

Authenticated Mode

By passing your API Key, you can manage your links and access advanced features (like specifying custom short codes).

import dcoink

link = dcoink.shorten(
    "https://example.com/my-campaign",
    custom_code="mybrand",
    api_key="dco_xxxxxx"
)

print(link.short_url)
# Output: https://dco.ink/mybrand

Advanced Usage (Client API)

For robust applications, use the Client to manage your links, check history, and more.

from dcoink import Client

with Client(api_key="dco_xxxxxx") as client:
    # Get user info
    me = client.get_me()
    print(f"Logged in as {me.name}")
    
    # Create a link
    link = client.create_link("https://github.com", custom_code="git")
    
    # List history
    links = client.list_links(limit=10)
    for l in links:
        print(l.short_url, l.clicks)
        
    # Update and delete
    client.update_link("git", "https://github.com/new-target")
    client.delete_link("git")

Async Support

Building high-concurrency scrapers or bots? We've got you covered with AsyncClient powered by httpx.

import asyncio
from dcoink import AsyncClient

async def main():
    async with AsyncClient(api_key="dco_xxxxxx") as client:
        link = await client.create_link("https://example.com")
        print(link.short_url)

asyncio.run(main())

Built-in CLI Tool

When you install the SDK, you also get a neat terminal command!

# Quick shorten
dcoink shorten https://example.com

# Custom short code
dcoink shorten https://example.com -c mybrand -k dco_xxxxxx

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

dcoink-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

dcoink-0.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dcoink-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for dcoink-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8a9e689dc0a8866f74f44b4190bec484457cc01f82bd84d0af13cf05a3ca85d7
MD5 514957935367f75a8c9afae46b150a8e
BLAKE2b-256 fc31dbdb0e70abf1c3c0e77df04e0209d35ba489787dd35c90ebe632430ccd65

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dcoink-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for dcoink-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17d0d793d0a77835984f7fedbecdcf9428ed030de2491baf6b00cd94ae99f9d3
MD5 75ca503f69f46c2b402e8b57756c6cea
BLAKE2b-256 01ef6bef33341617fe531bc79b8c70e9c7e7ed58d9575b5f5c6f27fd6fed611b

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