twitterviewer 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Types of the TwitterViewer API, following openapi.json.
3
+ * The API may add response fields at any time.
4
+ */
5
+ export interface UserLite {
6
+ id: string;
7
+ /** Username without @ */
8
+ handle: string;
9
+ name: string;
10
+ avatarUrl: string | null;
11
+ verified: boolean;
12
+ verifiedType: 'blue' | 'business' | 'government' | null;
13
+ protected: boolean;
14
+ }
15
+ export interface User extends UserLite {
16
+ bannerUrl: string | null;
17
+ bio: string;
18
+ location: string | null;
19
+ website: string | null;
20
+ followers: number | null;
21
+ following: number | null;
22
+ postsCount: number | null;
23
+ likesCount: number | null;
24
+ mediaCount: number | null;
25
+ /** ISO 8601 */
26
+ createdAt: string | null;
27
+ pinnedTweetIds: string[];
28
+ }
29
+ export interface VideoVariant {
30
+ url: string;
31
+ contentType: 'video/mp4' | 'application/x-mpegURL';
32
+ bitrate: number | null;
33
+ width: number | null;
34
+ height: number | null;
35
+ }
36
+ export interface Media {
37
+ id: string;
38
+ kind: 'photo' | 'video' | 'gif';
39
+ /** Photo address; cover image for video and GIF */
40
+ url: string;
41
+ width: number | null;
42
+ height: number | null;
43
+ altText: string | null;
44
+ durationMs: number | null;
45
+ variants: VideoVariant[];
46
+ }
47
+ export interface Article {
48
+ id: string;
49
+ title: string;
50
+ /** Article body as Markdown; preview text when the body is not available */
51
+ markdown: string;
52
+ coverUrl: string | null;
53
+ url: string;
54
+ }
55
+ export interface PollOption {
56
+ label: string;
57
+ votes: number | null;
58
+ }
59
+ export interface Poll {
60
+ options: PollOption[];
61
+ totalVotes: number | null;
62
+ /** ISO 8601 */
63
+ endsAt: string | null;
64
+ ended: boolean;
65
+ }
66
+ export interface Card {
67
+ url: string;
68
+ title: string | null;
69
+ description: string | null;
70
+ domain: string | null;
71
+ imageUrl: string | null;
72
+ }
73
+ export interface ReplyTarget {
74
+ tweetId: string;
75
+ handle: string;
76
+ }
77
+ export interface Tweet {
78
+ id: string;
79
+ url: string;
80
+ author: UserLite;
81
+ text: string;
82
+ lang: string | null;
83
+ /** ISO 8601 */
84
+ createdAt: string;
85
+ replyCount: number | null;
86
+ repostCount: number | null;
87
+ likeCount: number | null;
88
+ quoteCount: number | null;
89
+ bookmarkCount: number | null;
90
+ viewCount: number | null;
91
+ media: Media[];
92
+ quoted: Tweet | null;
93
+ repostedBy: UserLite | null;
94
+ inReplyTo: ReplyTarget | null;
95
+ conversationId: string | null;
96
+ pinned: boolean;
97
+ article?: Article | null;
98
+ poll?: Poll | null;
99
+ card?: Card | null;
100
+ communityNote?: string | null;
101
+ sensitive?: boolean;
102
+ }
103
+ /** Credits charged by a call and credits left after it. */
104
+ export interface Billing {
105
+ charged: number;
106
+ remaining: number;
107
+ }
108
+ export interface ConvertResult {
109
+ kind: 'post' | 'thread' | 'conversation' | 'profile';
110
+ title: string;
111
+ sourceUrl: string;
112
+ /** Full profile when available, otherwise the short form */
113
+ author: User | UserLite;
114
+ /** The document as Markdown, or Obsidian Markdown when `format` is `obsidian` */
115
+ markdown: string;
116
+ /** The same content as plain text */
117
+ text: string;
118
+ posts: Tweet[];
119
+ /** Filled only for `scope: 'conversation'` */
120
+ replies: Tweet[];
121
+ /** Posts, replies and quoted posts in this result; the credit cost of a first request */
122
+ postsReturned: number;
123
+ wordCount: number;
124
+ credits: Billing;
125
+ }
126
+ export interface RepliesResult {
127
+ sourceUrl: string;
128
+ replies: Tweet[];
129
+ /** Length of `replies`. Quoted posts are not counted here but are charged */
130
+ postsReturned: number;
131
+ credits: Billing;
132
+ }
133
+ export interface CreditBalance {
134
+ total: number;
135
+ unlimited: boolean;
136
+ plan: {
137
+ remaining: number;
138
+ granted: number;
139
+ /** ISO 8601 */
140
+ expiresAt: string | null;
141
+ };
142
+ /** Credits that never expire, including the sign-up credits */
143
+ purchased: {
144
+ remaining: number;
145
+ };
146
+ }
147
+ export type Scope = 'thread' | 'post' | 'conversation';
148
+ export type TextFormat = 'markdown' | 'obsidian' | 'text';
149
+ export type Format = TextFormat | 'json' | 'pdf';
150
+ export type Stats = 'all' | 'root' | 'off';
151
+ export type Paper = 'a4' | 'letter';
152
+ /** Parameters shared by every conversion. */
153
+ export interface ConvertOptions {
154
+ /** Post links only. Default `thread`. */
155
+ scope?: Scope;
156
+ /** Engagement numbers in the rendered document. Default `all`. */
157
+ stats?: Stats;
158
+ /** Profile links only: how many recent posts, 1 to 200. Default 20. */
159
+ max?: number;
160
+ /** Profile links only: include the account's replies. Default false. */
161
+ replies?: boolean;
162
+ /** Profile links only: include reposts. Default false. */
163
+ reposts?: boolean;
164
+ /** Page size of a PDF. Default `a4`. */
165
+ paper?: Paper;
166
+ }
167
+ export interface ConvertTarget extends ConvertOptions {
168
+ /** A link to an X post or profile (x.com or twitter.com), or an @handle. */
169
+ url: string;
170
+ }
171
+ /** Parameters of a conversion returned as JSON. */
172
+ export interface ConvertParams extends ConvertTarget {
173
+ /** Which flavor the `markdown` field is rendered in. */
174
+ format?: 'json' | 'markdown' | 'obsidian';
175
+ }
176
+ /** Parameters of a conversion returned as a plain document. */
177
+ export interface ConvertTextParams extends ConvertTarget {
178
+ /** Default `markdown`. */
179
+ format?: TextFormat;
180
+ }
181
+ /** Parameters of a conversion returned as a PDF. */
182
+ export type ConvertPdfParams = ConvertTarget;
183
+ export interface SwapParams extends ConvertOptions {
184
+ /** Default `markdown`. */
185
+ format?: Format;
186
+ /** `off` is the same as `scope: 'post'` (ignored when `scope` is given). */
187
+ thread?: 'off';
188
+ }
189
+ export interface RepliesParams {
190
+ /** A link to an X post. */
191
+ url: string;
192
+ /** 1 to 100. Default 20. */
193
+ max?: number;
194
+ }
195
+ /** Values of the response headers. `null` when the header is absent. */
196
+ export interface ResponseMeta {
197
+ creditsCharged: number | null;
198
+ creditsRemaining: number | null;
199
+ /** Requests left in the current minute; absent for accounts without a limit */
200
+ rateLimitRemaining: number | null;
201
+ }
202
+ export interface TextDocument extends ResponseMeta {
203
+ content: string;
204
+ /** Posts in the document, quoted posts included */
205
+ postsReturned: number | null;
206
+ }
207
+ export interface PdfDocument extends ResponseMeta {
208
+ data: Uint8Array;
209
+ /** File name suggested by the server, in the title's own script when it sends one */
210
+ filename: string | null;
211
+ }
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types of the TwitterViewer API, following openapi.json.
3
+ * The API may add response fields at any time.
4
+ */
5
+ export {};
@@ -0,0 +1,2 @@
1
+ /** Package version. A test keeps it equal to package.json. */
2
+ export declare const VERSION = "0.1.1";
@@ -0,0 +1,2 @@
1
+ /** Package version. A test keeps it equal to package.json. */
2
+ export const VERSION = '0.1.1';
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "twitterviewer",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "TypeScript SDK and command line client for the TwitterViewer API: read public X (Twitter) posts, threads, profiles and replies as JSON, Markdown, text or PDF.",
5
+ "keywords": ["twitter", "x", "twitterviewer-api", "sdk", "cli", "markdown", "thread", "obsidian", "ai-agents", "twitterviewer"],
6
+ "homepage": "https://twitterviewer.ai",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/TwitterViewer/twitterviewer-node.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/TwitterViewer/twitterviewer-node/issues"
13
+ },
14
+ "license": "MIT",
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "types": "./dist/index.d.ts",
24
+ "bin": {
25
+ "twitterviewer": "dist/cli/bin.js"
26
+ },
27
+ "files": ["dist", "README.md", "LICENSE"],
28
+ "sideEffects": false,
29
+ "engines": {
30
+ "node": ">=20"
31
+ },
32
+ "scripts": {
33
+ "build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json && node -e \"require('node:fs').chmodSync('dist/cli/bin.js', 0o755)\"",
34
+ "prepack": "npm run build",
35
+ "typecheck": "tsc -p tsconfig.json",
36
+ "test": "vitest run"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^20",
43
+ "typescript": "^5",
44
+ "vitest": "^3"
45
+ }
46
+ }