← Twitter Developer App

New Tweet Metrics from Twitter Developer App API

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

Trigger workflow on
New Tweet Metrics from the Twitter Developer App API
Next, do this
Connect to 500+ APIs using code and no-code building blocks
No credit card required
Trusted by 200,000+ developers from startups to Fortune 500 companies:
Trusted by 200,000+ developers from startups to Fortune 500 companies

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 + 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

Details

This is a pre-built, open source 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:
Version:0.0.2
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",
  name: "New Tweet Metrics",
  version: "0.0.2",
  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 component invocations.
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.

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

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

About Pipedream

Stop writing boilerplate code, struggling with authentication and managing infrastructure. Start connecting APIs with code-level control when you need it — and no code when you don't.

Into to Pipedream
Watch us build a workflow
Watch us build a workflow
4 min
Watch now ➜
"The past few weeks, I truly feel like the clichéd 10x engineer."
@heyellieday
Powerful features that scale
Manage concurrency and execution rate
Manage concurrency and execution rate

Queue up to 10,000 events per workfow and manage the concurrency and rate at which workflows are triggered.

Process large payloads up to 5 terabytes
Process large payloads up to 5 terabytes

Large file support enables you to trigger workflows with any data (e.g., large JSON files, images and videos) up to 5 terabytes.

Return custom responses to HTTP requests
Return custom responses to HTTP requests

Return any JSON-serializable response from an HTTP triggered workflow using $respond().

Use most npm packages
Use most npm packages

To use any npm package, just require() it -- there's no npm install or package.json required.

Maintain state between executions
Maintain state between executions

Use $checkpoint to save state in one workflow invocation and read it the next time your workflow runs.

Pass data between steps
Pass data between steps

Return data from any step to inspect it in a human-friendly way and reference the data in future steps via the steps object.