twitter-openapi-typescript 0.0.56 → 0.1.0
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.
- package/LICENSE +31 -31
- package/LICENSE.AGPL +660 -660
- package/README.md +75 -75
- package/dist/src/api.d.ts +3 -3
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/api.js +161 -295
- package/dist/src/api.js.map +1 -1
- package/dist/src/apis/defaultApi.d.ts +2 -2
- package/dist/src/apis/defaultApi.d.ts.map +1 -1
- package/dist/src/apis/defaultApi.js +39 -114
- package/dist/src/apis/defaultApi.js.map +1 -1
- package/dist/src/apis/initialStateApi.js +2 -5
- package/dist/src/apis/initialStateApi.js.map +1 -1
- package/dist/src/apis/postApi.d.ts +2 -2
- package/dist/src/apis/postApi.d.ts.map +1 -1
- package/dist/src/apis/postApi.js +140 -251
- package/dist/src/apis/postApi.js.map +1 -1
- package/dist/src/apis/tweetApi.d.ts +6 -3
- package/dist/src/apis/tweetApi.d.ts.map +1 -1
- package/dist/src/apis/tweetApi.js +237 -342
- package/dist/src/apis/tweetApi.js.map +1 -1
- package/dist/src/apis/userApi.d.ts +3 -3
- package/dist/src/apis/userApi.d.ts.map +1 -1
- package/dist/src/apis/userApi.js +43 -108
- package/dist/src/apis/userApi.js.map +1 -1
- package/dist/src/apis/userListApi.d.ts +3 -3
- package/dist/src/apis/userListApi.d.ts.map +1 -1
- package/dist/src/apis/userListApi.js +97 -183
- package/dist/src/apis/userListApi.js.map +1 -1
- package/dist/src/apis/usersApi.d.ts +3 -3
- package/dist/src/apis/usersApi.d.ts.map +1 -1
- package/dist/src/apis/usersApi.js +28 -91
- package/dist/src/apis/usersApi.js.map +1 -1
- package/dist/src/apis/v11GetApi.d.ts +3 -3
- package/dist/src/apis/v11GetApi.d.ts.map +1 -1
- package/dist/src/apis/v11GetApi.js +3 -4
- package/dist/src/apis/v11GetApi.js.map +1 -1
- package/dist/src/apis/v11PostApi.d.ts +3 -3
- package/dist/src/apis/v11PostApi.d.ts.map +1 -1
- package/dist/src/apis/v11PostApi.js +50 -84
- package/dist/src/apis/v11PostApi.js.map +1 -1
- package/dist/src/apis/v20GetApi.d.ts +3 -3
- package/dist/src/apis/v20GetApi.d.ts.map +1 -1
- package/dist/src/apis/v20GetApi.js +3 -4
- package/dist/src/apis/v20GetApi.js.map +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +4 -4
- package/dist/src/models/response.d.ts +1 -1
- package/dist/src/models/response.d.ts.map +1 -1
- package/dist/src/models/timeline.d.ts +2 -2
- package/dist/src/models/timeline.d.ts.map +1 -1
- package/dist/src/models/utils.d.ts +2 -2
- package/dist/src/models/utils.d.ts.map +1 -1
- package/dist/src/utils/api.d.ts +2 -2
- package/dist/src/utils/api.d.ts.map +1 -1
- package/dist/src/utils/api.js +68 -85
- package/dist/src/utils/api.js.map +1 -1
- package/package.json +37 -42
package/README.md
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
# twitter-openapi-typescript
|
|
2
|
-
|
|
3
|
-
## Setup
|
|
4
|
-
|
|
5
|
-
```sh
|
|
6
|
-
npm i twitter-openapi-typescript
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
## Usage
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { TwitterOpenApi } from 'twitter-openapi-typescript';
|
|
13
|
-
|
|
14
|
-
const api = new TwitterOpenApi();
|
|
15
|
-
const client = await api.getGuestClient();
|
|
16
|
-
const response = await client.getUserApi().getUserByScreenName({ screenName: 'elonmusk' });
|
|
17
|
-
const userLegacy = response.data?.user?.legacy;
|
|
18
|
-
if (userLegacy) {
|
|
19
|
-
console.log(userLegacy.screenName);
|
|
20
|
-
console.log(`followCount: ${userLegacy.friendsCount} followersCount: ${userLegacy.followersCount}`);
|
|
21
|
-
} else {
|
|
22
|
-
console.log('User not found');
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### Login
|
|
27
|
-
|
|
28
|
-
```typescript
|
|
29
|
-
// ct0 and authToken will also work but it is recommended to set all cookies.
|
|
30
|
-
const client = await api.getClientFromCookies({
|
|
31
|
-
ct0: '<csrf_token>',
|
|
32
|
-
auth_token: '<auth_token>',
|
|
33
|
-
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Multiple OS
|
|
37
|
-
|
|
38
|
-
The Token can only be used on the same OS that issued the Token
|
|
39
|
-
In other words, if the sec-ch-ua-platform does not match, the Token cannot be used.
|
|
40
|
-
This library uses the Linux Chrome header by default.
|
|
41
|
-
To use Token issued by Windows, do the following.
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
const api = new TwitterOpenApi();
|
|
45
|
-
api.setAdditionalApiHeaders({
|
|
46
|
-
'sec-ch-ua-platform': '"Windows"',
|
|
47
|
-
});
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### List of APIs
|
|
51
|
-
|
|
52
|
-
You should read the Test case.
|
|
53
|
-
|
|
54
|
-
<https://github.com/fa0311/twitter-openapi-typescript/tree/master/twitter-openapi-typescript/test/api>
|
|
55
|
-
|
|
56
|
-
### Customize in detail
|
|
57
|
-
|
|
58
|
-
Most values exist as static variables. There is no need to change them.
|
|
59
|
-
Changing them could result in account suspension.
|
|
60
|
-
For advanced customization, use the
|
|
61
|
-
You can also use the `TwitterOpenApiClient` class directly
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
import { TwitterOpenApi } from 'twitter-openapi-typescript';
|
|
65
|
-
TwitterOpenApi.fetchApi = fetch.bind(globalThis);
|
|
66
|
-
TwitterOpenApi.twitter = 'https://x.com/home';
|
|
67
|
-
TwitterOpenApi.bearer = 'xxxx';
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## License
|
|
71
|
-
|
|
72
|
-
This project is dual licensed. You can choose one of the following licenses:
|
|
73
|
-
|
|
74
|
-
- [Custom License](./LICENSE)
|
|
75
|
-
- [GNU Affero General Public License v3.0](./LICENSE.AGPL)
|
|
1
|
+
# twitter-openapi-typescript
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm i twitter-openapi-typescript
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { TwitterOpenApi } from 'twitter-openapi-typescript';
|
|
13
|
+
|
|
14
|
+
const api = new TwitterOpenApi();
|
|
15
|
+
const client = await api.getGuestClient();
|
|
16
|
+
const response = await client.getUserApi().getUserByScreenName({ screenName: 'elonmusk' });
|
|
17
|
+
const userLegacy = response.data?.user?.legacy;
|
|
18
|
+
if (userLegacy) {
|
|
19
|
+
console.log(userLegacy.screenName);
|
|
20
|
+
console.log(`followCount: ${userLegacy.friendsCount} followersCount: ${userLegacy.followersCount}`);
|
|
21
|
+
} else {
|
|
22
|
+
console.log('User not found');
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Login
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
// ct0 and authToken will also work but it is recommended to set all cookies.
|
|
30
|
+
const client = await api.getClientFromCookies({
|
|
31
|
+
ct0: '<csrf_token>',
|
|
32
|
+
auth_token: '<auth_token>',
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Multiple OS
|
|
37
|
+
|
|
38
|
+
The Token can only be used on the same OS that issued the Token
|
|
39
|
+
In other words, if the sec-ch-ua-platform does not match, the Token cannot be used.
|
|
40
|
+
This library uses the Linux Chrome header by default.
|
|
41
|
+
To use Token issued by Windows, do the following.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
const api = new TwitterOpenApi();
|
|
45
|
+
api.setAdditionalApiHeaders({
|
|
46
|
+
'sec-ch-ua-platform': '"Windows"',
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### List of APIs
|
|
51
|
+
|
|
52
|
+
You should read the Test case.
|
|
53
|
+
|
|
54
|
+
<https://github.com/fa0311/twitter-openapi-typescript/tree/master/twitter-openapi-typescript/test/api>
|
|
55
|
+
|
|
56
|
+
### Customize in detail
|
|
57
|
+
|
|
58
|
+
Most values exist as static variables. There is no need to change them.
|
|
59
|
+
Changing them could result in account suspension.
|
|
60
|
+
For advanced customization, use the
|
|
61
|
+
You can also use the `TwitterOpenApiClient` class directly
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { TwitterOpenApi } from 'twitter-openapi-typescript';
|
|
65
|
+
TwitterOpenApi.fetchApi = fetch.bind(globalThis);
|
|
66
|
+
TwitterOpenApi.twitter = 'https://x.com/home';
|
|
67
|
+
TwitterOpenApi.bearer = 'xxxx';
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
This project is dual licensed. You can choose one of the following licenses:
|
|
73
|
+
|
|
74
|
+
- [Custom License](./LICENSE)
|
|
75
|
+
- [GNU Affero General Public License v3.0](./LICENSE.AGPL)
|
package/dist/src/api.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DefaultApiUtils, InitialStateApiUtils, PostApiUtils, TweetApiUtils, UserApiUtils, UserListApiUtils, V11GetApiUtils, V11PostApiUtils, V20GetApiUtils } from './apis';
|
|
2
|
-
import type { DefaultFlag } from './models';
|
|
3
1
|
import * as i from 'twitter-openapi-typescript-generated';
|
|
2
|
+
import { DefaultApiUtils, InitialStateApiUtils, PostApiUtils, TweetApiUtils, UserApiUtils, UserListApiUtils, V11GetApiUtils, V11PostApiUtils, V20GetApiUtils } from './apis/index.js';
|
|
3
|
+
import type { DefaultFlag } from './models/index.js';
|
|
4
4
|
import { UsersApiUtils } from './apis/usersApi';
|
|
5
|
-
import { InitOverridesType } from './utils';
|
|
5
|
+
import type { InitOverridesType } from './utils';
|
|
6
6
|
export declare class TwitterOpenApi {
|
|
7
7
|
static hash: string;
|
|
8
8
|
static url: string;
|
package/dist/src/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,cAAc,EACf,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,sCAAsC,CAAC;AAE1D,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,cAAc,EACf,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,qBAAa,cAAc;IACzB,MAAM,CAAC,IAAI,SAA8C;IACzD,MAAM,CAAC,GAAG,SAAuG;IACjH,MAAM,CAAC,MAAM,SAA4F;IACzG,MAAM,CAAC,OAAO,SAAwB;IACtC,MAAM,CAAC,MAAM,SACgG;IAE7G,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAA0B;IAErD,wBAAwB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAM;IAEzD,2BAA2B,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI;IAIrE,oBAAoB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE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