Skip to main content

Collection

A named group of bookmarks. Collections can be manual (user adds bookmarks explicitly) or smart (bookmarks are included automatically based on a filter rule).

Attributes

AttributeTypeDescription
namestrDisplay name.
collection_type[CollectionType](collectiontype.md?sid=app_models_collection_collectiontype) = CollectionType.MANUALWhether the collection is manual or smart.
bookmark_idsList[str] = []Ordered list of bookmark IDs in the collection.
filter_rulestr = ""For smart collections, a query string that selects bookmarks.
is_pinnedbool = FalseWhether the collection appears at the top of the sidebar.
idstrUnique identifier.
created_atdatetimeCreation timestamp.

Methods


size()

@property
def size(self) -> int: ...

Number of bookmarks in the collection.

Returns

TypeDescription
intThe number of bookmarks in the collection.

is_smart()

@property
def is_smart(self) -> bool: ...

Whether this collection auto-populates based on a filter rule.

Returns

TypeDescription
boolTrue if the collection is smart, False otherwise.

add_bookmark()

def add_bookmark(self, bookmark_id: str) -> bool: ...

Add a bookmark to a manual collection.

Parameters

NameTypeDescription
bookmark_idstrID of the bookmark to add.

Returns

TypeDescription
boolTrue if added, False if already present or collection is smart.

remove_bookmark()

def remove_bookmark(self, bookmark_id: str) -> bool: ...

Remove a bookmark from the collection.

Parameters

NameTypeDescription
bookmark_idstrThe ID of the bookmark to remove from the collection.

Returns

TypeDescription
boolTrue if the bookmark was removed, False if it was not found in the collection.

reorder()

def reorder(self, bookmark_ids: List[str]) -> None: ...

Replace the bookmark ordering.

Parameters

NameTypeDescription
bookmark_idsList[str]New ordered list. Must contain the same IDs.

Returns

TypeDescription
NoneThis method does not return any value.

pin()

def pin(self) -> None: ...

Pin the collection to the top of the sidebar.

Returns

TypeDescription
NoneThis method does not return any value.

unpin()

def unpin(self) -> None: ...

Unpin the collection.

Returns

TypeDescription
NoneThis method does not return any value.

to_dict()

def to_dict(self) -> Dict[str, Any]: ...

Serialise to JSON-safe dictionary.

Returns

TypeDescription
Dict[str, Any]A dictionary representation of the collection, suitable for JSON serialization.

from_dict()

@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "Collection": ...

Construct from a dictionary.

Parameters

NameTypeDescription
dataDict[str, Any]A dictionary containing the data to construct the Collection.

Returns

TypeDescription
[Collection](collection.md?sid=app_models_collection_collection)A new Collection instance initialized from the provided dictionary data.