Skip to content

Latest commit

 

History

History
691 lines (508 loc) · 54.7 KB

File metadata and controls

691 lines (508 loc) · 54.7 KB

Users

Overview

Available Operations

getByUsernames

Retrieve detailed profile information for multiple Twitter users by their usernames or profile URLs, $0.10/1000 users. 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

import { XApiScraper } from "@twexapi-dev/x-api-scraper";

const xApiScraper = new XApiScraper({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await xApiScraper.users.getByUsernames([
    "elonmusk",
  ]);

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { usersGetByUsernames } from "@twexapi-dev/x-api-scraper/funcs/users-get-by-usernames.js";

// Use `XApiScraperCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const xApiScraper = new XApiScraperCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await usersGetByUsernames(xApiScraper, [
    "elonmusk",
  ]);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersGetByUsernames failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request string[] ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<any>

Errors

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

getByIds

Users Details by ID. 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

import { XApiScraper } from "@twexapi-dev/x-api-scraper";

const xApiScraper = new XApiScraper({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await xApiScraper.users.getByIds([
    "44196397",
    "1696160451770429440",
  ]);

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { usersGetByIds } from "@twexapi-dev/x-api-scraper/funcs/users-get-by-ids.js";

// Use `XApiScraperCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const xApiScraper = new XApiScraperCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await usersGetByIds(xApiScraper, [
    "44196397",
    "1696160451770429440",
  ]);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersGetByIds failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request string[] ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.UsersDetailsResponse>

Errors

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

verifyAccount

Retrieves the verification metadata for a specific account. This endpoint identifies whether an account holds a Blue Verified status (authenticity check) or is an Official Organization Affiliate (gold/grey labels). 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

import { XApiScraper } from "@twexapi-dev/x-api-scraper";

const xApiScraper = new XApiScraper({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await xApiScraper.users.verifyAccount([
    "1696160451770429440",
  ]);

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { usersVerifyAccount } from "@twexapi-dev/x-api-scraper/funcs/users-verify-account.js";

// Use `XApiScraperCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const xApiScraper = new XApiScraperCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await usersVerifyAccount(xApiScraper, [
    "1696160451770429440",
  ]);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersVerifyAccount failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request string[] ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.AccountVerifyResponse>

Errors

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

getStatuses

Retrieve detailed account status for multiple Twitter users by their usernames. 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

import { XApiScraper } from "@twexapi-dev/x-api-scraper";

const xApiScraper = new XApiScraper({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await xApiScraper.users.getStatuses([
    "elonmusk",
    "sundarpichai",
  ]);

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { usersGetStatuses } from "@twexapi-dev/x-api-scraper/funcs/users-get-statuses.js";

// Use `XApiScraperCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const xApiScraper = new XApiScraperCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await usersGetStatuses(xApiScraper, [
    "elonmusk",
    "sundarpichai",
  ]);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersGetStatuses failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request string[] ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<any>

Errors

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

search

Search user

Example Usage

import { XApiScraper } from "@twexapi-dev/x-api-scraper";

const xApiScraper = new XApiScraper({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await xApiScraper.users.search({
    keyword: "<value>",
    targetCount: 794044,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { usersSearch } from "@twexapi-dev/x-api-scraper/funcs/users-search.js";

// Use `XApiScraperCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const xApiScraper = new XApiScraperCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await usersSearch(xApiScraper, {
    keyword: "<value>",
    targetCount: 794044,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersSearch failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.UsersSearchRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.SearchUserResponse>

Errors

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

follow

Follow a user, $0.001 per call.

Example Usage

import { XApiScraper } from "@twexapi-dev/x-api-scraper";

const xApiScraper = new XApiScraper({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await xApiScraper.users.follow({
    username: "Mckenna.Roberts",
    cookie: "ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { usersFollow } from "@twexapi-dev/x-api-scraper/funcs/users-follow.js";

// Use `XApiScraperCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const xApiScraper = new XApiScraperCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await usersFollow(xApiScraper, {
    username: "Mckenna.Roberts",
    cookie: "ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersFollow failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request models.FollowUserQuery ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.BlockUserResponse>

Errors

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

unfollow

Unfollow a user, $0.001 per call.

Example Usage

import { XApiScraper } from "@twexapi-dev/x-api-scraper";

const xApiScraper = new XApiScraper({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await xApiScraper.users.unfollow({
    username: "Casandra47",
    cookie: "ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { usersUnfollow } from "@twexapi-dev/x-api-scraper/funcs/users-unfollow.js";

// Use `XApiScraperCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const xApiScraper = new XApiScraperCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await usersUnfollow(xApiScraper, {
    username: "Casandra47",
    cookie: "ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersUnfollow failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request models.UnfollowUserQuery ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.UnfollowUserResponse>

Errors

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

getAccountBased

Get Twitter Account Based in. 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

import { XApiScraper } from "@twexapi-dev/x-api-scraper";

const xApiScraper = new XApiScraper({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await xApiScraper.users.getAccountBased([
    "screen_name",
  ]);

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { usersGetAccountBased } from "@twexapi-dev/x-api-scraper/funcs/users-get-account-based.js";

// Use `XApiScraperCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const xApiScraper = new XApiScraperCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await usersGetAccountBased(xApiScraper, [
    "screen_name",
  ]);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersGetAccountBased failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request string[] ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.TwitterAccountBasedStandardResponse>

Errors

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

getAbout

Get Twitter User About for a specific twitter user. get account_based_in,location_accurate

Example Usage

import { XApiScraper } from "@twexapi-dev/x-api-scraper";

const xApiScraper = new XApiScraper({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await xApiScraper.users.getAbout({
    screenName: "elonmusk",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { usersGetAbout } from "@twexapi-dev/x-api-scraper/funcs/users-get-about.js";

// Use `XApiScraperCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const xApiScraper = new XApiScraperCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await usersGetAbout(xApiScraper, {
    screenName: "elonmusk",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersGetAbout failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.UsersGetAboutRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.TwitterUserAboutStandardResponse>

Errors

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