- countries - List Global Trend Countries
- topics - List Global Trend Topics
- contents - List Global Trend Content Tags
- tweets - Get Global Trending Tweets
- byCountry - Get Trending Topics
Get the supported country and global options that can be used to filter trending tweets.
import { XApiScraper } from "@twexapi-dev/x-api-scraper";
const xApiScraper = new XApiScraper({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await xApiScraper.trending.countries();
console.log(result);
}
run();The standalone function version of this method:
import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { trendingCountries } from "@twexapi-dev/x-api-scraper/funcs/trending-countries.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 trendingCountries(xApiScraper);
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("trendingCountries failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
Promise<models.StandardResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.XAPIScraperDefaultError | 4XX, 5XX | */* |
Get the topic categories available for filtering global trending tweets.
import { XApiScraper } from "@twexapi-dev/x-api-scraper";
const xApiScraper = new XApiScraper({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await xApiScraper.trending.topics();
console.log(result);
}
run();The standalone function version of this method:
import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { trendingTopics } from "@twexapi-dev/x-api-scraper/funcs/trending-topics.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 trendingTopics(xApiScraper);
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("trendingTopics failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
Promise<models.StandardResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.XAPIScraperDefaultError | 4XX, 5XX | */* |
Get content tags for a selected country and topic so tweets can be filtered more precisely.
import { XApiScraper } from "@twexapi-dev/x-api-scraper";
const xApiScraper = new XApiScraper({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await xApiScraper.trending.contents({
country: "Monaco",
topic: "<value>",
});
console.log(result);
}
run();The standalone function version of this method:
import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { trendingContents } from "@twexapi-dev/x-api-scraper/funcs/trending-contents.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 trendingContents(xApiScraper, {
country: "Monaco",
topic: "<value>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("trendingContents failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.TrendingContentsRequest | ✔️ | 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. |
Promise<models.StandardResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.XAPIScraperDefaultError | 4XX, 5XX | */* |
Get trending tweets for a country, with optional topic and content tag filters.
import { XApiScraper } from "@twexapi-dev/x-api-scraper";
const xApiScraper = new XApiScraper({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await xApiScraper.trending.tweets({
country: "Lithuania",
});
console.log(result);
}
run();The standalone function version of this method:
import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { trendingTweets } from "@twexapi-dev/x-api-scraper/funcs/trending-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 trendingTweets(xApiScraper, {
country: "Lithuania",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("trendingTweets failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.TrendingTweetsRequest | ✔️ | 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. |
Promise<models.SearchResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.XAPIScraperDefaultError | 4XX, 5XX | */* |
Get X Explore trending topics for a given country. Use 'worldwide' for account-default trends or a country slug such as 'united-states'.
import { XApiScraper } from "@twexapi-dev/x-api-scraper";
const xApiScraper = new XApiScraper({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await xApiScraper.trending.byCountry({
country: "worldwide",
});
console.log(result);
}
run();The standalone function version of this method:
import { XApiScraperCore } from "@twexapi-dev/x-api-scraper/core.js";
import { trendingByCountry } from "@twexapi-dev/x-api-scraper/funcs/trending-by-country.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 trendingByCountry(xApiScraper, {
country: "worldwide",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("trendingByCountry failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.TrendingByCountryRequest | ✔️ | 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. |
Promise<models.StandardResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.XAPIScraperDefaultError | 4XX, 5XX | */* |