Skip to content

Commit 87ee46a

Browse files
authored
Merge pull request #261 from ITAYC0HEN/feature/getBacklinksForBlock
Add support for listing backlinks of a page
2 parents bbd479b + 25c0063 commit 87ee46a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

notion/block.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,17 @@ class PageBlock(BasicBlock):
542542

543543
locked = field_map("format.block_locked")
544544

545+
def get_backlinks(self):
546+
"""
547+
Returns a list of blocks that referencing the current PageBlock. Note that only PageBlocks support backlinks.
548+
"""
549+
data = self._client.post(
550+
"getBacklinksForBlock",
551+
{"blockId": self.id},
552+
).json()
553+
if "backlinks" not in data:
554+
return None
555+
return [self._client.get_block(block.get("mentioned_from").get("block_id")) for block in data.get("backlinks")]
545556

546557
class BulletedListBlock(BasicBlock):
547558

0 commit comments

Comments
 (0)