> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graphext.com/llms.txt
> Use this file to discover all available pages before exploring further.

# fetch_twitter

> Enriches a dataset containing tweets with information about their authors. 

In addition to author information also adds the location the tweet was send from (if available),
and indicates whether a tweet was retweeted or favourited at least once. See below for a
detailed list of the enrichment columns.

???+ info "API integration"
To use this step you will need to create an app associated to your Twitter account,
and obtain four items: the consumer\_key, the consumer\_secret, the token and the token\_secret.

To do so you can follow the steps [here](https://help.graphext.com/en/articles/3973608-how-to-obtain-twitter-api-keys-for-twitter-enrichment),
and then add them to a Graphext integration.

## Usage

The following example shows how the step can be used in a recipe.

<Accordion title="Examples" icon="code" defaultOpen="true">
  <Tabs>
    <Tab title="Example 1">
      This step doesn't have any configuration parameters. Hence simply:

      ```stan theme={null}
      fetch_twitter(ds.id) -> (
        ds.user_created_at,
        ds.user_description,
        ds.user_favourites_count,
        ds.user_followers_count,
        ds.user_following_count,
        ds.user_listed_count,
        ds.user_profile_image_url_https,
        ds.user_protected,
        ds.user_tweets_count,
        ds.user_profile_url,
        ds.user_verified,
        ds.user_location,
        ds.lat,
        ds.long,
        ds.retweeted,
        ds.favorited,
        ds.source
      )
      ```
    </Tab>

    <Tab title="Signature">
      General syntax for using the step in a recipe. Shows the inputs and outputs the step is expected to receive and will produce respectively. For futher details see sections below.

      ```stan theme={null}
      fetch_twitter(tweet_ids: category|number, {
          "param": value,
          ...
      }) -> (
      	user_created_at: date,
      	user_description: text,
      	user_favourites_count: number,
      	user_followers_count: number,
      	user_following_count: number,
      	user_listed_count: number,
      	user_profile_image_url_https: url,
      	user_protected: boolean,
      	user_tweets_count: number,
      	user_profile_url: url,
      	user_verified: boolean,
      	user_location: category,
      	lat: number,
      	long: number,
      	retweeted: boolean,
      	favorited: boolean,
      	source: category
      )
      ```
    </Tab>
  </Tabs>
</Accordion>

## Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally
columns (`ds.first_name`), datasets (`ds` or `ds[["first_name", "last_name"]]`) or models (referenced
by name e.g. `"churn-clf"`).

<Accordion title="Inputs" icon="right-to-bracket">
  <ParamField path="tweet_ids" type="column[category|number]" required>
    Twitter's unique identifier for each tweet.
  </ParamField>
</Accordion>

<Accordion title="Outputs" icon="right-from-bracket">
  <ParamField path="user_created_at" type="column[date]" required>
    Time the user who tweeted this tweet was created.
  </ParamField>

  <ParamField path="user_description" type="column[text]" required>
    Self-description of the user.
  </ParamField>

  <ParamField path="user_favourites_count" type="column[number]" required>
    How many tweets the user has favorited.
  </ParamField>

  <ParamField path="user_followers_count" type="column[number]" required>
    How many followers the user has.
  </ParamField>

  <ParamField path="user_following_count" type="column[number]" required>
    How many users the user is following.
  </ParamField>

  <ParamField path="user_listed_count" type="column[number]" required>
    How many times the user has been listed in public listings.
  </ParamField>

  <ParamField path="user_profile_image_url_https" type="column[url]" required>
    User's picture.
  </ParamField>

  <ParamField path="user_protected" type="column[boolean]" required>
    Whether this user has protected their tweets or not.
  </ParamField>

  <ParamField path="user_tweets_count" type="column[number]" required>
    How many times this user has tweeted.
  </ParamField>

  <ParamField path="user_profile_url" type="column[url]" required>
    User's profile url.
  </ParamField>

  <ParamField path="user_verified" type="column[boolean]" required>
    Whether this user is verified or not.
  </ParamField>

  <ParamField path="user_location" type="column[category]" required>
    Location extracted from the author profile.
  </ParamField>

  <ParamField path="lat" type="column[number]" required>
    Latitude this tweet was tweeted from.
  </ParamField>

  <ParamField path="long" type="column[number]" required>
    Longitude this tweet was tweeted from.
  </ParamField>

  <ParamField path="retweeted" type="column[boolean]" required>
    Whether you have retweeted this tweet.
  </ParamField>

  <ParamField path="favorited" type="column[boolean]" required>
    Whether you have favorited this tweet.
  </ParamField>

  <ParamField path="source" type="column[category]" required>
    Where this tweet was tweeted from as a HTML string.
  </ParamField>
</Accordion>

## Configuration

The following parameters can be used to configure the behaviour of the step by including them in
a json object as the last "input" to the step, i.e. `step(..., {"param": "value", ...}) -> (output)`.

<Accordion title="Parameters" defaultOpen="true" icon="sliders">
  <ParamField path="integration" type="string" required>
    ID of the integration you'd like to use.
  </ParamField>
</Accordion>
