Documentation Index
Fetch the complete documentation index at: https://docs.xquik.com/llms.txt
Use this file to discover all available pages before exploring further.
Use the TypeScript SDK when you want typed request parameters, response models, retries, and autocomplete for Xquik REST API workflows in Node.js, Bun, or server-side TypeScript.
Install
npm install x-twitter-scraper
Authenticate
export X_TWITTER_SCRAPER_API_KEY="xq_YOUR_KEY_HERE"
import XTwitterScraper from "x-twitter-scraper";
const client = new XTwitterScraper({
apiKey: process.env["X_TWITTER_SCRAPER_API_KEY"],
});
Basic Example
Search tweets and write the first page as JSON:
import XTwitterScraper from "x-twitter-scraper";
const client = new XTwitterScraper();
const tweets = await client.x.tweets.search({
q: "from:elonmusk",
limit: 10,
});
process.stdout.write(JSON.stringify(tweets, null, 2));
Useful endpoints:
Error Handling
The SDK throws typed errors for API failures:
| Status | Error class |
|---|
| 400 | BadRequestError |
| 401 | AuthenticationError |
| 403 | PermissionDeniedError |
| 404 | NotFoundError |
| 422 | UnprocessableEntityError |
| 429 | RateLimitError |
| 5xx | InternalServerError |
import XTwitterScraper from "x-twitter-scraper";
const client = new XTwitterScraper();
try {
await client.account.retrieve();
} catch (error) {
if (error instanceof XTwitterScraper.APIError) {
process.stderr.write(`HTTP ${error.status}\n`);
} else {
process.stderr.write("Network or timeout error\n");
}
}
The client retries connection errors, 408, 409, 429, and 5xx responses by default. Set maxRetries to tune retry behavior.
Search and list endpoints return page objects. Check has_next_page and pass the generated cursor fields documented on each endpoint when you need another page.
const firstPage = await client.x.tweets.search({ q: "xquik", limit: 20 });
if (firstPage.has_next_page) {
process.stderr.write("More results are available\n");
}
Webhooks & References