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
namestringDisplay name.
collection_type[CollectionType](collectiontype.md?sid=app_models_collection_collectiontype) = CollectionType.MANUALWhether the collection is manual or smart.
bookmark_idslist of strings = []Ordered list of bookmark IDs in the collection.
filter_rulestringFor smart collections, a query string that selects bookmarks.
is_pinnedboolean = falseWhether the collection appears at the top of the sidebar.
idstringUnique identifier.
created_atdatetimeCreation timestamp.

Constructor

Signature

def Collection(
name: str,
collection_type: [CollectionType](collectiontype.md?sid=app_models_collection_collectiontype) = CollectionType.MANUAL,
bookmark_ids: List[str] = [],
filter_rule: str = "",
is_pinned: bool = False,
id: str = uuid.uuid4().hex[:10],
created_at: datetime = datetime.utcnow
)

Parameters

NameTypeDescription
namestrThe display name of the collection.
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.
filter_rulestr = ""Query string for smart collections.
is_pinnedbool = FalseWhether the collection is pinned in the sidebar.
idstr = uuid.uuid4().hex[:10]Unique identifier for the collection.
created_atdatetime = datetime.utcnowThe timestamp when the collection was created.

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

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

Replace the bookmark ordering.

Parameters

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

pin()

@classmethod
def pin()

Pin the collection to the top of the sidebar.


unpin()

@classmethod
def unpin()

Unpin the collection.


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, bookmark IDs, and state

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 such as name, type, and filter_rule

Returns

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