Package: aiolinkding
🔖 aiolinkding: a Python3, async library to the linkding REST APIaiolinkdingis a Python3, async library that interfaces withlinkdinginstances. It is intended to be a reasonably light wrapper around the linkding API
(meaning that instead of drowning the user in custom objects/etc., it focuses on
returning JSON straight from the API).InstallationPython VersionsUsageCreating a ClientWorking with BookmarksGetting All BookmarksGetting Archived BookmarksGetting a Single BookmarkCreating a New BookmarkUpdating an Existing Bookmark by IDArchiving/Unarchiving a BookmarkDeleting a BookmarkWorking with TagsGetting All TagsGetting a Single TagCreating a New TagWorking with User DataGetting Profile InfoConnection PoolingContributingInstallationpipinstallaiolinkdingPython Versionsaiolinkdingis currently supported on:Python 3.10Python 3.11Python 3.12UsageCreating a ClientIt's easy to create an API client for a linkding instance. All you need are two
parameters:A URL to a linkding instanceA linkding API tokenimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")asyncio.run(main())Working with BookmarksGetting All Bookmarksimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")# Get all bookmarks:bookmarks=awaitclient.bookmarks.async_get_all()# >>> { "count": 100, "next": null, "previous": null, "results": [...] }asyncio.run(main())client.bookmarks.async_get_all()takes three optional parameters:query: a string query to filter the returned bookmarkslimit: the maximum number of results that should be returnedoffset: the index from which to return results (e.g.,5starts at the fifth bookmark)Getting Archived Bookmarksimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")# Get all archived bookmarks:bookmarks=awaitclient.bookmarks.async_get_archived()# >>> { "count": 100, "next": null, "previous": null, "results": [...] }asyncio.run(main())client.bookmarks.async_get_archived()takes three optional parameters:query: a string query to filter the returned bookmarkslimit: the maximum number of results that should be returnedoffset: the index from which to return results (e.g.,5starts at the fifth bookmark)Getting a Single Bookmark by IDimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")# Get a single bookmark:bookmark=awaitclient.bookmarks.async_get_single(37)# >>> { "id": 37, "url": "https://example.com", "title": "Example title", ... }asyncio.run(main())Creating a New Bookmarkimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")# Create a new bookmark:created_bookmark=awaitclient.bookmarks.async_create("https://example.com",title="Example title",description="Example description",tag_names=["tag1","tag2",],)# >>> { "id": 37, "url": "https://example.com", "title": "Example title", ... }asyncio.run(main())client.bookmarks.async_create()takes four optional parameters:title: the bookmark's titledescription: the bookmark's descriptionnotes: Markdown notes to add to the bookmarktag_names: the tags to assign to the bookmark (represented as a list of strings)is_archived: whether the newly-created bookmark should automatically be archivedunread: whether the newly-created bookmark should be marked as unreadshared: whether the newly-created bookmark should be shareable with other linkding usersUpdating an Existing Bookmark by IDimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")# Update an existing bookmark:updated_bookmark=awaitclient.bookmarks.async_update(37,url="https://different-example.com",title="Different example title",description="Different example description",tag_names=["tag1","tag2",],)# >>> { "id": 37, "url": "https://different-example.com", ... }asyncio.run(main())client.bookmarks.async_update()takes four optional parameters (inclusion of any parameter
will change that value for the existing bookmark):url: the bookmark's URLtitle: the bookmark's titledescription: the bookmark's descriptionnotes: Markdown notes to add to the bookmarktag_names: the tags to assign to the bookmark (represented as a list of strings)unread: whether the bookmark should be marked as unreadshared: whether the bookmark should be shareable with other linkding usersArchiving/Unarchiving a Bookmarkimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")# Archive a bookmark by ID:awaitclient.bookmarks.async_archive(37)# ...and unarchive it:awaitclient.bookmarks.async_unarchive(37)asyncio.run(main())Deleting a Bookmarkimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")# Delete a bookmark by ID:awaitclient.bookmarks.async_delete(37)asyncio.run(main())Working with TagsGetting All Tagsimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")# Get all tags:tags=awaitclient.tags.async_get_all()# >>> { "count": 100, "next": null, "previous": null, "results": [...] }asyncio.run(main())client.tags.async_get_all()takes two optional parameters:limit: the maximum number of results that should be returnedoffset: the index from which to return results (e.g.,5starts at the fifth bookmark)Getting a Single Tag by IDimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")# Get a single tag:tag=awaitclient.tags.async_get_single(22)# >>> { "id": 22, "name": "example-tag", ... }asyncio.run(main())Creating a New Tagimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")# Create a new tag:created_tag=awaitclient.tags.async_create("example-tag")# >>> { "id": 22, "name": "example-tag", ... }asyncio.run(main())Working with User DataGetting Profile Infoimportasynciofromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345")# Get all tags:tags=awaitclient.user.async_get_profile()# >>> { "theme": "auto", "bookmark_date_display": "relative", ... }asyncio.run(main())Connection PoolingBy 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), anaiohttpClientSessioncan be used for
connection pooling:importasynciofromaiohttpimportasync_get_clientSessionfromaiolinkdingimportasync_get_clientasyncdefmain()->None:"""Use aiolinkding for fun and profit."""asyncwithClientSession()assession:client=awaitasync_get_client("http://127.0.0.1:8000","token_abcde12345",session=session)# Get to work...asyncio.run(main())ContributingThanks to all ofour contributorsso far!Check for open features/bugsorinitiate 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/activateInstall the dev environment:script/setupCode your new feature or bug fix on a new branch.Write tests that cover your new functionality.Run tests and ensure 100% code coverage:poetry run pytest --cov aiolinkding testsUpdateREADME.mdwith any new documentation.Submit a pull request!