Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

docs(x): update maintenance guidance and add fix history to changelog

spacesdrived7df278bf021
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 98538ff..b0a1111 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -47,6 +47,15 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
+**X (Twitter) API fixes**
+- Replaced `Twitter` Lucide icon (removed in lucide-react 1.17.0) with an inline `XIcon` SVG component in `Sidebar.jsx` and `AccountManager.jsx`; resolves build failure
+- Updated `X_BEARER` from the rotated January 2024 token to the current web client token; error code 89 on HTTP 401 is the symptom of a stale bearer token, not expired user cookies
+- Updated `X_GQL_BASE` from `api.x.com/graphql` to `x.com/i/api/graphql` to match the live endpoint
+- Updated `UserByScreenName` and `UserTweets` query IDs; 400/422 `GRAPHQL_VALIDATION_FAILED` is the symptom of stale query IDs which X rotates on every frontend deploy
+- Replaced two sparse feature flag objects with a unified `BASE_FEATURES` dict aligned with twscrape's `GQL_FEATURES`; profile queries extend it with subscription/highlights flags
+- Improved 400/422 error handler to read and expose the actual X response body rather than returning a generic message
+- Added `Origin` and `Referer` headers required by X's GraphQL endpoints
+
**Reddit Application-Only OAuth**
- Added `REDDIT_CLIENT_ID` and `REDDIT_CLIENT_SECRET` optional Worker secrets for application-only OAuth (client credentials grant)
- `getAppOnlyToken(env)` in `backend/services/reddit.js` - exchanges client credentials for a bearer token via `POST /api/v1/access_token` with `grant_type=client_credentials`; token cached in isolate memory with expiry
diff --git a/docs/architecture/backend/SERVICES.md b/docs/architecture/backend/SERVICES.md
index 1d25e12..84def99 100644
--- a/docs/architecture/backend/SERVICES.md
+++ b/docs/architecture/backend/SERVICES.md
@@ -128,7 +128,9 @@ Reddit integration requires no Worker secrets. The session cookie is a per-user
### HTTP Client
-All X (Twitter) internal GraphQL API calls go through `xFetch(url, authToken, ct0)`. Requests include the X web client bearer token in `Authorization`, the `ct0` value in `x-csrf-token`, and both cookies in `Cookie`. The bearer token (`X_BEARER` constant) is X's own web client token and changes infrequently. GraphQL query IDs (`X_QUERY_IDS`) rotate when X deploys frontend changes — symptoms are HTTP 400 or 422 `GRAPHQL_VALIDATION_FAILED`. Get current IDs from `OP_UserByScreenName` / `OP_UserTweets` in https://github.com/vladkens/twscrape (twscrape/api.py).
+All X (Twitter) internal GraphQL API calls go through `xFetch(url, authToken, ct0)`. Requests include the X web client bearer token in `Authorization`, the `ct0` value in `x-csrf-token`, and both cookies in `Cookie`. The bearer token (`X_BEARER` constant) is X's own web client token and changes infrequently. GraphQL query IDs (`X_QUERY_IDS`) rotate frequently when X deploys frontend changes — symptoms are HTTP 400 or 422 `GRAPHQL_VALIDATION_FAILED`. Cross-reference two sources for fresh IDs, as either can lag X's rotation:
+- https://github.com/vladkens/twscrape — `OP_UserByScreenName` / `OP_UserTweets` in `twscrape/api.py`
+- https://github.com/trevorhobenshield/twitter-api-client — `UserByScreenName` / `UserTweets` in `twitter/constants.py`
### Key Functions
diff --git a/docs/architecture/data-flows/ANALYTICS.md b/docs/architecture/data-flows/ANALYTICS.md
index 3aedf23..d649a97 100644
--- a/docs/architecture/data-flows/ANALYTICS.md
+++ b/docs/architecture/data-flows/ANALYTICS.md
@@ -277,7 +277,9 @@ XAnalytics.jsx mounts -> api.getXAnalytics(id)
Note: `impressionCount` requires authentication as the account owner. It is available for own tweets via X's `views.count` field in the GraphQL response. Older tweets or tweets viewed without authentication return 0.
-Note: X's GraphQL `queryId` values in `X_QUERY_IDS` (backend/services/x.js) rotate when X deploys frontend updates. Symptoms are HTTP 400 or HTTP 422 with `GRAPHQL_VALIDATION_FAILED`. Get current IDs from https://github.com/vladkens/twscrape — look for `OP_UserByScreenName` and `OP_UserTweets` in `twscrape/api.py`.
+Note: X's GraphQL `queryId` values in `X_QUERY_IDS` (backend/services/x.js) rotate frequently when X deploys frontend updates. Symptoms are HTTP 400 or HTTP 422 with `GRAPHQL_VALIDATION_FAILED`. Cross-reference both sources, as either can lag X's rotation:
+- https://github.com/vladkens/twscrape — `OP_UserByScreenName` / `OP_UserTweets` in `twscrape/api.py`
+- https://github.com/trevorhobenshield/twitter-api-client — `UserByScreenName` / `UserTweets` in `twitter/constants.py`
## Overview Dashboard (Cross-Account)