Skip to content

Latest commit

 

History

History
243 lines (172 loc) · 12.1 KB

File metadata and controls

243 lines (172 loc) · 12.1 KB

Timelines

Overview

Available Operations

tweetsAndReplies

Get all tweets and replies posted by a specific Twitter user. Returns a comprehensive list including both original tweets and reply tweets posted by the user. $0.10/1000 items.

Example Usage

package hello.world;

import io.twexapi.sdk.XapiScraper;
import io.twexapi.sdk.models.errors.HTTPValidationError;
import io.twexapi.sdk.models.operations.TimelinesTweetsAndRepliesRequest;
import io.twexapi.sdk.models.operations.TimelinesTweetsAndRepliesResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws HTTPValidationError, Exception {

        XapiScraper sdk = XapiScraper.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        TimelinesTweetsAndRepliesRequest req = TimelinesTweetsAndRepliesRequest.builder()
                .screenName("elonmusk")
                .count(50L)
                .build();

        TimelinesTweetsAndRepliesResponse res = sdk.timelines().tweetsAndReplies()
                .request(req)
                .call();

        if (res.searchResponse().isPresent()) {
            System.out.println(res.searchResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
request TimelinesTweetsAndRepliesRequest ✔️ The request object to use for the request.

Response

TimelinesTweetsAndRepliesResponse

Errors

Error Type Status Code Content Type
models/errors/HTTPValidationError 422 application/json
models/errors/APIException 4XX, 5XX */*

userPage

Fetch a single page from a user's timeline using POST. Pass next_cursor in the body to continue.

Example Usage

package hello.world;

import io.twexapi.sdk.XapiScraper;
import io.twexapi.sdk.models.components.UserTimelinePageQuery;
import io.twexapi.sdk.models.errors.HTTPValidationError;
import io.twexapi.sdk.models.operations.TimelinesUserPageRequest;
import io.twexapi.sdk.models.operations.TimelinesUserPageResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws HTTPValidationError, Exception {

        XapiScraper sdk = XapiScraper.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        TimelinesUserPageRequest req = TimelinesUserPageRequest.builder()
                .screenName("axiaisacat")
                .body(UserTimelinePageQuery.builder()
                    .nextCursor("DAAHCgABHFeD5h9__-cLAAIAAAATMjAzODIzMzA5NTM4ODY4MDU5NAgAAwAAAAIAAA")
                    .build())
                .build();

        TimelinesUserPageResponse res = sdk.timelines().userPage()
                .request(req)
                .call();

        if (res.userTimelinePageResponse().isPresent()) {
            System.out.println(res.userTimelinePageResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
request TimelinesUserPageRequest ✔️ The request object to use for the request.

Response

TimelinesUserPageResponse

Errors

Error Type Status Code Content Type
models/errors/HTTPValidationError 422 application/json
models/errors/APIException 4XX, 5XX */*

user

Fetch a user's timeline across pages using POST and try to fill the requested count.

Example Usage

package hello.world;

import io.twexapi.sdk.XapiScraper;
import io.twexapi.sdk.models.components.UserTimelineFillQuery;
import io.twexapi.sdk.models.errors.HTTPValidationError;
import io.twexapi.sdk.models.operations.TimelinesUserRequest;
import io.twexapi.sdk.models.operations.TimelinesUserResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws HTTPValidationError, Exception {

        XapiScraper sdk = XapiScraper.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        TimelinesUserRequest req = TimelinesUserRequest.builder()
                .screenName("axiaisacat")
                .body(UserTimelineFillQuery.builder()
                    .build())
                .build();

        TimelinesUserResponse res = sdk.timelines().user()
                .request(req)
                .call();

        if (res.userTimelineResponse().isPresent()) {
            System.out.println(res.userTimelineResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
request TimelinesUserRequest ✔️ The request object to use for the request.

Response

TimelinesUserResponse

Errors

Error Type Status Code Content Type
models/errors/HTTPValidationError 422 application/json
models/errors/APIException 4XX, 5XX */*

tweetsAndRepliesPage

Retrieve a paginated list of a user's tweets and replies using cursor-based pagination. Each page returns up to 20 items. Pass next_cursor from the previous response to continue. Pricing: $0.10 per 1,000 items.

Example Usage

package hello.world;

import io.twexapi.sdk.XapiScraper;
import io.twexapi.sdk.models.components.GetAllTweetsRepliesCursorQuery;
import io.twexapi.sdk.models.errors.HTTPValidationError;
import io.twexapi.sdk.models.operations.TimelinesTweetsAndRepliesPageResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws HTTPValidationError, Exception {

        XapiScraper sdk = XapiScraper.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        GetAllTweetsRepliesCursorQuery req = GetAllTweetsRepliesCursorQuery.builder()
                .screenName("elonmusk")
                .nextCursor("1234567890")
                .build();

        TimelinesTweetsAndRepliesPageResponse res = sdk.timelines().tweetsAndRepliesPage()
                .request(req)
                .call();

        if (res.getAllTweetsRepliesCursorResponse().isPresent()) {
            System.out.println(res.getAllTweetsRepliesCursorResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
request GetAllTweetsRepliesCursorQuery ✔️ The request object to use for the request.

Response

TimelinesTweetsAndRepliesPageResponse

Errors

Error Type Status Code Content Type
models/errors/HTTPValidationError 422 application/json
models/errors/APIException 4XX, 5XX */*