anytype.Object
Bases: APIWrapper
Represents an object within a specific space, allowing creation and manipulation of its properties. The object can be customized with various attributes such as name
, icon
, body
, description
, and more. This class provides methods to export objects and add different content types to the object body, such as titles, text, code blocks, checkboxes, and bullet points.
IMPORTANT
Certain properties of an object, such as:
DOI
in a collection of articles;Release Year
in albums;Genre
in music collections;Author
in book collections;Publication Date
in documents;Rating
in review-based objects;Tags
in categorized objects;
are accessible through the class properties. For example, if an object is created with a Type
(e.g., anytype.Type
) that includes a DOI
property, the DOI URL can be set during the object creation using Object.doi
.
Note that these property names are derived from the corresponding name in the Anytype GUI. They are all lowercase with spaces replaced by underscores. For instance, a property called Release Year
in the Anytype GUI will be accessed as release_year
in the object, and a property called Publication Date
will be accessed as publication_date
.
Source code in anytype/object.py
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
|
add_bullet(text)
Adds a bullet point to the object's body.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to be added as a bullet point. |
required |
add_checkbox(text, checked=False)
Adds a checkbox to the object's body.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to be added next to the checkbox. |
required |
checked
|
bool
|
Whether the checkbox is checked. Default is False. |
False
|
Source code in anytype/object.py
add_codeblock(code, language='')
Adds a code block to the object's body.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
code
|
str
|
The code to be added. |
required |
language
|
str
|
The programming language of the code block. Default is an empty string. |
''
|
Source code in anytype/object.py
add_image(image_url, alt='', title='')
Adds an image to the object's body.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_url
|
str
|
The URL of the image. |
required |
alt
|
str
|
The alternative text for the image. Default is an empty string. |
''
|
title
|
str
|
The title of the image. Default is an empty string. |
''
|
Source code in anytype/object.py
add_text(text)
Adds plain text to the object's body.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to be added. |
required |
add_title1(text)
Adds a level 1 title to the object's body.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to be added as a level 1 title. |
required |
add_title2(text)
Adds a level 2 title to the object's body.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to be added as a level 2 title. |
required |
add_title3(text)
Adds a level 3 title to the object's body.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to be added as a level 3 title. |
required |
add_type(type)
Adds a type for an Object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type
|
Type
|
Type from the space retrieved using |
required |