Overview
The X Recommendation Algorithm uses Apache Thrift for service definitions and data serialization. This page documents the key Thrift types used across multiple services.Common Types
ClientContext
Client context containing caller identification and device information. Used across all services.User ID for authenticated users (personalDataType=‘UserId’)
Guest ID for logged-out users (personalDataType=‘GuestId’)
Application identifier (personalDataType=‘AppId’)
Client IP address (personalDataType=‘IpAddress’)
Client user agent string (personalDataType=‘UserAgent’)
Inferred country code (personalDataType=‘InferredCountry’)
Inferred language code (personalDataType=‘InferredLanguage’)
Device identifier (personalDataType=‘DeviceId’)
CR Mixer Types
Product
Enum identifying which product surface is making the request.TweetRecommendation
A single tweet recommendation with score and metadata.Tweet identifier (personalDataType=‘TweetId’)
Recommendation score - higher values indicate stronger recommendations
Tags for metrics tracking and attribution
Tweet author’s user ID (personalDataType=‘UserId’)
Information about which algorithm generated this candidate
Latest timestamp of engagement signals used (null if not from engagement signals)
RelatedTweet
A tweet related to a query tweet or author.UtegTweet
Tweet recommendation from User Tweet Entity Graph with social proof.Tweet identifier
Sum of weights of seed users who engaged with the tweet. If a user engaged multiple times (e.g., liked and retweeted), their weight is counted for each engagement type.
Map from engagement type to list of user IDs who engaged in that way. Key is engagement type (like, retweet, reply), value is list of user IDs.
TopicTweet
Tweet recommendation for a specific topic.Algorithm used to generate this recommendation (SimClustersANN, TwHINANN, UTEG, etc.)
Follow Recommendations Types
DisplayLocation
Enum specifying where recommendations will be displayed.- HOME_TIMELINE (39) - WTF module in Home timeline
- NUX_PYMK (67) - New user “People You May Know”
- HOME_TIMELINE_TWEET_RECS (83) - FutureGraph tweet author recommendations
- MagicRecs (59) - Account recommendations in notifications
UserRecommendation
A recommended user account.Recommended user’s ID (personalDataType=‘UserId’)
Reason for the recommendation (social context, e.g., “Followed by X”)
Present if this is a promoted account; used for ad impression tracking
Opaque tracking token for attribution
Information about the candidate’s score and ranking
Identifier for which recommendation flow generated this candidate
Source Signals
SourceType
Enum identifying the type of user signal used for candidate generation.SimilarityEngineType
Enum identifying which similarity/recommendation algorithm was used.- SimClustersANN - Community-based clustering and similarity
- TweetBasedTwHINANN - Heterogeneous graph neural network
- UTEG - User Tweet Entity Graph engagement-based
- TwhinCollabFilter - Collaborative filtering with TwHIN embeddings
- Earlybird* - Real-time search index-based
Error Types
ValidationExceptionList
List of validation errors with details reported to clients.ServerError
Generic server error. Details are not reported to clients for security.Data Annotations
Thrift definitions include personal data annotations for privacy compliance:personalDataType='UserId'- Twitter user identifierpersonalDataType='TweetId'- Tweet identifierpersonalDataType='IpAddress'- IP addresspersonalDataType='DeviceId'- Device identifierhasPersonalData='true'- Struct contains personal datapersisted='true'- Data may be persisted to storage
Related Documentation
- CR Mixer API - CR Mixer service endpoints
- Follow Recommendations Service API - FRS service endpoints
- Data Record Formats - ML data format
Source Files
Thrift definitions can be found in the source repository:cr-mixer/thrift/src/main/thrift/- CR Mixer definitionsfollow-recommendations-service/thrift/src/main/thrift/- FRS definitionssrc/thrift/com/twitter/- Shared common definitions