← Twitter Developer App

New Tweet Metrics from Twitter Developer App API

Pipedream makes it easy to connect APIs for Twitter Developer App and 1000+ other apps remarkably fast.

Trigger workflow on
New Tweet Metrics from the Twitter Developer App API
Next, do this
Connect to 1000+ APIs using code and no-code building blocks
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜

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

Adyen logo
Brex logo
Carta logo
Checkr logo
Chameleon logo
DevRev logo
LinkedIn logo
Netflix logo
New Relic logo
OnDeck logo
Replicated logo
Scale AI logo
Teamwork logo
Warner Bros. logo
Xendit logo

Developers Pipedream

Getting Started

Trigger a workflow on New Tweet Metrics with Twitter Developer App API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the New Tweet Metrics trigger
    1. Connect your Twitter Developer App account
    2. Configure timer
    3. Configure Tweet IDs
    4. Configure Only Changed Metrics?
    5. Configure Exclude Public Metrics
    6. Configure Exclude Non-Public Metrics
    7. Configure Exclude Organic Metrics
  2. Add steps to connect to 1000+ 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 New Tweet Metrics from Twitter Developer App API
Twitter Developer App + Discord Webhook
 
Try it
Add Multiple Rows with Google Sheets API on New Tweet Metrics from Twitter Developer App API
Twitter Developer App + Google Sheets
 
Try it
Get Film with SWAPI API on New Tweet Metrics from Twitter Developer App API
Twitter Developer App + SWAPI - Star Wars
 
Try it
Create Multiple Records with Airtable API on New Tweet Metrics from Twitter Developer App API
Twitter Developer App + Airtable
 
Try it
Custom Request with HTTP / Webhook API on New Tweet Metrics from Twitter Developer App API
Twitter Developer App + 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.

New Tweet Metrics on Twitter Developer App
Description:Emit new event on each new twitter metric
Version:0.0.3
Key:twitter_developer_app-new-tweet-metrics

Code

const isEqual = require("lodash/isEqual");
const common = require("../common");

module.exports = {
  ...common,
  key: "twitter_developer_app-new-tweet-metrics",
  description: "Emit new event on each new twitter metric",
  type: "source",
  name: "New Tweet Metrics",
  version: "0.0.3",
  dedupe: "unique",
  props: {
    ...common.props,
    tweetIds: {
      type: "string[]",
      label: "Tweet IDs",
      description: "The IDs of the Tweets for which to retrieve metrics",
    },
    onlyChangedMetrics: {
      type: "boolean",
      label: "Only Changed Metrics?",
      description: `
        When enabled, this event source will only emit events if the values of the
        retrieved metrics changed
      `,
      default: false,
    },
    excludePublic: {
      type: "boolean",
      label: "Exclude Public Metrics",
      description: "Exclude public metrics from the emitted events",
      default: false,
    },
    excludeNonPublic: {
      type: "boolean",
      label: "Exclude Non-Public Metrics",
      description: "Exclude non-public metrics from the emitted events",
      default: false,
    },
    excludeOrganic: {
      type: "boolean",
      label: "Exclude Organic Metrics",
      description: "Exclude organic metrics from the emitted events",
      default: false,
    },
  },
  hooks: {
    deactivate() {
      this._setLastMetrics(null);
    },
  },
  methods: {
    ...common.methods,
    _getLastMetrics() {
      return this.db.get("lastmetrics");
    },
    _setLastMetrics(metrics) {
      this.db.set("lastmetrics", metrics);
    },
    _shouldSkipExecution(metrics) {
      return (
        this.onlyChangedMetrics &&
        isEqual(this._getLastMetrics(), metrics)
      );
    },
    generateMeta({
      event,
      metrics,
    }) {
      const { id: tweetId } = metrics;
      const { timestamp: ts } = event;
      const id = `${tweetId}-${ts}`;
      const summary = "New metrics";
      return {
        id,
        summary,
        ts,
      };
    },
  },
  async run(event) {
    const metrics = await this.twitter_developer_app.getMetricsForIds({
      tweetIds: this.tweetIds,
      excludePublic: this.excludePublic,
      excludeNonPublic: this.excludeNonPublic,
      excludeOrganic: this.excludeOrganic,
    });

    if (this._shouldSkipExecution(metrics)) {
      console.log("No new metrics found. Skipping...");
      return;
    }

    const meta = this.generateMeta({
      event,
      metrics,
    });
    this.$emit(metrics, meta);

    this._setLastMetrics(metrics);
  },
};

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
Twitter Developer Apptwitter_developer_appappThis component uses the Twitter Developer App app.
N/Adb$.service.dbThis component uses $.service.db to maintain state between executions.
timer$.interface.timer
Tweet IDstweetIdsstring[]

The IDs of the Tweets for which to retrieve metrics

Only Changed Metrics?onlyChangedMetricsboolean
    When enabled, this event source will only emit events if the values of the
    retrieved metrics changed
  
Exclude Public MetricsexcludePublicboolean

Exclude public metrics from the emitted events

Exclude Non-Public MetricsexcludeNonPublicboolean

Exclude non-public metrics from the emitted events

Exclude Organic MetricsexcludeOrganicboolean

Exclude organic metrics from the emitted events

Authentication

Twitter Developer App uses API keys for authentication. When you connect your Twitter Developer App account, Pipedream securely stores the keys so you can easily authenticate to Twitter Developer App APIs in both code and no-code steps.

Video Tutorial on how to create and connect a Twitter Developer App to Pipedream

First, you'll need to sign up for a Twitter developer account and create a new application in the Twitter app dashboard.

  1. Register a new app on https://developers.twitter.com
  2. Apply for a new Twitter app, be detailed about your use
  3. After approval, create a new Standalone App
  4. Copy the api_key and api_secret_key into a Twitter Developer App Account on Pipedream
  5. Generate a new set of keys for your specific Twitter account
  6. Paste the access_token and access_token_secret in the Twitter Developer App Account on Pipedream

Once you've created an app, visit the Keys and tokens section of the app's settings, and add the API key, API secret key, Access token, and Access token secret below.

About Twitter Developer App

Use a Twitter developer app you've created to send API requests

More Ways to Use Twitter Developer App

Triggers

New Tweet Metrics from the Twitter Developer App API
 
Try it
New Message from the Twitter Developer App API

Emit new event each time the authenticated user receives a Direct Message

 
Try it
New Message from the Twitter Developer App API

Emit an event each time the authenticated user receives a Direct Message

 
Try it

Actions

Send Direct Message (DM) with the Twitter Developer App API

Send a DM to a user.

 
Try it