← Notion

Updated Page in Database from Notion API

Pipedream makes it easy to connect APIs for Notion and 1,600+ other apps remarkably fast.

Trigger workflow on
Updated Page in Database from the Notion API
Next, do this
Connect to 1,600+ APIs using code and no-code building blocks
No credit card required
Intro to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜

Trusted by 750,000+ developers from startups to Fortune 500 companies

Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo
Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo

Developers Pipedream

Getting Started

Trigger a workflow on Updated Page in Database with Notion API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the Updated Page in Database trigger
    1. Connect your Notion account
    2. Configure timer
    3. Select a Database ID
    4. Optional- Select one or more Property Types
  2. Add steps to connect to 1,600+ APIs using code and no-code building blocks
  3. Deploy the workflow
  4. Send a test event to validate your setup
  5. Turn on the trigger

Integrations

Send Message with Discord Webhook API on Updated Page from Notion API
Notion + Discord Webhook
 
Try it
Add Multiple Rows with Google Sheets API on Updated Page from Notion API
Notion + Google Sheets
 
Try it
Get Film with SWAPI - Star Wars API on Updated Page from Notion API
Notion + SWAPI - Star Wars
 
Try it
Create Multiple Records with Airtable API on Updated Page from Notion API
Notion + Airtable (API Key)
 
Try it
Custom Request with HTTP / Webhook API on Updated Page from Notion API
Notion + HTTP / Webhook
 
Try it

Details

This is a pre-built, source-available component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Updated Page in Database on Notion
Description:Emit new event when a page in a database is updated. To select a specific page, use `Updated Page ID` instead
Version:0.0.12
Key:notion-updated-page

Code

import notion from "../../notion.app.mjs";
import sampleEmit from "./test-event.mjs";
import base from "../common/base.mjs";
import constants from "../common/constants.mjs";

export default {
  ...base,
  key: "notion-updated-page",
  name: "Updated Page in Database", /* eslint-disable-line pipedream/source-name */
  description: "Emit new event when a page in a database is updated. To select a specific page, use `Updated Page ID` instead",
  version: "0.0.12",
  type: "source",
  dedupe: "unique",
  props: {
    ...base.props,
    databaseId: {
      propDefinition: [
        notion,
        "databaseId",
      ],
    },
    properties: {
      propDefinition: [
        notion,
        "propertyTypes",
        (c) => ({
          parentId: c.databaseId,
          parentType: "database",
        }),
      ],
      description: "Only emit events when one or more of the selected properties has changed",
      optional: true,
    },
  },
  hooks: {
    async deploy() {
      if (!this.properties?.length) {
        return;
      }
      const propertyValues = {};
      const pagesStream = this.notion.getPages(this.databaseId);
      for await (const page of pagesStream) {
        propertyValues[page.id] = {};
        for (const property of this.properties) {
          propertyValues[page.id][property] = JSON.stringify(page.properties[property]);
        }
      }
      this._setPropertyValues(propertyValues);
    },
  },
  methods: {
    ...base.methods,
    _getPropertyValues() {
      return this.db.get("propertyValues");
    },
    _setPropertyValues(propertyValues) {
      this.db.set("propertyValues", propertyValues);
    },
  },
  async run() {
    const lastCheckedTimestamp = this.getLastUpdatedTimestamp();
    const lastCheckedTimestampDate = new Date(lastCheckedTimestamp);
    const lastCheckedTimestampISO = lastCheckedTimestampDate.toISOString();
    const propertyValues = this._getPropertyValues();

    // Add a filter so that we only receive pages that have been updated since the last call.
    const params = {
      ...this.lastUpdatedSortParam(),
      filter: {
        timestamp: "last_edited_time",
        last_edited_time: {
          after: lastCheckedTimestampISO,
        },
      },
    };
    let newLastUpdatedTimestamp = lastCheckedTimestamp;

    const pagesStream = this.notion.getPages(this.databaseId, params);

    for await (const page of pagesStream) {
      if (!this.isResultNew(page.last_edited_time, lastCheckedTimestamp)) {
        // The call to getPages() includes a descending sort by last_edited_time.
        // As soon as one page !isResultNew(), all of the following ones will also.
        // NOTE: the last_edited_filter means this will never be called,
        // but it's worth keeping as future-proofing.
        break;
      }

      newLastUpdatedTimestamp = Math.max(
        newLastUpdatedTimestamp,
        Date.parse(page?.last_edited_time),
      );

      if (this.properties?.length) {
        let propertyChangeFound = false;
        for (const property of this.properties) {
          const currentProperty = JSON.stringify(page.properties[property]);
          if (!propertyValues[page.id] || currentProperty !== propertyValues[page.id][property]) {
            propertyChangeFound = true;
            propertyValues[page.id] = {
              ...propertyValues[page.id],
              [property]: currentProperty,
            };
          }
        }
        if (!propertyChangeFound) {
          continue;
        }
      }

      const meta = this.generateMeta(
        page,
        constants.types.PAGE,
        constants.timestamps.LAST_EDITED_TIME,
        constants.summaries.PAGE_UPDATED,
        true,
      );

      this.$emit(page, meta);
    }

    this.setLastUpdatedTimestamp(newLastUpdatedTimestamp);
    this._setPropertyValues(propertyValues);
  },
  sampleEmit,
};

Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
NotionnotionappThis component uses the Notion app.
N/Adb$.service.dbThis component uses $.service.db to maintain state between executions.
timer$.interface.timer
Database IDdatabaseIdstringSelect a value from the drop down menu.
Property Typespropertiesstring[]Select a value from the drop down menu.

