Skip to content

Latest commit

 

History

History
198 lines (153 loc) · 10.1 KB

File metadata and controls

198 lines (153 loc) · 10.1 KB

Search

Overview

Available Operations

Advanced

Perform advanced Twitter search with cursor-based pagination. Each page returns up to 20 tweets. Pass next_cursor from the previous response to continue. Pricing: $0.10 per 1,000 tweets. 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"
	"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.Search.Advanced(ctx, components.AdvancedSearchCursorQuery{
        SearchTerms: []string{
            "<value 1>",
            "<value 2>",
            "<value 3>",
        },
        SortBy: "<value>",
        NextCursor: optionalnullable.From(xapiscraper.Pointer("")),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.AdvancedSearchCursorResponse != nil {
        // handle response
    }
}

Parameters

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

Response

*operations.SearchAdvancedResponse, error

Errors

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

Cashtags

Search for tweets containing specific cashtags (stock symbols), $0.10/1000 tweets. 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"
	"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.Search.Cashtags(ctx, components.CashtagsQuery{
        Cashtags: []string{
            "AAPL",
            "TSLA",
        },
        StartTime: optionalnullable.From(xapiscraper.Pointer("1775726400")),
        EndTime: optionalnullable.From(xapiscraper.Pointer("1775727300")),
        Language: optionalnullable.From(xapiscraper.Pointer(components.CashtagsQueryLanguageEn)),
    })
    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 components.CashtagsQuery ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.SearchCashtagsResponse, error

Errors

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

Hashtags

Search for tweets containing specific hashtags. 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"
	"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.Search.Hashtags(ctx, components.HashtagsQuery{
        Hashtags: []string{
            "btc",
            "eth",
        },
        StartTime: optionalnullable.From(xapiscraper.Pointer("1775726400")),
        EndTime: optionalnullable.From(xapiscraper.Pointer("1775727300")),
        Language: optionalnullable.From(xapiscraper.Pointer(components.HashtagsQueryLanguageEn)),
    })
    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 components.HashtagsQuery ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.SearchHashtagsResponse, error

Errors

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