Documentation
¶
Overview ¶
Package twitter provides tools for Twitter/X via the v2 API.
Authentication: Bearer token (read-only) or OAuth 1.0a (read+write). Required env vars:
TWITTER_BEARER_TOKEN — for search and read (required) TWITTER_API_KEY — for posting (OAuth 1.0a) TWITTER_API_SECRET — for posting TWITTER_ACCESS_TOKEN — for posting TWITTER_ACCESS_SECRET — for posting
NOTE: Twitter API v2 free tier (2025) is severely limited:
- Read: 500k tweets/month, only recent search (last 7 days)
- Write: 500 posts/month
- Basic tier ($100/month) unlocks more
Tools planned (see GitHub issue):
twitter_search — search recent tweets (last 7 days) twitter_timeline — fetch a user's recent timeline twitter_tweet — post a tweet (requires OAuth 1.0a) twitter_thread — post a thread of connected tweets
Index ¶
- Constants
- Variables
- type SearchTool
- func (t *SearchTool) BackfillInput(_ context.Context, input map[string]any) map[string]any
- func (t *SearchTool) Call(_ context.Context, _ tool.CallInput, _ types.CanUseToolFn) (tool.CallResult, error)
- func (t *SearchTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult
- func (t *SearchTool) Definition() tool.Definition
- func (t *SearchTool) Description(_ context.Context) (string, error)
- func (t *SearchTool) FormatResult(data any) string
- func (t *SearchTool) IsConcurrencySafe(_ map[string]any) bool
- func (t *SearchTool) IsEnabled() bool
- func (t *SearchTool) IsReadOnly(_ map[string]any) bool
- func (t *SearchTool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)
- type TweetTool
- func (t *TweetTool) BackfillInput(_ context.Context, input map[string]any) map[string]any
- func (t *TweetTool) Call(_ context.Context, _ tool.CallInput, _ types.CanUseToolFn) (tool.CallResult, error)
- func (t *TweetTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult
- func (t *TweetTool) Definition() tool.Definition
- func (t *TweetTool) Description(_ context.Context) (string, error)
- func (t *TweetTool) FormatResult(data any) string
- func (t *TweetTool) IsConcurrencySafe(_ map[string]any) bool
- func (t *TweetTool) IsEnabled() bool
- func (t *TweetTool) IsReadOnly(_ map[string]any) bool
- func (t *TweetTool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)
Constants ¶
View Source
const ( SearchToolName = "twitter_search" SearchDisplayName = "Search Twitter/X" SearchDescription = `` /* 352-byte string literal not displayed */ )
View Source
const ( TweetToolName = "twitter_tweet" TweetDisplayName = "Post Tweet" TweetDescription = `` /* 311-byte string literal not displayed */ )
Variables ¶
View Source
var ErrNotImplemented = errors.New("twitter tools: not implemented — see GitHub issue")
ErrNotImplemented is returned by all Twitter tools until the API client is complete (see GitHub issue). The API cost model should be considered before implementing — basic tier required for serious usage.
Functions ¶
This section is empty.
Types ¶
type SearchTool ¶
type SearchTool struct{}
func NewSearchTool ¶
func NewSearchTool() *SearchTool
func (*SearchTool) BackfillInput ¶
func (*SearchTool) Call ¶
func (t *SearchTool) Call(_ context.Context, _ tool.CallInput, _ types.CanUseToolFn) (tool.CallResult, error)
func (*SearchTool) CheckPermissions ¶
func (t *SearchTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult
func (*SearchTool) Definition ¶
func (t *SearchTool) Definition() tool.Definition
func (*SearchTool) Description ¶
func (t *SearchTool) Description(_ context.Context) (string, error)
func (*SearchTool) FormatResult ¶
func (t *SearchTool) FormatResult(data any) string
func (*SearchTool) IsConcurrencySafe ¶
func (t *SearchTool) IsConcurrencySafe(_ map[string]any) bool
func (*SearchTool) IsEnabled ¶
func (t *SearchTool) IsEnabled() bool
func (*SearchTool) IsReadOnly ¶
func (t *SearchTool) IsReadOnly(_ map[string]any) bool
func (*SearchTool) ValidateInput ¶
type TweetTool ¶
type TweetTool struct{}
func NewTweetTool ¶
func NewTweetTool() *TweetTool
func (*TweetTool) BackfillInput ¶
func (*TweetTool) Call ¶
func (t *TweetTool) Call(_ context.Context, _ tool.CallInput, _ types.CanUseToolFn) (tool.CallResult, error)
func (*TweetTool) CheckPermissions ¶
func (t *TweetTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult
func (*TweetTool) Definition ¶
func (t *TweetTool) Definition() tool.Definition
func (*TweetTool) FormatResult ¶
Click to show internal directories.
Click to hide internal directories.