@@ -36,6 +36,123 @@ const collectionData = await api.getCollectionData(
3636)
3737```
3838
39+ ### Fetch a database's content
40+
41+ You can pass a database ID to the ` getPage ` method. The response is an object which contains several important properties:
42+
43+ - ` block `
44+ - ` collection `
45+ - ` collection_view `
46+
47+ The value of the ` block ` property maps the id of each block object present in the database to its corresponding properties like type, parent id, created time, last edited by, and more.
48+
49+ ```
50+ {
51+ block: {
52+ 'cc368b47-772a-4a1a-a36e-1f52c507d20d': { role: 'reader', value: [Object] },
53+ '97dbe6d5-aea3-4e03-b571-91810cf975d4': { role: 'reader', value: [Object] },
54+ '08d5ba1e-03d2-4d4a-add7-a414f297ff8a': { role: 'reader', value: [Object] },
55+ '7aad4627-c4af-4314-960e-1465e76cc6bd': { role: 'reader', value: [Object] },
56+ '7be73360-19b9-4b77-a518-70acd610d492': { role: 'reader', value: [Object] },
57+ 'af961803-cd0c-470e-bd27-1d025baa2f95': { role: 'reader', value: [Object] },
58+ // ...
59+ }
60+ }
61+ ```
62+
63+ The map of blocks is arranged as followed:
64+
65+ - The first id is of the collection view
66+ - The second is of the parent page that contains the database in question
67+ - The next ids are of all the children pages inside the database
68+ - After that comes all the children blocks of each page.
69+
70+
71+ Please note that a block object can take many types: header, text, list, media, and almost any block supported by Notion. It can also be * a page* or a * collection view* .
72+
73+ Example of a block object of type ` text ` :
74+
75+ ```
76+ {
77+ role: 'reader',
78+ value: {
79+ id: '0377e1a4-dc3d-4daf-99dd-f54f986d932e',
80+ version: 1,
81+ type: 'text',
82+ properties: { title: [Array] },
83+ format: { copied_from_pointer: [Object] },
84+ created_time: 1655961814278,
85+ last_edited_time: 1655961814278,
86+ parent_id: '08d5ba1e-03d2-4d4a-add7-a414f297ff8a',
87+ parent_table: 'block',
88+ alive: true,
89+ copied_from: '526d2008-0d0b-46f8-9de1-7411a85bff7b',
90+ created_by_table: 'notion_user',
91+ created_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',
92+ last_edited_by_table: 'notion_user',
93+ last_edited_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',
94+ space_id: '6b70425f-211e-4318-80c6-5d093df8f7eb'
95+ }
96+ }
97+ ```
98+
99+ Example of a block object of type ` page ` :
100+
101+ ```
102+ {
103+ role: 'reader',
104+ value: {
105+ id: 'af961803-cd0c-470e-bd27-1d025baa2f95',
106+ version: 31,
107+ type: 'page',
108+ properties: { '==~K': [Array], 'BN]P': [Array], title: [Array] },
109+ content: [
110+ '8cbf7053-da37-4d69-8cde-89343baf3623',
111+ '0fc1712e-852c-4307-b72b-094dadaa86ba'
112+ ],
113+ created_time: 1655962200000,
114+ last_edited_time: 1655979420000,
115+ parent_id: '175482e5-870d-4da8-980c-ead469427316',
116+ parent_table: 'collection',
117+ alive: true,
118+ created_by_table: 'notion_user',
119+ created_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',
120+ last_edited_by_table: 'notion_user',
121+ last_edited_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',
122+ space_id: '6b70425f-211e-4318-80c6-5d093df8f7eb'
123+ }
124+ }
125+ ```
126+
127+ Example of a block object of type ` collection_view ` :
128+ ```
129+ {
130+ role: 'reader',
131+ value: {
132+ id: 'cc368b47-772a-4a1a-a36e-1f52c507d20d',
133+ version: 5,
134+ type: 'collection_view',
135+ view_ids: [
136+ '028f6968-2a6c-46da-bf43-cb44e6d91765',
137+ '77f32047-52dd-422e-93fa-813438087e57'
138+ ],
139+ collection_id: '175482e5-870d-4da8-980c-ead469427316',
140+ format: { collection_pointer: [Object], copied_from_pointer: [Object] },
141+ created_time: 1655961814276,
142+ last_edited_time: 1656075900000,
143+ parent_id: '97dbe6d5-aea3-4e03-b571-91810cf975d4',
144+ parent_table: 'block',
145+ alive: true,
146+ copied_from: '3e3073e9-7aee-481c-b831-765e112ec7b5',
147+ created_by_table: 'notion_user',
148+ created_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',
149+ last_edited_by_table: 'notion_user',
150+ last_edited_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',
151+ space_id: '6b70425f-211e-4318-80c6-5d093df8f7eb'
152+ }
153+ }
154+ ```
155+
39156## Docs
40157
41158See the [ full docs] ( https://github.com/NotionX/react-notion-x ) .
0 commit comments