A Python3, async interface to the linkding REST API
Project description
🚰 aiolinkding: DESCRIPTION
DESCRIPTION
Installation
pip install aiolinkding
Python Versions
aiolinkding
is currently supported on:
- Python 3.8
- Python 3.9
- Python 3.10
Usage
Creating a Client
It's easy to create an API client for a linkding instance. All you need are two parameters:
- A URL to a linkding instance
- A linkding API token
import asyncio
from aiohttp import ClientSession
from aiolinkding import Client
async def main() -> None:
"""Create the aiohttp session and run the example."""
client = Client("http://127.0.0.1:8000", "token_abcde12345")
asyncio.run(main())
Working with Bookmarks
The Client
object provides easy access to several bookmark-related API operations:
import asyncio
from aiohttp import ClientSession
from aiolinkding import Client
async def main() -> None:
"""Create the aiohttp session and run the example."""
client = Client("http://127.0.0.1:8000", "token_abcde12345")
# Get all bookmarks:
bookmarks = await client.bookmarks.async_all()
# >>> { "count": 5, "next": null, "previous": null, "results": [...] }
asyncio.run(main())
By default, the library creates a new connection to linkding with each coroutine. If you
are calling a large number of coroutines (or merely want to squeeze out every second of
runtime savings possible), an
aiohttp
ClientSession
can be used for connection
pooling:
import asyncio
from aiohttp import ClientSession
from aionotion import async_get_client
async def main() -> None:
"""Create the aiohttp session and run the example."""
async with ClientSession() as session:
# Create a Notion API client:
client = Client("http://127.0.0.1:8000", "token_abcde12345", session=session)
# Get to work...
asyncio.run(main())
Contributing
- Check for open features/bugs or initiate a discussion on one.
- Fork the repository.
- (optional, but highly recommended) Create a virtual environment:
python3 -m venv .venv
- (optional, but highly recommended) Enter the virtual environment:
source ./.venv/bin/activate
- Install the dev environment:
script/setup
- Code your new feature or bug fix.
- Write tests that cover your new functionality.
- Run tests and ensure 100% code coverage:
nox -rs coverage
- Update
README.md
with any new documentation. - Add yourself to
AUTHORS.md
. - Submit a pull request!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiolinkding-0.0.1.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for aiolinkding-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37a3e99cd2aa16422b965de133685b7e8ab620861f52b6687f3350d0d21e236e |
|
MD5 | c61aaecf34fc9fd7d03d60f6160f742c |
|
BLAKE2b-256 | 27328cc6222dbb690586c9554a5f50f5019d05758a39285e875e843203d9dece |