Skip to content

Commit a84ff0a

Browse files
committed
perf: 更新包配置与示例
1 parent 579cddd commit a84ff0a

File tree

2 files changed

+37
-55
lines changed

2 files changed

+37
-55
lines changed

README.md

Lines changed: 27 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,13 @@ Module system
2525

2626
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
2727

28-
### Building
28+
### Installation
2929

3030
To build and compile the typescript sources to javascript use:
31-
```
32-
npm install
33-
npm run build
34-
```
35-
36-
### Publishing
37-
38-
First build the package then run ```npm publish```
39-
40-
### Consuming
41-
42-
navigate to the folder of your consuming project and run one of the following commands.
43-
44-
_published:_
45-
4631
```
4732
npm install @tikhub/[email protected] --save
4833
```
4934

50-
_unPublished (not recommended):_
51-
52-
```
53-
npm install PATH_TO_GENERATED_PACKAGE --save
54-
```
55-
5635
## **🌟 Features**
5736

5837
- 🚀 **Fully Typed TypeScript SDK** – Provides complete type definitions.
@@ -77,18 +56,15 @@ npm install @tikhub/tikhub-api-ts-sdk --save
7756
Before making API requests, configure the **API Client** with your **API Key** and ​**Base URL**​.
7857

7958
```ts
80-
import { Configuration, ApiClient } from "@tikhub/tikhub-api-ts-sdk";
59+
import { Configuration } from "@tikhubio/tikhub-api-ts-sdk";
8160

8261
// Create an API configuration instance
8362
const config = new Configuration({
8463
basePath: "https://api.tikhub.io", // ✅ Set API base URL
85-
apiKey: "YOUR_API_KEY", // ✅ Set API Key for authentication
64+
accessToken: "YOUR_API_KEY", // ✅ Set API Key for authentication
8665
});
8766

88-
// Create the API client instance
89-
const client = new ApiClient(config);
90-
91-
console.log("TikHub API Client initialized!");
67+
console.log("TikHub API Client Config initialized!");
9268
```
9369

9470
📌 **Replace `YOUR_API_KEY`** with your actual API key.
@@ -102,27 +78,27 @@ console.log("TikHub API Client initialized!");
10278
Fetch videos associated with a given hashtag.
10379

10480
```typescript
105-
import { TikTokAppV3APIApi } from 'tikhub-api-sdk';
81+
import { TikTokAppV3APIApi } from '@tikhubio/tikhub-api-ts-sdk';
10682

10783
const api = new TikTokAppV3APIApi(config);
10884

109-
async function fetchHashtagVideos() {
110-
try {
111-
const response = await api.fetchHashtagVideoListApiV1TiktokAppV3FetchHashtagVideoListGet('dance', 0, 10);
112-
console.log('Hashtag Video List:', response.data);
113-
} catch (error) {
114-
console.error('Error fetching hashtag videos:', error);
115-
}
85+
async function fetchUserProfile() {
86+
try {
87+
const response = await api.handlerUserProfileApiV1TiktokAppV3HandlerUserProfileGet_52('', 'MS4wLjABAAAAv7iSuuXDJGDvJkmH_vz1qkDZYo1apxgzaxdBSeIuPiM', '', '');
88+
console.log('User Profile Info:', response.data);
89+
} catch (error) {
90+
console.error('Error fetching User profile info:', error);
91+
};
11692
}
11793

118-
fetchHashtagVideos();
94+
fetchUserProfile();
11995
```
12096

12197
🔹 **Parameters:**
12298

123-
* `chId`: Hashtag ID (string)
124-
* `cursor`: Pagination cursor (default: `0`)
125-
* `count`: Number of results to fetch (default: `10`)
99+
* `userId`: User ID (string) Optional
100+
* `secUserId`: Secondary User ID (string) Optional
101+
* `uniqueId`: Unique ID (string) Optional
126102

127103
---
128104

@@ -131,20 +107,20 @@ fetchHashtagVideos();
131107
Retrieve TikTok's recommended videos based on cookies.
132108

133109
```typescript
134-
import { TikTokAppV3APIApi, TikTokAppV3HomeFeed } from 'tikhub-api-sdk';
110+
import { TikTokAppV3APIApi, TikTokAppV3HomeFeed } from '@tikhubio/tikhub-api-ts-sdk';
135111

136112
const api = new TikTokAppV3APIApi(config);
137113

138114
async function fetchHomeFeed() {
139-
try {
140-
const requestBody: TikTokAppV3HomeFeed = {
141-
cookie: 'your_tiktok_cookie_here',
142-
};
143-
const response = await api.fetchHomeFeedApiV1TiktokAppV3FetchHomeFeedPost(requestBody);
144-
console.log('Home Feed:', response.data);
145-
} catch (error) {
146-
console.error('Error fetching home feed:', error);
147-
}
115+
try {
116+
const TikTokAppV3HomeFeed = {
117+
cookie: 'your_tiktok_cookie_here',
118+
};
119+
const response = await api.fetchHomeFeedApiV1TiktokAppV3FetchHomeFeedPost(TikTokAppV3HomeFeed);
120+
console.log('Home Feed:', response.data);
121+
} catch (error) {
122+
console.error('Error fetching home feed:', error);
123+
}
148124
}
149125

150126
fetchHomeFeed();
@@ -161,7 +137,7 @@ fetchHomeFeed();
161137
Retrieve TikTok user profile information.
162138

163139
```typescript
164-
import { TikTokAppV3APIApi } from 'tikhub-api-sdk';
140+
import { TikTokAppV3APIApi } from '@tikhubio/tikhub-api-ts-sdk';
165141

166142
const api = new TikTokAppV3APIApi(config);
167143

package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
{
2-
"name": "@tikhub/tikhub-api-ts-sdk",
2+
"name": "@tikhubio/tikhub-api-ts-sdk",
33
"version": "1.0.0",
4-
"description": "OpenAPI client for @tikhub/tikhub-api-ts-sdk",
4+
"description": "OpenAPI client for @tikhubio/tikhub-api-ts-sdk",
55
"author": "OpenAPI-Generator Contributors",
66
"keywords": [
77
"axios",
88
"typescript",
99
"openapi-client",
1010
"openapi-generator",
11-
"@tikhub/tikhub-api-ts-sdk"
11+
"tikhubio",
12+
"sdk",
13+
"crawler",
14+
"api",
15+
"tikhub-api-ts-sdk",
16+
"@tikhubio/tikhub-api-ts-sdk"
1217
],
1318
"license": "Unlicense",
1419
"main": "./dist/index.js",
@@ -25,6 +30,7 @@
2530
"typescript": "^3.6.4"
2631
},
2732
"publishConfig": {
33+
"access": "public",
2834
"registry": "https://registry.npmjs.org/"
2935
}
30-
}
36+
}

0 commit comments

Comments
 (0)