karakeep-python-api 0.2.3__tar.gz → 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {karakeep_python_api-0.2.3/karakeep_python_api.egg-info → karakeep_python_api-1.1.0}/PKG-INFO +22 -17
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/README.md +21 -16
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/karakeep_python_api/__main__.py +14 -12
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/karakeep_python_api/datatypes.py +1 -0
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/karakeep_python_api/karakeep_api.py +149 -62
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/karakeep_python_api/openapi_reference.json +8 -1
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0/karakeep_python_api.egg-info}/PKG-INFO +22 -17
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/setup.py +1 -1
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/tests/test_karakeep_api.py +188 -90
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/LICENSE +0 -0
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/MANIFEST.in +0 -0
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/karakeep_python_api/__init__.py +0 -0
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/karakeep_python_api.egg-info/SOURCES.txt +0 -0
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/karakeep_python_api.egg-info/dependency_links.txt +0 -0
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/karakeep_python_api.egg-info/entry_points.txt +0 -0
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/karakeep_python_api.egg-info/requires.txt +0 -0
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/karakeep_python_api.egg-info/top_level.txt +0 -0
- {karakeep_python_api-0.2.3 → karakeep_python_api-1.1.0}/setup.cfg +0 -0
{karakeep_python_api-0.2.3/karakeep_python_api.egg-info → karakeep_python_api-1.1.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: karakeep_python_api
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Community python client for the Karakeep API.
|
|
5
5
|
Home-page: https://github.com/thiswillbeyourgithub/karakeep_python_api/
|
|
6
6
|
License: GPLv3
|
|
@@ -52,6 +52,7 @@ A community-developed Python client for the [Karakeep](https://karakeep.app/) AP
|
|
|
52
52
|
- [Environment Variables](#environment-variables)
|
|
53
53
|
- [Command Line Interface (CLI)](#command-line-interface-cli)
|
|
54
54
|
- [Python Library](#python-library)
|
|
55
|
+
- [Community Scripts](#community-scripts)
|
|
55
56
|
- [Development](#development)
|
|
56
57
|
- [License](#license)
|
|
57
58
|
|
|
@@ -136,7 +137,7 @@ This package can be used as a Python library or as a command-line interface (CLI
|
|
|
136
137
|
|
|
137
138
|
The client can be configured using the following environment variables:
|
|
138
139
|
|
|
139
|
-
* `
|
|
140
|
+
* `KARAKEEP_PYTHON_API_ENDPOINT`: **Required**. The full URL of your Karakeep API, including the `/api/v1/` path (e.g., `https://karakeep.domain.com/api/v1/` or `https://try.karakeep.app/api/v1/`).
|
|
140
141
|
* `KARAKEEP_PYTHON_API_KEY`: **Required**. Your Karakeep API key (Bearer token).
|
|
141
142
|
* `KARAKEEP_PYTHON_API_VERIFY_SSL`: Set to `false` to disable SSL certificate verification (default: `true`).
|
|
142
143
|
* `KARAKEEP_PYTHON_API_VERBOSE`: Set to `true` to enable verbose debug logging for the client and CLI (default: `false`).
|
|
@@ -145,7 +146,7 @@ The client can be configured using the following environment variables:
|
|
|
145
146
|
|
|
146
147
|
### Command Line Interface (CLI)
|
|
147
148
|
|
|
148
|
-
The CLI dynamically generates commands based on the API methods. You need to provide your API key and
|
|
149
|
+
The CLI dynamically generates commands based on the API methods. You need to provide your API key and endpoint either via environment variables (recommended) or command-line options.
|
|
149
150
|
|
|
150
151
|
**Basic Structure:**
|
|
151
152
|
|
|
@@ -170,8 +171,8 @@ python -m karakeep_python_api get-all-bookmarks --help
|
|
|
170
171
|
python -m karakeep_python_api get-all-tags
|
|
171
172
|
|
|
172
173
|
# Get the first page of bookmarks with a limit, overriding env vars if needed
|
|
173
|
-
# Note:
|
|
174
|
-
python -m karakeep_python_api --base-url https://
|
|
174
|
+
# Note: The /api/v1/ path will be automatically appended if not present
|
|
175
|
+
python -m karakeep_python_api --base-url https://karakeep.domain.com/api/v1/ --api-key YOUR_API_KEY get-all-bookmarks --limit 10
|
|
175
176
|
|
|
176
177
|
# Get all lists and pipe the JSON output to jq to extract the first list
|
|
177
178
|
python -m karakeep_python_api get-all-lists | jq '.[0]'
|
|
@@ -195,14 +196,14 @@ import os
|
|
|
195
196
|
from karakeep_python_api import KarakeepAPI, APIError, AuthenticationError, datatypes
|
|
196
197
|
|
|
197
198
|
# Ensure required environment variables are set
|
|
198
|
-
# Example: os.environ["
|
|
199
|
+
# Example: os.environ["KARAKEEP_PYTHON_API_ENDPOINT"] = "https://karakeep.domain.com/api/v1/"
|
|
199
200
|
# Example: os.environ["KARAKEEP_PYTHON_API_KEY"] = "your_secret_api_key"
|
|
200
201
|
|
|
201
202
|
try:
|
|
202
203
|
# Initialize the client (reads from env vars by default)
|
|
203
204
|
client = KarakeepAPI(
|
|
204
205
|
# Optionally override env vars:
|
|
205
|
-
#
|
|
206
|
+
# api_endpoint="https://karakeep.domain.com/api/v1/",
|
|
206
207
|
# api_key="another_key",
|
|
207
208
|
# verbose=True,
|
|
208
209
|
# disable_response_validation=False
|
|
@@ -232,23 +233,27 @@ except AuthenticationError as e:
|
|
|
232
233
|
except APIError as e:
|
|
233
234
|
print(f"An API error occurred: {e}")
|
|
234
235
|
except ValueError as e:
|
|
235
|
-
# Handles missing API key/
|
|
236
|
+
# Handles missing API key/endpoint during initialization
|
|
236
237
|
print(f"Configuration error: {e}")
|
|
237
238
|
except Exception as e:
|
|
238
239
|
print(f"An unexpected error occurred: {e}")
|
|
239
240
|
|
|
240
241
|
```
|
|
241
242
|
|
|
242
|
-
|
|
243
|
+
## Community Scripts
|
|
243
244
|
|
|
244
|
-
|
|
245
|
+
Community Scripts are a bunch of scripts made to solve specific issues. They are made by the community so don't hesitate to submit yours or open an issue if you have a bug. They also serve as example of how to use the API.
|
|
245
246
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
|
249
|
-
|
|
250
|
-
| **
|
|
251
|
-
| **
|
|
247
|
+
They can be found in the [./community_scripts](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts) folder. Don't hesitate to submit yours, the contribution guidelines are in the community_scripts directory README.md file.
|
|
248
|
+
|
|
249
|
+
| Community Script | Description | Documentation |
|
|
250
|
+
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
|
|
251
|
+
| **Karakeep-Time-Tagger** | Automatically adds time-to-read tags (`0-5m`, `5-10m`, etc.) to bookmarks based on content length analysis. Includes systemd service and timer files for automated periodic execution. | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/karakeep-time-tagger) |
|
|
252
|
+
| **Karakeep-List-To-Tag** | Converts a Karakeep list into tags by adding a specified tag to all bookmarks within that list. | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/karakeep-list-to-tag) |
|
|
253
|
+
| **Omnivore2Karakeep-Highlights** | Imports highlights from Omnivore export data to Karakeep, with intelligent position detection and bookmark matching. Supports dry-run mode for testing. | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/omnivore2karakeep-highlights) |
|
|
254
|
+
| **Omnivore2Karakeep-Archived** | (Should not be needed anymore) Fixes the archived status of bookmarks imported from Omnivore by reading export data and updating Karakeep accordingly. | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/omnivore2karakeep-archived) |
|
|
255
|
+
| **pocket2karakeep-archived** by [@youenchene](https://github.com/youenchene) | (Should not be needed anymore) Fixes the archived status of bookmarks imported from Pocket by reading export data and updating Karakeep accordingly. | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/pocket2karakeep-archived) |
|
|
256
|
+
| **karakeep-archive-before-date** by [@youenchene](https://github.com/youenchene) | Allow you to archive all not archived post before a given date | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/karakeep-archive-before-date) |
|
|
252
257
|
|
|
253
258
|
## Development
|
|
254
259
|
|
|
@@ -259,7 +264,7 @@ Examples of the API being used can be found in the [`./examples`](./examples) fo
|
|
|
259
264
|
```bash
|
|
260
265
|
uv pip install -e ".[dev]"
|
|
261
266
|
```
|
|
262
|
-
4. Set the required environment variables (`
|
|
267
|
+
4. Set the required environment variables (`KARAKEEP_PYTHON_API_ENDPOINT`, `KARAKEEP_PYTHON_API_KEY`) for running tests against a live instance.
|
|
263
268
|
5. Run tests:
|
|
264
269
|
|
|
265
270
|
```bash
|
|
@@ -17,6 +17,7 @@ A community-developed Python client for the [Karakeep](https://karakeep.app/) AP
|
|
|
17
17
|
- [Environment Variables](#environment-variables)
|
|
18
18
|
- [Command Line Interface (CLI)](#command-line-interface-cli)
|
|
19
19
|
- [Python Library](#python-library)
|
|
20
|
+
- [Community Scripts](#community-scripts)
|
|
20
21
|
- [Development](#development)
|
|
21
22
|
- [License](#license)
|
|
22
23
|
|
|
@@ -101,7 +102,7 @@ This package can be used as a Python library or as a command-line interface (CLI
|
|
|
101
102
|
|
|
102
103
|
The client can be configured using the following environment variables:
|
|
103
104
|
|
|
104
|
-
* `
|
|
105
|
+
* `KARAKEEP_PYTHON_API_ENDPOINT`: **Required**. The full URL of your Karakeep API, including the `/api/v1/` path (e.g., `https://karakeep.domain.com/api/v1/` or `https://try.karakeep.app/api/v1/`).
|
|
105
106
|
* `KARAKEEP_PYTHON_API_KEY`: **Required**. Your Karakeep API key (Bearer token).
|
|
106
107
|
* `KARAKEEP_PYTHON_API_VERIFY_SSL`: Set to `false` to disable SSL certificate verification (default: `true`).
|
|
107
108
|
* `KARAKEEP_PYTHON_API_VERBOSE`: Set to `true` to enable verbose debug logging for the client and CLI (default: `false`).
|
|
@@ -110,7 +111,7 @@ The client can be configured using the following environment variables:
|
|
|
110
111
|
|
|
111
112
|
### Command Line Interface (CLI)
|
|
112
113
|
|
|
113
|
-
The CLI dynamically generates commands based on the API methods. You need to provide your API key and
|
|
114
|
+
The CLI dynamically generates commands based on the API methods. You need to provide your API key and endpoint either via environment variables (recommended) or command-line options.
|
|
114
115
|
|
|
115
116
|
**Basic Structure:**
|
|
116
117
|
|
|
@@ -135,8 +136,8 @@ python -m karakeep_python_api get-all-bookmarks --help
|
|
|
135
136
|
python -m karakeep_python_api get-all-tags
|
|
136
137
|
|
|
137
138
|
# Get the first page of bookmarks with a limit, overriding env vars if needed
|
|
138
|
-
# Note:
|
|
139
|
-
python -m karakeep_python_api --base-url https://
|
|
139
|
+
# Note: The /api/v1/ path will be automatically appended if not present
|
|
140
|
+
python -m karakeep_python_api --base-url https://karakeep.domain.com/api/v1/ --api-key YOUR_API_KEY get-all-bookmarks --limit 10
|
|
140
141
|
|
|
141
142
|
# Get all lists and pipe the JSON output to jq to extract the first list
|
|
142
143
|
python -m karakeep_python_api get-all-lists | jq '.[0]'
|
|
@@ -160,14 +161,14 @@ import os
|
|
|
160
161
|
from karakeep_python_api import KarakeepAPI, APIError, AuthenticationError, datatypes
|
|
161
162
|
|
|
162
163
|
# Ensure required environment variables are set
|
|
163
|
-
# Example: os.environ["
|
|
164
|
+
# Example: os.environ["KARAKEEP_PYTHON_API_ENDPOINT"] = "https://karakeep.domain.com/api/v1/"
|
|
164
165
|
# Example: os.environ["KARAKEEP_PYTHON_API_KEY"] = "your_secret_api_key"
|
|
165
166
|
|
|
166
167
|
try:
|
|
167
168
|
# Initialize the client (reads from env vars by default)
|
|
168
169
|
client = KarakeepAPI(
|
|
169
170
|
# Optionally override env vars:
|
|
170
|
-
#
|
|
171
|
+
# api_endpoint="https://karakeep.domain.com/api/v1/",
|
|
171
172
|
# api_key="another_key",
|
|
172
173
|
# verbose=True,
|
|
173
174
|
# disable_response_validation=False
|
|
@@ -197,23 +198,27 @@ except AuthenticationError as e:
|
|
|
197
198
|
except APIError as e:
|
|
198
199
|
print(f"An API error occurred: {e}")
|
|
199
200
|
except ValueError as e:
|
|
200
|
-
# Handles missing API key/
|
|
201
|
+
# Handles missing API key/endpoint during initialization
|
|
201
202
|
print(f"Configuration error: {e}")
|
|
202
203
|
except Exception as e:
|
|
203
204
|
print(f"An unexpected error occurred: {e}")
|
|
204
205
|
|
|
205
206
|
```
|
|
206
207
|
|
|
207
|
-
|
|
208
|
+
## Community Scripts
|
|
208
209
|
|
|
209
|
-
|
|
210
|
+
Community Scripts are a bunch of scripts made to solve specific issues. They are made by the community so don't hesitate to submit yours or open an issue if you have a bug. They also serve as example of how to use the API.
|
|
210
211
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
|
214
|
-
|
|
215
|
-
| **
|
|
216
|
-
| **
|
|
212
|
+
They can be found in the [./community_scripts](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts) folder. Don't hesitate to submit yours, the contribution guidelines are in the community_scripts directory README.md file.
|
|
213
|
+
|
|
214
|
+
| Community Script | Description | Documentation |
|
|
215
|
+
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
|
|
216
|
+
| **Karakeep-Time-Tagger** | Automatically adds time-to-read tags (`0-5m`, `5-10m`, etc.) to bookmarks based on content length analysis. Includes systemd service and timer files for automated periodic execution. | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/karakeep-time-tagger) |
|
|
217
|
+
| **Karakeep-List-To-Tag** | Converts a Karakeep list into tags by adding a specified tag to all bookmarks within that list. | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/karakeep-list-to-tag) |
|
|
218
|
+
| **Omnivore2Karakeep-Highlights** | Imports highlights from Omnivore export data to Karakeep, with intelligent position detection and bookmark matching. Supports dry-run mode for testing. | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/omnivore2karakeep-highlights) |
|
|
219
|
+
| **Omnivore2Karakeep-Archived** | (Should not be needed anymore) Fixes the archived status of bookmarks imported from Omnivore by reading export data and updating Karakeep accordingly. | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/omnivore2karakeep-archived) |
|
|
220
|
+
| **pocket2karakeep-archived** by [@youenchene](https://github.com/youenchene) | (Should not be needed anymore) Fixes the archived status of bookmarks imported from Pocket by reading export data and updating Karakeep accordingly. | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/pocket2karakeep-archived) |
|
|
221
|
+
| **karakeep-archive-before-date** by [@youenchene](https://github.com/youenchene) | Allow you to archive all not archived post before a given date | [`Link`](https://github.com/thiswillbeyourgithub/karakeep_python_api/tree/main/community_scripts/karakeep-archive-before-date) |
|
|
217
222
|
|
|
218
223
|
## Development
|
|
219
224
|
|
|
@@ -224,7 +229,7 @@ Examples of the API being used can be found in the [`./examples`](./examples) fo
|
|
|
224
229
|
```bash
|
|
225
230
|
uv pip install -e ".[dev]"
|
|
226
231
|
```
|
|
227
|
-
4. Set the required environment variables (`
|
|
232
|
+
4. Set the required environment variables (`KARAKEEP_PYTHON_API_ENDPOINT`, `KARAKEEP_PYTHON_API_KEY`) for running tests against a live instance.
|
|
228
233
|
5. Run tests:
|
|
229
234
|
|
|
230
235
|
```bash
|
|
@@ -59,9 +59,9 @@ def serialize_output(data: Any) -> Any:
|
|
|
59
59
|
# Shared options for the API client
|
|
60
60
|
shared_options = [
|
|
61
61
|
click.option(
|
|
62
|
-
"--
|
|
63
|
-
envvar="
|
|
64
|
-
help="Full Karakeep API
|
|
62
|
+
"--api-endpoint",
|
|
63
|
+
envvar="KARAKEEP_PYTHON_API_ENDPOINT",
|
|
64
|
+
help="Full Karakeep API endpoint URL, including /api/v1/ (e.g., https://instance.com/api/v1/).",
|
|
65
65
|
),
|
|
66
66
|
click.option(
|
|
67
67
|
"--api-key",
|
|
@@ -151,7 +151,7 @@ def print_openapi_spec(ctx, param, value):
|
|
|
151
151
|
@click.pass_context
|
|
152
152
|
def cli(
|
|
153
153
|
ctx,
|
|
154
|
-
|
|
154
|
+
api_endpoint,
|
|
155
155
|
api_key,
|
|
156
156
|
verify_ssl,
|
|
157
157
|
verbose,
|
|
@@ -167,7 +167,7 @@ def cli(
|
|
|
167
167
|
# Ensure the context object exists
|
|
168
168
|
ctx.ensure_object(dict)
|
|
169
169
|
|
|
170
|
-
# --- Strict Check for API Key and
|
|
170
|
+
# --- Strict Check for API Key and Endpoint ---
|
|
171
171
|
# Check for API key (must be provided via arg or env)
|
|
172
172
|
resolved_api_key = api_key or os.environ.get("KARAKEEP_PYTHON_API_KEY")
|
|
173
173
|
if not resolved_api_key:
|
|
@@ -175,16 +175,18 @@ def cli(
|
|
|
175
175
|
"API Key is required. Provide --api-key option or set KARAKEEP_PYTHON_API_KEY environment variable."
|
|
176
176
|
)
|
|
177
177
|
|
|
178
|
-
# Check for
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
# Check for API endpoint (must be provided via arg or env)
|
|
179
|
+
resolved_api_endpoint = api_endpoint or os.environ.get(
|
|
180
|
+
"KARAKEEP_PYTHON_API_ENDPOINT"
|
|
181
|
+
)
|
|
182
|
+
if not resolved_api_endpoint:
|
|
181
183
|
raise click.UsageError(
|
|
182
|
-
"API
|
|
184
|
+
"API endpoint is required. Provide --api-endpoint option or set KARAKEEP_PYTHON_API_ENDPOINT environment variable. "
|
|
183
185
|
"The URL must include the API path, e.g., 'https://your-instance.com/api/v1/'."
|
|
184
186
|
)
|
|
185
187
|
|
|
186
188
|
# Store common API parameters in the context for commands to use
|
|
187
|
-
ctx.obj["
|
|
189
|
+
ctx.obj["API_ENDPOINT"] = resolved_api_endpoint # Store the resolved endpoint
|
|
188
190
|
ctx.obj["API_KEY"] = resolved_api_key # Store the resolved key
|
|
189
191
|
ctx.obj["VERIFY_SSL"] = verify_ssl
|
|
190
192
|
ctx.obj["VERBOSE"] = verbose
|
|
@@ -231,7 +233,7 @@ def create_click_command(
|
|
|
231
233
|
def command_func(ctx, **kwargs):
|
|
232
234
|
"""Dynamically generated command function wrapper."""
|
|
233
235
|
# Retrieve API parameters from context, ensuring API key is present now
|
|
234
|
-
|
|
236
|
+
api_endpoint = ctx.obj["API_ENDPOINT"]
|
|
235
237
|
api_key = ctx.obj["API_KEY"]
|
|
236
238
|
verify_ssl = ctx.obj["VERIFY_SSL"]
|
|
237
239
|
verbose = ctx.obj["VERBOSE"]
|
|
@@ -250,7 +252,7 @@ def create_click_command(
|
|
|
250
252
|
# Method generation already happened during inspection phase or initial load
|
|
251
253
|
api = KarakeepAPI(
|
|
252
254
|
api_key=api_key,
|
|
253
|
-
|
|
255
|
+
api_endpoint=api_endpoint,
|
|
254
256
|
verify_ssl=verify_ssl,
|
|
255
257
|
verbose=verbose,
|
|
256
258
|
disable_response_validation=disable_validation, # Pass flag to constructor
|