3.0.0 • Published 5 years ago
@datafire/twitter_labs v3.0.0
@datafire/twitter_labs
Client library for Tweets and Users
Installation and Usage
npm install --save @datafire/twitter_labs
let twitter_labs = require('@datafire/twitter_labs').create();
.then(data => {
console.log(data);
});
Description
API Reference — Labs v2
Actions
getOpenApiSpec
Full open api spec in JSON format. (See https://github.com/OAI/OpenAPI-Specification/blob/master/README.md)
twitter_labs.getOpenApiSpec(null, context)
Input
This action has no parameters
Output
- output
string
findTweetsById
Returns a variety of information about the Tweet specified by the requested ID
twitter_labs.findTweetsById({
"ids": []
}, context)
Input
- input
object
- ids required
array
: A comma separated list of Tweet IDs. Up to 100 are allowed in a single request. - expansions
array
: A comma separated list of fields to expand. - tweet.fields
array
: A comma separated list of Tweet fields to display. - user.fields
array
: A comma separated list of User fields to display. - media.fields
array
: A comma separated list of Media fields to display. - place.fields
array
: A comma separated list of Place fields to display. - poll.fields
array
: A comma separated list of Poll fields to display.
- ids required
Output
- output TweetLookupResponse
findTweetById
Returns a variety of information about the Tweet specified by the requested ID
twitter_labs.findTweetById({
"id": ""
}, context)
Input
- input
object
- id required
string
: A single Tweet ID. - expansions
array
: A comma separated list of fields to expand. - tweet.fields
array
: A comma separated list of Tweet fields to display. - user.fields
array
: A comma separated list of User fields to display. - media.fields
array
: A comma separated list of Media fields to display. - place.fields
array
: A comma separated list of Place fields to display. - poll.fields
array
: A comma separated list of Poll fields to display.
- id required
Output
- output SingleTweetLookupResponse
findUsersById
This endpoint returns information about users. Specify users by their ID.
twitter_labs.findUsersById({
"ids": []
}, context)
Input
- input
object
- ids required
array
: Required. A list of User IDs, comma-separated. You can specify up to 100 IDs. - expansions
array
: A comma separated list of fields to expand. - tweet.fields
array
: A comma separated list of Tweet fields to display. - user.fields
array
: A comma separated list of User fields to display. - media.fields
array
: A comma separated list of Media fields to display. - place.fields
array
: A comma separated list of Place fields to display. - poll.fields
array
: A comma separated list of Poll fields to display.
- ids required
Output
- output UserLookupResponse
findUsersByUsername
This endpoint returns information about users. Specify users by their username.
twitter_labs.findUsersByUsername({
"usernames": []
}, context)
Input
- input
object
- usernames required
array
: Required . A list of usernames, comma-separated. You can specify up to 100 usernames. - expansions
array
: A comma separated list of fields to expand. - tweet.fields
array
: A comma separated list of Tweet fields to display. - user.fields
array
: A comma separated list of User fields to display. - media.fields
array
: A comma separated list of Media fields to display. - place.fields
array
: A comma separated list of Place fields to display. - poll.fields
array
: A comma separated list of Poll fields to display.
- usernames required
Output
- output UserLookupResponse
findUserByUsername
This endpoint returns information about a user. Specify user by username.
twitter_labs.findUserByUsername({
"username": ""
}, context)
Input
- input
object
- username required
string
: Required. A username. - expansions
array
: A comma separated list of fields to expand. - tweet.fields
array
: A comma separated list of Tweet fields to display. - user.fields
array
: A comma separated list of User fields to display. - media.fields
array
: A comma separated list of Media fields to display. - place.fields
array
: A comma separated list of Place fields to display. - poll.fields
array
: A comma separated list of Poll fields to display.
- username required
Output
- output SingleUserLookupResponse
findUserById
This endpoint returns information about a user. Specify user by ID.
twitter_labs.findUserById({
"id": ""
}, context)
Input
- input
object
- id required
string
: Required. A User ID. - expansions
array
: A comma separated list of fields to expand. - tweet.fields
array
: A comma separated list of Tweet fields to display. - user.fields
array
: A comma separated list of User fields to display. - media.fields
array
: A comma separated list of Media fields to display. - place.fields
array
: A comma separated list of Place fields to display. - poll.fields
array
: A comma separated list of Poll fields to display.
- id required
Output
- output SingleUserLookupResponse
Definitions
AnimatedGif
- AnimatedGif
object
- preview_image_url
string
- type
string
(values: animated_gif) - height MediaHeight
- media_key MediaKey
- width MediaWidth
- preview_image_url
CashtagEntity
- CashtagEntity
- end required
integer
: Index (zero-based) at which position this entity ends. - start required
integer
: Index (zero-based) at which position this entity starts. - tag required
string
- end required
CashtagFields
- CashtagFields
object
: Represent the portion of text recognized as a Cashtag, and its start and end position within the text.- tag required
string
- tag required
ClientForbiddenProblem
- ClientForbiddenProblem
object
: A problem that indicates your client is forbidden from making this request.- reason
string
(values: official-client-forbidden, client-not-enrolled) - registration_url
string
- type
string
(values: https://api.twitter.com/labs/2/problems/client-forbidden) - detail required
string
- title required
string
- type required
string
- reason
CommonMediaFields
- CommonMediaFields
object
: This contains the list of the fields that are common to all media returned.- height MediaHeight
- media_key MediaKey
- width MediaWidth
ContextAnnotation
- ContextAnnotation
object
: Annotation inferred from the tweet text.- domain required ContextAnnotationDomainFields
- entity required ContextAnnotationEntityFields
ContextAnnotationDomainFields
- ContextAnnotationDomainFields
object
: Represents the data for the context annotation domain.- description
string
: Description of the context annotation domain. - id required
string
: The unique id for a context annotation domain. - name
string
: Name of the context annotation domain.
- description
ContextAnnotationEntityFields
- ContextAnnotationEntityFields
object
: Represents the data for the context annotation entity.- description
string
: Description of the context annotation entity. - id required
string
: The unique id for a context annotation entity. - name
string
: Name of the context annotation entity.
- description
CountryCode
- CountryCode
string
DisallowedResourceProblem
- DisallowedResourceProblem
object
: A problem that indicates that the resource requested violates the precepts of this API.- resource_id required
string
- resource_type required
string
(values: tweet, media) - section required
string
(values: data, includes) - type
string
(values: https://api.twitter.com/labs/2/problems/disallowed-resource) - detail required
string
- title required
string
- type required
string
- resource_id required
EntityIndices
- EntityIndices
object
: Represent a boundary range (start and end index) for a recognized entity (for example a hashtag or a mention).start
must be smaller thanend
.- end required
integer
: Index (zero-based) at which position this entity ends. - start required
integer
: Index (zero-based) at which position this entity starts.
- end required
Error
- Error
object
- code required
integer
- message required
string
- code required
Expansions
- Expansions
object
FullTextEntities
- FullTextEntities
object
- cashtags
array
- items CashtagEntity
- hashtags
array
- items HashtagEntity
- mentions
array
- items MentionEntity
- urls
array
- items UrlEntity
- cashtags
GenericProblem
- GenericProblem
object
: A generic problem with no additional information beyond that provided by the HTTP status code.- status required
integer
- type
string
(values: about:blank) - detail required
string
- title required
string
- type required
string
- status required
Geo
- Geo
object
- bbox required
array
- items
number
- items
- geometry Point
- properties required
object
- type required
string
(values: Feature)
- bbox required
HTTPStatusCode
- HTTPStatusCode
integer
: HTTP Status Code.
HashtagEntity
- HashtagEntity
- end required
integer
: Index (zero-based) at which position this entity ends. - start required
integer
: Index (zero-based) at which position this entity starts. - tag required
string
: The text of the Hashtag
- end required
HashtagFields
- HashtagFields
object
: Represent the portion of text recognized as a Hashtag, and its start and end position within the text.- tag required
string
: The text of the Hashtag
- tag required
InvalidRequestProblem
- InvalidRequestProblem
object
: A problem that indicates this request is invalid.- errors
array
- items
object
- parameters
object
- message
string
- parameters
- items
- type
string
(values: https://api.twitter.com/labs/2/problems/invalid-request) - detail required
string
- title required
string
- type required
string
- errors
Media
MediaHeight
- MediaHeight
integer
: The height of the media in pixels
MediaKey
- MediaKey
string
: The Media Key identifier for this attachment.
MediaWidth
- MediaWidth
integer
: The width of the media in pixels
MentionEntity
- MentionEntity
- end required
integer
: Index (zero-based) at which position this entity ends. - start required
integer
: Index (zero-based) at which position this entity starts. - username required UserName
- end required
MentionFields
- MentionFields
object
: Represent the portion of text recognized as a User mention, and its start and end position within the text.- username required UserName
Photo
- Photo
object
- type
string
(values: photo) - url
string
- height MediaHeight
- media_key MediaKey
- width MediaWidth
- type
Place
- Place
object
- contained_within
array
- items PlaceId
- country
string
- country_code CountryCode
- full_name required
string
- geo Geo
- id required PlaceId
- name
string
: The human readable name of this place. - place_type PlaceType
- contained_within
PlaceId
- PlaceId
string
: The identifier for this place
PlaceType
- PlaceType
string
(values: poi, neighborhood, city, admin, country, unknown)
Point
- Point
object
: A GeoJson Point geometry object.- coordinates required Position
- type required
string
(values: Point)
Poll
- Poll
object
: Represent a Poll attached to a Tweet- duration_minutes
integer
- end_datetime
string
- id required PollId
- options required
array
- items PollOption
- voting_status
string
(values: open, closed)
- duration_minutes
PollId
- PollId
string
: Unique identifier of this poll.
PollOption
- PollOption
object
: Describes a choice in a Poll object.- label required
string
: The text of a poll choice. - position required
integer
: Position of this choice in the poll. - votes required
integer
: Number of users who voted for this choice.
- label required
Position
- Position
array
: A GeoJson Position in the format[longitude,latitude]
.- items
number
- items
Problem
ProblemFields
- ProblemFields
object
- detail required
string
- title required
string
- type required
string
- detail required
ResourceNotFoundProblem
- ResourceNotFoundProblem
object
: A problem that indicates that a given Tweet, User, etc. does not exist.- parameter required
string
- resource_type required
string
(values: user, tweet, media) - type
string
(values: https://api.twitter.com/labs/2/problems/resource-not-found) - detail required
string
- title required
string
- type required
string
- parameter required
ResourceUnauthorizedProblem
- ResourceUnauthorizedProblem
object
: A problem that indicates you are not allowed to see a particular Tweet, User, etc.- resource_id required
string
- resource_type required
string
(values: tweet, user, media) - section required
string
(values: data, includes) - type
string
(values: https://api.twitter.com/labs/2/problems/not-authorized-for-resource) - detail required
string
- title required
string
- type required
string
- resource_id required
SingleTweetLookupResponse
- SingleTweetLookupResponse
object
- data Tweet
- errors
array
- items Problem
- includes Expansions
SingleUserLookupResponse
- SingleUserLookupResponse
object
- data User
- errors
array
- items Problem
- includes Expansions
Tweet
- Tweet
object
- attachments
object
: Specifies the type of attachments (if any) present in this Tweet. - author_id UserID
- context_annotations
array
- items ContextAnnotation
- created_at
string
: Creation time of the Tweet. - entities FullTextEntities
- geo
object
: The location tagged on the Tweet, if the user provided one. - id required TweetID
- in_reply_to_user_id UserID
- lang
string
: Language of the Tweet, if detected by Twitter. Returned as a BCP47 language tag. - non_public_metrics
object
: Nonpublic engagement metrics for the Tweet at the time of the request.- impression_count
integer
: Number of times this Tweet has been viewed. - url_link_clicks
integer
: Number of times links in this Tweet have been clicked. - user_profile_clicks
integer
: Number of times the user's profile from this Tweet has been clicked.
- impression_count
- organic_metrics
object
: Organic nonpublic engagement metrics for the Tweet at the time of the request.- impression_count required
integer
: Number of times this Tweet has been viewed. - like_count required
integer
: Number of times this Tweet has been liked. - reply_count required
integer
: Number of times this Tweet has been replied to. - retweet_count required
integer
: Number of times this Tweet has been Retweeted. - url_link_clicks
integer
: Number of times links in this Tweet have been clicked. - user_profile_clicks required
integer
: Number of times the user's profile from this Tweet has been clicked.
- impression_count required
- possibly_sensitive
boolean
: Indicates if this Tweet contains URLs marked as sensitive, for example content suitable for mature audiences. - promoted_metrics
object
: Promoted nonpublic engagement metrics for the Tweet at the time of the request.- impression_count
integer
: Number of times this Tweet has been viewed. - like_count
integer
: Number of times this Tweet has been liked. - reply_count
integer
: Number of times this Tweet has been replied to. - retweet_count
integer
: Number of times this Tweet has been Retweeted. - url_link_clicks
integer
: Number of times links in this Tweet have been clicked. - user_profile_clicks
integer
: Number of times the user's profile from this Tweet has been clicked.
- impression_count
- public_metrics
object
: Engagement metrics for the Tweet at the time of the request.- like_count required
integer
: Number of times this Tweet has been liked. - quote_count
integer
: Number of times this Tweet has been quoted. - reply_count required
integer
: Number of times this Tweet has been replied to. - retweet_count required
integer
: Number of times this Tweet has been Retweeted.
- like_count required
- referenced_tweets
array
: A list of Tweets this Tweet refers to. For example, if the parent Tweet is a Retweet, a Quoted Tweet or a Reply, it will include the related Tweet referenced to by its parent.- items
object
- id required TweetID
- type required
string
(values: retweeted, quoted, replied_to)
- items
- source
string
: The name of the app the user Tweeted from. - text required
string
: The content of the Tweet. - withheld TweetWithheld
- attachments
TweetID
- TweetID
string
: Unique identifier of this Tweet. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
TweetLookupResponse
- TweetLookupResponse
object
- data
array
- items Tweet
- errors
array
- items Problem
- includes Expansions
- data
TweetWithheld
- TweetWithheld
object
: Indicates withholding details for withheld content.- copyright required
boolean
: Indicates if the content is being withheld for on the basis of copyright infringement. - country_codes required
array
: Provides a list of countries where this content is not available.- items CountryCode
- scope
string
(values: tweet, user): Indicates whether the content being withheld is thetweet
or auser
.
- copyright required
URL
- URL
string
: A validly formatted URL.
URLFields
- URLFields
object
: Represent the portion of text recognized as a URL.- description
string
: Description of the URL landing page. - display_url
string
: The URL as displayed in the Twitter client. - expanded_url URL
- images
array
- items URLImage
- status HTTPStatusCode
- title
string
: Title of the page the URL points to. - unwound_url
string
: Fully resolved url - url required URL
- description
URLImage
- URLImage
object
: Represent the information for the URL image- height MediaHeight
- url URL
- width MediaWidth
UnsupportedAuthenticationProblem
- UnsupportedAuthenticationProblem
object
: A problem that indicates that the authentication used is not supported.- type
string
(values: https://api.twitter.com/labs/2/problems/unsupported-authentication) - detail required
string
- title required
string
- type required
string
- type
UrlEntity
- UrlEntity: Represent the portion of text recognized as a URL, and its start and end position within the text.
- end required
integer
: Index (zero-based) at which position this entity ends. - start required
integer
: Index (zero-based) at which position this entity starts. - description
string
: Description of the URL landing page. - display_url
string
: The URL as displayed in the Twitter client. - expanded_url URL
- images
array
- items URLImage
- status HTTPStatusCode
- title
string
: Title of the page the URL points to. - unwound_url
string
: Fully resolved url - url required URL
- end required
UsageCapExceededProblem
- UsageCapExceededProblem
object
: A problem that indicates that a usage cap has been exceeded.- period
string
(values: Daily, Monthly) - scope
string
(values: Account, Product) - type
string
(values: https://api.twitter.com/labs/2/problems/usage-capped) - detail required
string
- title required
string
- type required
string
- period
User
- User
object
: The Twitter User object- created_at
string
: Creation time of this user. - description
string
: The text of this user's profile description (also known as bio), if the user provided one. - entities
object
: A list of metadata found in the user's profile description.- description FullTextEntities
- url
object
: Expanded details for the URL specified in the user's profile, with start and end indices.- urls
array
- items UrlEntity
- urls
- id required UserID
- location
string
: The location specified in the user's profile, if the user provided one. As this is a freeform value, it may not indicate a valid location, but it may be fuzzily evaluated when performing searches with location queries. - name required
string
: The friendly name of this user, as shown on their profile. - pinned_tweet_id TweetID
- profile_image_url
string
: The URL to the profile image for this user. - protected
boolean
: Indicates if this user has chosen to protect their Tweets (in other words, if this user's Tweets are private). - public_metrics
object
: A list of metrics for this user- followers_count required
integer
: Number of users who are following this user. - following_count required
integer
: Number of users this user is following. - listed_count required
integer
: The number of lists that include this user. - tweet_count required
integer
: The number of Tweets (including Retweets) posted by this user.
- followers_count required
- url
string
: The URL specified in the user's profile. - username required UserName
- verified
boolean
: Indicate if this user is a verified Twitter User. - withheld UserWithheld
- created_at
UserID
- UserID
string
: Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
UserLookupResponse
- UserLookupResponse
object
- data
array
- items User
- errors
array
- items Problem
- includes Expansions
- data
UserName
- UserName
string
: The Twitter handle (screen name) of this user.
UserWithheld
- UserWithheld
object
: Indicates withholding details for withheld content.- country_codes required
array
: Provides a list of countries where this content is not available.- items CountryCode
- scope
string
(values: user): Indicates that the content being withheld is auser
.
- country_codes required
Video
- Video
object
- duration_ms
integer
- non_public_metrics
object
: Nonpublic engagement metrics for the Media at the time of the request.- playback_0_count
integer
: Number of users who made it through 0% of the video. - playback_100_count
integer
: Number of users who made it through 100% of the video. - playback_25_count
integer
: Number of users who made it through 25% of the video. - playback_50_count
integer
: Number of users who made it through 50% of the video. - playback_75_count
integer
: Number of users who made it through 75% of the video.
- playback_0_count
- organic_metrics
object
: Organic nonpublic engagement metrics for the Media at the time of the request.- playback_0_count
integer
: Number of users who made it through 0% of the video. - playback_100_count
integer
: Number of users who made it through 100% of the video. - playback_25_count
integer
: Number of users who made it through 25% of the video. - playback_50_count
integer
: Number of users who made it through 50% of the video. - playback_75_count
integer
: Number of users who made it through 75% of the video. - view_count
integer
: Number of times this video has been viewed.
- playback_0_count
- preview_image_url
string
- promoted_metrics
object
: Promoted nonpublic engagement metrics for the Media at the time of the request.- playback_0_count
integer
: Number of users who made it through 0% of the video. - playback_100_count
integer
: Number of users who made it through 100% of the video. - playback_25_count
integer
: Number of users who made it through 25% of the video. - playback_50_count
integer
: Number of users who made it through 50% of the video. - playback_75_count
integer
: Number of users who made it through 75% of the video. - view_count
integer
: Number of times this video has been viewed.
- playback_0_count
- public_metrics
object
: Engagement metrics for the Media at the time of the request.- view_count
integer
: Number of times this video has been viewed.
- view_count
- type
string
(values: video) - height MediaHeight
- media_key MediaKey
- width MediaWidth
- duration_ms
3.0.0
5 years ago