Mirra
Integrations

Twitter

SDK reference for twitter operations

Overview

Twitter (X) posting and social media management

  • Category: social
  • Auth Required: Yes
  • Supported Modes: standard, delegated

Operations

postTweet

Post a tweet

Arguments:

  • text (string, required): Tweet text (max 280 characters)

Returns:

AdapterOperationResult - Returns { tweetId: string, text: string } in result.data

Response Fields:

FieldTypeDescription
tweetIdstringID of the posted tweet
textstringText content of the posted tweet

Example:

const result = await mirra.twitter.postTweet({
  text: "example"
});

getUserTweets

Retrieve tweets from a Twitter user. Must provide either userId OR userName (not both). NOTE: This operation ONLY accepts the 4 parameters listed below. There is NO maxResults, limit, count, or similar parameters - the API returns ~20 tweets per page, use cursor for pagination.

Arguments:

  • userId (string, optional): Twitter user ID (recommended for stability and speed). Provide userId OR userName, not both.
  • userName (string, optional): Twitter username/handle without @ symbol (e.g., "elonmusk"). Provide userName OR userId, not both.
  • cursor (string, optional): Pagination cursor from previous response's nextCursor field. Do not fabricate cursor values.
  • includeReplies (boolean, optional): Whether to include replies in results. Defaults to false (only original tweets).

Returns:

AdapterOperationResult - Returns normalized flat structure: { tweets: NormalizedTweet[], hasNextPage, nextCursor, totalRetrieved }. Each tweet has FLAT fields (no nested author object): id, text, url, createdAt, lang, likeCount, retweetCount, replyCount, quoteCount, viewCount, bookmarkCount, isReply, isRetweet, source, authorId, authorName, authorUserName, authorFollowers, authorFollowing, authorIsVerified, authorVerifiedType, authorCreatedAt.

Response Fields:

FieldTypeDescription
tweetsTwitterNormalizedTweet[]List of normalized tweets
tweets item fields (TwitterNormalizedTweet)
FieldTypeDescription
idstringTweet ID
textstringTweet text content
urlstringDirect URL to the tweet
createdAtstringTweet creation time (ISO 8601)
langstringTweet language code (optional)
likeCountnumberNumber of likes
retweetCountnumberNumber of retweets
replyCountnumberNumber of replies
quoteCountnumberNumber of quote tweets
viewCountnumberNumber of views
bookmarkCountnumberNumber of bookmarks
isReplybooleanWhether this is a reply to another tweet
isRetweetbooleanWhether this is a retweet
sourcestringSource application of the tweet (optional)
authorIdstringAuthor user ID
authorNamestringAuthor display name
authorUserNamestringAuthor username/handle
authorFollowersnumberAuthor follower count
authorFollowingnumberAuthor following count
authorIsVerifiedbooleanWhether the author is verified
authorVerifiedTypestringType of verification (blue, business, government) (optional)
authorCreatedAtstringAuthor account creation date (optional)

| hasNextPage | boolean | Whether more tweets are available | | nextCursor | string | Cursor for fetching the next page | | totalRetrieved | number | Number of tweets retrieved in this response |

Example:

const result = await mirra.twitter.getUserTweets({});

advancedSearch

Search tweets using advanced Twitter search syntax. Supports operators like from:username, since:date, until:date, lang:en, and boolean operators (AND, OR). NOTE: This operation ONLY accepts the 3 parameters listed below (query, queryType, cursor). There is NO minFollowers, maxResults, limit, or other filtering parameters - filter results client-side after fetching.

Arguments:

  • query (string, required): Search query with advanced syntax. Examples: "from:elonmusk", "bitcoin since:2024-01-01", "AI OR "machine learning"". Supported operators: from:user, to:user, since:YYYY-MM-DD, until:YYYY-MM-DD, lang:xx, filter:media, filter:links, -filter:retweets, AND, OR, -keyword, "exact phrase".
  • queryType (string, optional): Type of search results: "Latest" (most recent) or "Top" (most relevant). Defaults to "Latest". Only these two values are valid.
  • cursor (string, optional): Pagination cursor from previous response's nextCursor field. Do not fabricate cursor values.

Returns:

AdapterOperationResult - Returns normalized flat structure: { query, queryType, tweets: NormalizedTweet[], hasNextPage, nextCursor, totalRetrieved }. Each tweet has FLAT fields (no nested author object): id, text, url, createdAt, lang, likeCount, retweetCount, replyCount, quoteCount, viewCount, bookmarkCount, isReply, isRetweet, source, authorId, authorName, authorUserName, authorFollowers, authorFollowing, authorIsVerified, authorVerifiedType, authorCreatedAt. To filter by follower count, check tweet.authorFollowers >= threshold.

Response Fields:

FieldTypeDescription
querystringSearch query used
queryTypestringType of search: Latest or Top
tweetsTwitterNormalizedTweet[]List of matching tweets
tweets item fields (TwitterNormalizedTweet)
FieldTypeDescription
idstringTweet ID
textstringTweet text content
urlstringDirect URL to the tweet
createdAtstringTweet creation time (ISO 8601)
langstringTweet language code (optional)
likeCountnumberNumber of likes
retweetCountnumberNumber of retweets
replyCountnumberNumber of replies
quoteCountnumberNumber of quote tweets
viewCountnumberNumber of views
bookmarkCountnumberNumber of bookmarks
isReplybooleanWhether this is a reply to another tweet
isRetweetbooleanWhether this is a retweet
sourcestringSource application of the tweet (optional)
authorIdstringAuthor user ID
authorNamestringAuthor display name
authorUserNamestringAuthor username/handle
authorFollowersnumberAuthor follower count
authorFollowingnumberAuthor following count
authorIsVerifiedbooleanWhether the author is verified
authorVerifiedTypestringType of verification (blue, business, government) (optional)
authorCreatedAtstringAuthor account creation date (optional)

| hasNextPage | boolean | Whether more results are available | | nextCursor | string | Cursor for fetching the next page | | totalRetrieved | number | Number of tweets retrieved in this response |

Example:

const result = await mirra.twitter.advancedSearch({
  query: "example"
});

On this page