Skip to content

Latest commit

 

History

History
282 lines (209 loc) · 13.5 KB

File metadata and controls

282 lines (209 loc) · 13.5 KB

Trending

Overview

Available Operations

Countries

Get the supported country and global options that can be used to filter trending tweets.

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.Trending.Countries(ctx)
    if err != nil {
        log.Fatal(err)
    }
    if res.StandardResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.TrendingCountriesResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

Topics

Get the topic categories available for filtering global trending tweets.

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.Trending.Topics(ctx)
    if err != nil {
        log.Fatal(err)
    }
    if res.StandardResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.TrendingTopicsResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

Contents

Get content tags for a selected country and topic so tweets can be filtered more precisely.

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.Trending.Contents(ctx, operations.TrendingContentsRequest{
        Country: "Monaco",
        Topic: "<value>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.StandardResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.TrendingContentsResponse, error

Errors

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

Tweets

Get trending tweets for a country, with optional topic and content tag filters.

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.Trending.Tweets(ctx, operations.TrendingTweetsRequest{
        Country: "Lithuania",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.SearchResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.TrendingTweetsResponse, error

Errors

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

ByCountry

Get X Explore trending topics for a given country. Use 'worldwide' for account-default trends or a country slug such as 'united-states'.

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.Trending.ByCountry(ctx, operations.TrendingByCountryRequest{
        Country: operations.CountryWorldwide,
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.StandardResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.TrendingByCountryResponse, error

Errors

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