Skip to main content

Python client library for Readeck APIs

Project description

Readeck Python Client

A Python client library for the Readeck API, providing easy access to Readeck's bookmark and reading features.

Features

  • Full async/await support
  • Type hints with Pydantic models
  • Comprehensive error handling
  • Support for Python 3.10+
  • Easy authentication with Bearer tokens

Installation

pip install readeck

Quick Start

import asyncio
from readeck import ReadeckClient

async def main():
    client = ReadeckClient(
        base_url="https://your-readeck-instance.com",
        token="your-bearer-token"
    )

    # Get user profile
    profile = await client.get_user_profile()
    print(f"Welcome, {profile.user.username}!")

    # Create a bookmark
    result = await client.create_bookmark(
        url="https://example.com/article",
        title="Interesting Article",
        labels=["reading", "tech"]
    )
    print(f"Bookmark created with ID: {result.bookmark_id}")

    await client.close()

if __name__ == "__main__":
    asyncio.run(main())

Authentication

The client uses Bearer token authentication. You can obtain your token from your Readeck instance's settings.

client = ReadeckClient(
    base_url="https://your-readeck-instance.com",
    token="your-bearer-token"
)

API Reference

User Profile

Get the current user's profile information:

profile = await client.get_user_profile()

Returns a UserProfile object containing:

  • User information (username, email, creation date)
  • Authentication provider details
  • User settings and preferences
  • Reader settings (font, font size, line height)

Bookmarks

Create Bookmark

Create a new bookmark:

# Minimal bookmark
result = await client.create_bookmark(url="https://example.com")

# Bookmark with title
result = await client.create_bookmark(
    url="https://example.com/article",
    title="Article Title"
)

# Bookmark with labels
result = await client.create_bookmark(
    url="https://example.com/tutorial",
    labels=["tutorial", "programming"]
)

# Complete bookmark
result = await client.create_bookmark(
    url="https://example.com/complete",
    title="Complete Example",
    labels=["example", "complete", "demo"]
)

The create_bookmark method returns a BookmarkCreateResult object containing:

  • response: The API response with message and status
  • bookmark_id: The ID of the created bookmark (from response headers)
  • location: The URL of the created resource (from response headers)

Get Bookmarks

Retrieve bookmarks with optional filtering:

# Get all bookmarks
bookmarks = await client.get_bookmarks()

# Get bookmarks with parameters
from readeck import BookmarkListParams

params = BookmarkListParams(
    limit=10,
    search="python",
    labels="programming"
)
bookmarks = await client.get_bookmarks(params)

Export Bookmarks

Export bookmarks in different formats:

bookmark_id = "some_bookmark_id"

# Export as markdown (default format)
markdown_content = await client.export_bookmark(bookmark_id)

# Export as markdown explicitly
markdown_content = await client.export_bookmark(bookmark_id, format="md")

# Export as EPUB
epub_content = await client.export_bookmark(bookmark_id, format="epub")

# Save to files
with open("article.md", "w", encoding="utf-8") as f:
    f.write(markdown_content)

with open("article.epub", "wb") as f:
    f.write(epub_content)

Supported export formats:

  • md (markdown) - Returns a string with the article content as markdown
  • epub - Returns bytes containing the EPUB file data

Development

This project uses uv for dependency management:

# Install dependencies
uv sync --dev

# Run tests
uv run pytest

# Run linting
uv run black src tests
uv run isort src tests
uv run flake8 src tests
uv run mypy src

# Run all checks
uv run pre-commit run --all-files

License

MIT License. See LICENSE for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

readeck-0.1.3.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

readeck-0.1.3-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file readeck-0.1.3.tar.gz.

File metadata

  • Download URL: readeck-0.1.3.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for readeck-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3aa2908d2685c950ff5cd2e73393d80997df674f28d6726d46d8c5071d4fc73a
MD5 2b2069050a14270b19eac3c8a0e25f7d
BLAKE2b-256 8c233899cad2822a3ea89e95d116e8d749882861e377d2a98c355d43d728839d

See more details on using hashes here.

File details

Details for the file readeck-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: readeck-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for readeck-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 92f128c708af5174e98e3cdf7f410b380abf52f5fc0d1cedad83d027b7708054
MD5 4a804aea7d4d3323bd6336704092209a
BLAKE2b-256 6884d161c8a393b13802bd78fb89d31f926d4b2d5f4d22f30da1089664e37417

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