-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_collections.py
More file actions
39 lines (27 loc) · 979 Bytes
/
list_collections.py
File metadata and controls
39 lines (27 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
List all Raindrop collections
"""
import os
import requests
from dotenv import load_dotenv
# 1. Load environment variables from .env
load_dotenv()
# 2. Read configuration
API_TOKEN = os.getenv('RAINDROP_API_TOKEN')
# 3. Verify that everything is configured
if not API_TOKEN:
raise ValueError("RAINDROP_API_TOKEN not found in .env")
print("Configuration loaded.")
# 4. Set headers for API
headers = {'Authorization': f'Bearer {API_TOKEN}'}
# 5. Retrieve collections
print("Retrieving collections...")
response = requests.get('https://api.raindrop.io/rest/v1/collections', headers=headers)
response.raise_for_status()
collections = response.json()['items']
print(f"Found {len(collections)} collections.")
# Filter top-level groups (collections without parent)
groups = [c for c in collections if 'parent' not in c or not c.get('parent')]
print(f"Top-level groups: {len(groups)}")
for group in groups:
print(f" ID: {group['_id']} - Title: {group['title']}")