Skip to content

Latest commit

 

History

History
240 lines (181 loc) · 13.6 KB

File metadata and controls

240 lines (181 loc) · 13.6 KB

Tweets.Engagement

Overview

Available Operations

Retweeters

Retrieve retweeters in a single request. Automatically paginates until count is reached or no more results. Minimum 10, maximum 5000 users.

Example Usage

package main

import(
	"context"
	"os"
	xapiscraper "github.com/twexapi-dev/x-api-scraper-go"
	"github.com/twexapi-dev/x-api-scraper-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()

    s := xapiscraper.New(
        xapiscraper.WithSecurity(os.Getenv("X_API_SCRAPER_BEARER_AUTH")),
    )

    res, err := s.Tweets.Engagement.Retweeters(ctx, operations.TweetsEngagementRetweetersRequest{
        TweetID: "<id>",
        TargetCount: 100,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.SearchUserResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.TweetsEngagementRetweetersRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.TweetsEngagementRetweetersResponse, error

Errors

Error Type Status Code Content Type
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

RetweetersPage

Retrieve retweeters using cursor-based pagination. Each page returns up to 20 users. Pass next_cursor from the previous response to continue.

Example Usage

package main

import(
	"context"
	"os"
	xapiscraper "github.com/twexapi-dev/x-api-scraper-go"
	"github.com/twexapi-dev/x-api-scraper-go/optionalnullable"
	"github.com/twexapi-dev/x-api-scraper-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := xapiscraper.New(
        xapiscraper.WithSecurity(os.Getenv("X_API_SCRAPER_BEARER_AUTH")),
    )

    res, err := s.Tweets.Engagement.RetweetersPage(ctx, components.GetRetweetersCursorQuery{
        TweetID: "<id>",
        NextCursor: optionalnullable.From(xapiscraper.Pointer("eyJpZCI6IjIwNjAwNTE1Mzg3OTQ0Mzg2NzciLCJmbG9ja0N1cnNvciI6IjQ2MTE2ODYwMTg2Mjg5ODcxNzkiLCJvcmlnaW5hbERpcmVjdGlvbiI6IkRlc2NlbmRpbmcifQ==-999995")),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.GetRetweetersCursorResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.GetRetweetersCursorQuery ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.TweetsEngagementRetweetersPageResponse, error

Errors

Error Type Status Code Content Type
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Quotes

Retrieve quote tweets in a single request. Automatically paginates until count is reached or no more results. Use Latest for chronological order or Top for ranked results. Minimum 10, maximum 5000 tweets.

Example Usage

package main

import(
	"context"
	"os"
	xapiscraper "github.com/twexapi-dev/x-api-scraper-go"
	"github.com/twexapi-dev/x-api-scraper-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := xapiscraper.New(
        xapiscraper.WithSecurity(os.Getenv("X_API_SCRAPER_BEARER_AUTH")),
    )

    res, err := s.Tweets.Engagement.Quotes(ctx, components.GetQuotesQuery{
        TweetID: "<id>",
        Count: 100,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.GetQuotesResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.GetQuotesQuery ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.TweetsEngagementQuotesResponse, error

Errors

Error Type Status Code Content Type
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

QuotesPage

Retrieve quote tweets using cursor-based pagination. Each page returns up to 20 tweets. Use Latest for chronological order or Top for ranked results. Pass next_cursor from the previous response to continue.

Example Usage

package main

import(
	"context"
	"os"
	xapiscraper "github.com/twexapi-dev/x-api-scraper-go"
	"github.com/twexapi-dev/x-api-scraper-go/optionalnullable"
	"github.com/twexapi-dev/x-api-scraper-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := xapiscraper.New(
        xapiscraper.WithSecurity(os.Getenv("X_API_SCRAPER_BEARER_AUTH")),
    )

    res, err := s.Tweets.Engagement.QuotesPage(ctx, components.GetQuotesCursorQuery{
        TweetID: "<id>",
        NextCursor: optionalnullable.From(xapiscraper.Pointer("scroll:thGQYTMwMjU5NDA4ODc4ODc6MjU5NDA4ODc4ODc6")),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.GetQuotesCursorResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.GetQuotesCursorQuery ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.TweetsEngagementQuotesPageResponse, error

Errors

Error Type Status Code Content Type
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*