Skip to main content

Collection

A named group of bookmarks.

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()

@classmethod
def size() - > int

Number of bookmarks in the collection.

Returns

TypeDescription
intThe total count of bookmark IDs currently stored in the collection.

is_smart()

@classmethod
def is_smart() - > bool

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

Returns

TypeDescription
boolTrue if the collection type is SMART, False otherwise.

add_bookmark()

@classmethod
def add_bookmark(
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()

@classmethod
def remove_bookmark(
bookmark_id: str
) - > bool

Remove a bookmark from the collection.

Parameters

NameTypeDescription
bookmark_idstrThe unique identifier of the bookmark to be removed from the list.

Returns

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

reorder()

@classmethod
def reorder(
bookmark_ids: List[str]
) - > None

Replace the bookmark ordering.

Parameters

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

Returns

TypeDescription
Nonenull

pin()

@classmethod
def pin() - > None

Pin the collection to the top of the sidebar.

Returns

TypeDescription
Nonenull

unpin()

@classmethod
def unpin() - > None

Unpin the collection.

Returns

TypeDescription
Nonenull

to_dict()

@classmethod
def to_dict() - > Dict[str, Any]

Serialise to JSON-safe dictionary.

Returns

TypeDescription
Dict[str, Any]A dictionary containing the collection's metadata, including ID, name, type, and bookmark list.

from_dict()

@classmethod
def from_dict(
data: Dict[str, Any]
) - > [Collection](collection.md?sid=app_models_collection_collection)

Construct from a dictionary.

Parameters

NameTypeDescription
dataDict[str, Any]A dictionary containing collection attributes like name, type, and filter_rule.

Returns

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