Skip to content

Commit b4c0104

Browse files
committed
fix: patch api
1 parent fbe7725 commit b4c0104

4 files changed

Lines changed: 35 additions & 11 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ node_modules
2121
debug_responses
2222
*.bak
2323
/tools/*.json*
24+
25+
.claude
26+
.vercel

API.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,36 @@ Get username for a user ID.
206206
| attribution | object | Attribution information |
207207
| quote | object | Quoted tweet (if any) |
208208
| poll | object | Poll information (if any) |
209-
| gif | object | GIF information (if any) |
210-
| video | object | Video information (if any) |
211-
| photos | array | Photo URLs (if any) |
209+
| media | array | Media items (see Media Object) |
210+
| history | array | Tweet IDs in edit history |
211+
| note | string | Community note text (if any) |
212+
| isAd | bool | Paid promotion disclosure |
213+
| isAI | bool | AI-generated media disclosure |
214+
215+
### Media Object
216+
217+
Each item in the `media` array is a tagged object. The `kind` field is one of `photoMedia`, `videoMedia`, or `gifMedia`.
218+
219+
| Field | Type | When present | Description |
220+
|-------|--------|--------------|--------------------------|
221+
| kind | string | always | Media type discriminator |
222+
| photo | object | photoMedia | `{ url, altText }` |
223+
| video | object | videoMedia | Video variant metadata |
224+
| gif | object | gifMedia | `{ url, thumb, altText }`|
212225

213226
### Pagination Object
214227
| Field | Type | Description |
215228
|------------|--------|--------------------------------|
216229
| beginning | bool | Is first page |
217230
| top | string | Top cursor |
218-
| bottom | string | Bottom cursor |
231+
| bottom | string | Bottom cursor |
232+
233+
## Configuration
234+
235+
The JSON API is controlled by `enableJsonApi` in `nitter.conf` (default: `true`). When disabled, `/api/*` routes are not registered.
236+
237+
RSS feeds use a master switch `enableRSS` plus per-feed toggles (`enableRSSUserTweets`, `enableRSSUserReplies`, `enableRSSUserMedia`, `enableRSSSearch`, `enableRSSList`). Setting `enableRSS = false` disables all RSS endpoints.
238+
239+
### Tweet media migration
240+
241+
Older API responses exposed separate `gif`, `gifs`, `video`, and `photos` fields. These are replaced by a single `media` array. Clients should read `media` and use each item's `kind` to interpret `photo`, `video`, or `gif` payloads.

src/jsons/search.nim

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ proc createJsonApiSearchRouter*(cfg: Config) =
1616
if q.len > 500:
1717
respJsonError("Search input too long.", "invalid_input", Http400)
1818

19-
let
20-
prefs = cookiePrefs()
21-
query = initQuery(params(request))
19+
let query = initQuery(params(request))
2220

2321
case query.kind
2422
of users:

src/jsons/timeline.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ proc createJsonApiTimelineRouter*(cfg: Config) =
128128
cond @"name" notin ["pic", "gif", "video", "search", "settings", "login",
129129
"intent", "i"]
130130
let
131-
prefs = cookiePrefs()
131+
prefs = requestPrefs()
132132
names = getNames(@"name")
133133

134-
var query = request.getQuery("", @"name")
134+
var query = request.getQuery("", @"name", prefs)
135135
if names.len != 1:
136136
query.fromUser = names
137137

@@ -146,11 +146,11 @@ proc createJsonApiTimelineRouter*(cfg: Config) =
146146
cond @"name".allCharsInSet({'a'..'z', 'A'..'Z', '0'..'9', '_', ','})
147147
cond @"tab" in ["with_replies", "media", "search", ""]
148148
let
149-
prefs = cookiePrefs()
149+
prefs = requestPrefs()
150150
after = getCursor()
151151
names = getNames(@"name")
152152

153-
var query = request.getQuery(@"tab", @"name")
153+
var query = request.getQuery(@"tab", @"name", prefs)
154154
if names.len != 1:
155155
query.fromUser = names
156156

0 commit comments

Comments
 (0)