Skip to content

Latest commit

 

History

History
549 lines (406 loc) · 42.5 KB

File metadata and controls

549 lines (406 loc) · 42.5 KB

Communities

Overview

Available Operations

members

Get community members

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.communities.members({
    communityId: "<id>",
    targetCount: 298640,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { communitiesMembers } from "@twexapi-dev/x-api-scraper/funcs/communities-members.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 communitiesMembers(xApiScraper, {
    communityId: "<id>",
    targetCount: 298640,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("communitiesMembers failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CommunitiesMembersRequest ✔️ 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 */*

membersPage

Retrieve a paginated list of community members using cursor-based pagination. Each page returns up to 20 members. Pass next_cursor from the previous response to continue. Pricing: $0.10 per 1,000 members.

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.communities.membersPage({
    nextCursor: "1234567890",
    communityId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { communitiesMembersPage } from "@twexapi-dev/x-api-scraper/funcs/communities-members-page.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 communitiesMembersPage(xApiScraper, {
    nextCursor: "1234567890",
    communityId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("communitiesMembersPage failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request models.GetCommunityMembersCursorQuery ✔️ 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.GetCommunityMembersCursorResponse>

Errors

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

tweets

Get community tweets

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.communities.tweets({
    communityId: "<id>",
    tweetType: "Media",
    targetCount: 682850,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { communitiesTweets } from "@twexapi-dev/x-api-scraper/funcs/communities-tweets.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 communitiesTweets(xApiScraper, {
    communityId: "<id>",
    tweetType: "Media",
    targetCount: 682850,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("communitiesTweets failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CommunitiesTweetsRequest ✔️ 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.CommunityTweetsResponse>

Errors

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

tweetsPage

Retrieve a paginated list of community tweets using 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.

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.communities.tweetsPage({
    nextCursor: "1234567890",
    communityId: "<id>",
    tweetType: "Top",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { communitiesTweetsPage } from "@twexapi-dev/x-api-scraper/funcs/communities-tweets-page.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 communitiesTweetsPage(xApiScraper, {
    nextCursor: "1234567890",
    communityId: "<id>",
    tweetType: "Top",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("communitiesTweetsPage failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request models.GetCommunityTweetsCursorQuery ✔️ 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.GetCommunityTweetsCursorResponse>

Errors

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

search

Search community

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.communities.search({
    query: "<value>",
    targetCount: 761546,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { communitiesSearch } from "@twexapi-dev/x-api-scraper/funcs/communities-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 communitiesSearch(xApiScraper, {
    query: "<value>",
    targetCount: 761546,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("communitiesSearch failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request models.SearchCommunityQuery ✔️ 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.SearchCommunityResponse>

Errors

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

get

Get community

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.communities.get({
    communityId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { communitiesGet } from "@twexapi-dev/x-api-scraper/funcs/communities-get.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 communitiesGet(xApiScraper, {
    communityId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("communitiesGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CommunitiesGetRequest ✔️ 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.GetCommunityResponse>

Errors

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

searchTweets

Search community tweets

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.communities.searchTweets({
    communityId: "<id>",
    targetCount: 687977,
    query: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { communitiesSearchTweets } from "@twexapi-dev/x-api-scraper/funcs/communities-search-tweets.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 communitiesSearchTweets(xApiScraper, {
    communityId: "<id>",
    targetCount: 687977,
    query: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("communitiesSearchTweets failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request models.SearchCommunityTweetsQuery ✔️ 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.CommunityTweetsResponse>

Errors

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