Skip to content

Latest commit

 

History

History
232 lines (173 loc) · 10.9 KB

File metadata and controls

232 lines (173 loc) · 10.9 KB

Tweets

Overview

Available Operations

Detail

Retrieve detailed information for one or more tweets by ID (no cookie required). The maximum input quantity is limited by your plan's QPS. To pass larger input quantity limits, upgrade your plan to get higher QPS.

Example Usage

package main

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

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

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

    res, err := s.Tweets.Detail(ctx, []string{
        "2076874251915743687",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Any != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.TweetsDetailResponse, error

Errors

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

Thread

Retrieve all tweets in a thread by tweet ID, sorted by latest.

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.Thread(ctx, components.TweetThreadByIDBody{
        TweetID: "<id>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Any != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.TweetsThreadResponse, error

Errors

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

Lookup

Retrieve detailed information for multiple Tweets by their IDs. The maximum input quantity is limited by your plan's QPS. To pass larger input quantity limits, upgrade your plan to get higher QPS.

Example Usage

package main

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

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

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

    res, err := s.Tweets.Lookup(ctx, []string{
        "1803006263529541838",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.GetTweetsByIDResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.TweetsLookupResponse, error

Errors

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

Similar

Get similar 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/operations"
	"log"
)

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

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

    res, err := s.Tweets.Similar(ctx, operations.TweetsSimilarRequest{
        TweetID: "<id>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.GetTweetsByIDResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.TweetsSimilarResponse, error

Errors

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