Documentation ¶
Overview ¶
Package tweet provides primitives for making requests to Twitter API and parsing the tweets.
Example ¶
package main import ( "github.com/rodionlim/tweet/library/tweet" ) func main() { // Quick start example - This will query twitter for keywords oil, copper ... and user @Bloomberg Markets keywords := []string{"oil", "copper", "rates", "inflation", "gold", "nickel", "powell", "fed", "bonds", "metals", "equities", "energy", "central bank", "commodities", "fx"} users := []string{"markets"} req := tweet.NewReq(tweet.WithUsers(users), tweet.WithKeywords(keywords)) req.Get() }
Output:
Index ¶
- func GetLatestSearchTerms() ([]string, error)
- func WithEndpoint(endpoint string) func(r *Req) *Req
- func WithKeywords(keywords []string) func(r *Req) *Req
- func WithMaxResults(cnt int) func(r *Req) *Req
- func WithSinceTweetID(id int64) func(r *Req) *Req
- func WithUsers(users []string) func(r *Req) *Req
- type Meta
- type Req
- type Tweets
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLatestSearchTerms ¶
GetLatestSearchTerms fetches the latest keywords stored in disk, which can be useful to inform the user what is the current search term.
func WithEndpoint ¶
WithEndpoint changes the twitter api endpoint.
func WithKeywords ¶
WithKeywords adds a filter for keywords in tweets.
func WithMaxResults ¶
WithMaxResults adds a filter for maximum results returned.
func WithSinceTweetID ¶
WithSinceTweetID adds a filter for only returning tweets greater than tweet id.
Types ¶
type Meta ¶
type Meta struct { NewestID string `json:"newest_id"` OldestID string `json:"oldest_id"` ResultCount int `json:"result_count"` NextToken string `json:"next_token"` }
Meta is the metadata from the response of a twitter get request.
type Req ¶
type Req struct {
// contains filtered or unexported fields
}
Req consists of relevant parameters to encapsulate a Twitter API GET request.
func NewReq ¶
NewReq is a struct that contains the necessary API parameters before firing the call to Twitter endpoints
func (*Req) Get ¶
Get prepares the request and fires it to Twitter API, storing the results in Req object.
func (*Req) GetLatestTweetID ¶
GetLatestTweetID fetches the latest Twitter ID stored in disk, which can be useful when trying to avoid duplicated queries.
func (*Req) SetSinceTweetID ¶
Allow setting of since tweet ID at runtime to support polling for latest results without duplicates.
func (*Req) StoreLatestSearchTerms ¶
StoreLatestSearchTerm stores the latest keywords used for querying, persistently to disk, which can be useful to inform the user what is currently being searched.
func (*Req) StoreLatestTweetID ¶
StoreLatestTweetID stores the latest Twitter ID queried, persistently to disk, which can be useful when trying to avoid duplicated queries.