Authentication

Notion uses OAuth authentication. When you connect your Notion account, Pipedream will open a popup window where you can sign into Notion and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Notion API.

Pipedream requests the following authorization scopes when you connect your account:

About Notion

All-in-one workspace for notes, tasks, wikis and more

More Ways to Use Notion

Triggers

New Database from the Notion API

Emit new event when a database is created. Note: Databases must be shared with your Pipedream Integtration to trigger event.

 
Try it
New Page in Database from the Notion API

Emit new event when a page in a database is created

 
Try it
Page or Subpage Updated from the Notion API

Emit new event when a page or one of its sub-pages is updated.

 
Try it
Updated Page ID from the Notion API

Emit new event when a selected page is updated

 
Try it

Actions

Append Block to Parent with the Notion API

Creates and appends blocks to the specified parent. See the documentation

 
Try it
Create Page with the Notion API

Creates a page from a parent page. The only valid property is title. See the documentation

 
Try it
Create Page from Database with the Notion API

Creates a page from a database. See the docs

 
Try it
Duplicate Page with the Notion API

Creates a new page copied from an existing page block. See the docs

 
Try it
Find a Page with the Notion API

Searches for a page by its title. See the docs

 
Try it

Explore Other Apps

1
-
12
of
1,600+
apps by most popular

HTTP / Webhook
HTTP / Webhook
Get a unique URL where you can send HTTP or webhook requests
Node
Node
Anything you can do with Node.js, you can do in a Pipedream workflow. This includes using most of npm's 400,000+ packages.
Beta
Python
Python
Anything you can do in Python can be done in a Pipedream Workflow. This includes using any of the 350,000+ PyPi packages available in your Python powered workflows.
Schedule
Schedule
Trigger workflows on an interval or cron schedule.
Beta
Data Stores
Data Stores
Use Pipedream Data Stores to manage state throughout your workflows.
Telegram Bot
Telegram Bot
Telegram is a cloud-based instant messaging and voice over IP service
OpenAI (ChatGPT)
OpenAI (ChatGPT)
OpenAI is an AI research and deployment company with the mission to ensure that artificial general intelligence benefits all of humanity. They are the makers of popular models like ChatGPT, DALL-E, and Whisper.
Google Sheets
Google Sheets
With Google Sheets, you can create, edit, and collaborate wherever you are
Discord
Discord
Use this app to create a Discord source that emits messages from your guild to a Pipedream workflow.
GitHub
GitHub
Where the world builds software. Millions of developers and companies build, ship, and maintain their software on GitHub—the largest and most advanced development platform in the world.
Formatting
Formatting
Pre-built actions to make formatting and manipulating data within your workflows easier.
Slack
Slack
Slack is a channel-based messaging platform. With Slack, people can work together more effectively, connect all their software tools and services, and find the information they need to do their best work — all within a secure, enterprise-grade environment.