Action

Notion: List Databases

Posted by agiletortoise, Last update 6 months ago

List databases shared with the Drafts integration in your Notion workspace. Meant only as a demo of making basic calls with the Notion script object.

For more information on Notion integration, see our Notion Integration Guide

Steps

  • script

    // list databases which have been shared with the Drafts integration
    // API Docs: https://developers.notion.com/reference/post-search
    let endpoint = "https://api.notion.com/v1/search"
    
    // create Notion instance to make request
    // 'filter' specifies only database objects
    let notion = Notion.create();
    let response = notion.request({
    	"url": endpoint,
    	"method": "POST",
    	"data": {
    		"filter": {
    			"value": "database",
    			"property": "object"
    		}
    	}
    });
    
    // result has JSON payload
    // with page properties
    if (response.statusCode == 200) {
    	alert(`Notion Databases Loaded:
    	
    ${JSON.stringify(response.responseData, null, 2)}`)
    }
    else {
    	alert(`Notion Error: ${response.statusCode}
    	
    ${notion.lastError}`);
    	context.fail();
    }

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.