-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
api.go
25 lines (20 loc) · 823 Bytes
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package volumestream
import (
"context"
"github.com/michimani/gotwi"
"github.com/michimani/gotwi/tweet/volumestream/types"
)
const (
sampleStreamEndpoint = "https://api.twitter.com/2/tweets/sample/stream"
)
// Streams about 1% of all Tweets in real-time.
// If you have Academic Research access, you can connect up to two redundant connections to maximize your streaming up-time.
// https://developer.twitter.com/en/docs/twitter-api/tweets/volume-streams/api-reference/get-tweets-sample-stream
func SampleStream(ctx context.Context, c *gotwi.Client, p *types.SampleStreamInput) (*gotwi.StreamClient[*types.SampleStreamOutput], error) {
tc := gotwi.NewTypedClient[*types.SampleStreamOutput](c)
s, err := tc.CallStreamAPI(ctx, sampleStreamEndpoint, "GET", p)
if err != nil {
return nil, err
}
return s, nil
}