Skip to content

Commit

Permalink
docs: Added README."en".md translation via https://github.com/dephrai…
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jun 1, 2024
1 parent bd5f9b5 commit 794d6ec
Showing 1 changed file with 125 additions and 17 deletions.
142 changes: 125 additions & 17 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,148 @@
<a href="https://github.com/TikHubIO/TikHub-API-Python-SDK/blob/main/README.en.md">English</a> | <a href="https://github.com/TikHubIO/TikHub-API-Python-SDK/blob/main/README.md">简体中文</a>
</div>

#### Introduction
#### **Introduction**

[TikTok](https://tikhub.io/)It is an All in one RESTful API platform.
🎉「[TikHub.io](https://tikhub.io/)"Is a**A platform for out-of-the-box integration tools and services**, our goal is to help users quickly start business and support function customization. Our vision is to form a community entrepreneurship project. A single tree cannot grow into a forest, but cooperation can lead to win-win results.**Every community member has the opportunity to integrate the functions or interfaces they write into our platform and benefit from them**. We have accumulated a large number of registered users and community users, and in order to realize this vision, we are actively planning and implementing cooperation strategies to ensure the sustainable and healthy development of the ecosystem. Welcome everyone to join us[Discord](https://discord.gg/aMEAS8Xsvz)Community.

The API we provide can only obtain public data, that is, anyone can access Douyin, TikTok, and Xiaohongshu through browsers and APPs to obtain them.
* * *

If you have any suggestions or needs, please contact us. More features are under development, so stay tuned!
#### **quick start**

* * *
[TikHub.io](https://tikhub.io/)Most of the APIs are RESTFUL, which means you only need to use basic HTTP requests to complete the call.

All APIs are written based on the OPenAPI specification, which means you can use our`openapi.json`Automatically generate any form of API documentation:

#### Authentication
<https://api.tikhub.io/openapi.json>

The interface with 🔒 in the interface document needs to carry Token in the request header before it can be called.
Of course, we have used Swagger UI by default to display our API documents. You can open the following link on the web page, then authenticate the API Token on the web page, then click on any endpoint and click`Try it out`You can test the endpoints you need. Most endpoints already carry default values ​​or demo values, which will better help you understand the required parameters of the call:

Calling these interfaces will use the remaining number of requests in your account!
<https://api.tikhub.io>

* * *

#### Buy
#### **Authentication**

> Introduction
The endpoints with the 🔒 icon in the interface document need to carry the API Token in the request header before they can be called. Calling these interfaces will use the remaining free quota or account balance in your account. At the same time, each endpoint will also be based on the email of the API Token owner. The address limits the request rate. Each endpoint has independent RPS (Requests per second). In most cases, users can request the same endpoint 5 times per second.

> Generate API Token
The steps to obtain API Token are also very simple, you only need to log in to our user backend[Stay tuned](https://tikhub.io/users/api_keys), then click on the left`API Keys`You can generate your own API Token, and at the same time, you can customize the permissions of the API Token (`Scopes`), you can also set the expiration date of the API Token (`Expire Date`), you can also manually temporarily close the API Token (`Status`)。

> Used on the API documentation web page
After you complete the above steps, you can copy your API Token, then return to our Swagger UI web page and click the green on the right side of the page`Authorize`, and then at the bottom of the pop-up window`Value`Paste the API Token in the input box to complete the authentication.

Website(🚧ing):[tikhub.io](https://tikhub.io/)
> Used in HTTP requests
API Document:[api.tikhub.io](https://api.tikhub.io/)
If you want to carry the API Token in the HTTP request, please read the format below carefully, and you need to carry an API Token in the request header.`Authorization`Field, below I will give an example of JSON as header:

Discord(Support):<https://discord.gg/kk23BGeYrJ>
{

Github:<https://github.com/TikHubIO>
"Authorization":"Bearer Your_API_Token"

Email:[[email protected]](mailto:[email protected])
}

> Remark
Please do not share your API Token, as this may cause you to lose property and other problems. We strongly recommend using a different API Token for each of your projects, and don’t forget to check the corresponding box when creating the API Token.`Scopes`, otherwise you will encounter insufficient permissions when requesting.

* * *

#### announcement
## **Use SDK**

- Install ours via PyPi[SDK](https://pypi.org/project/tikhub/)

```console
pip install tikhub
```

- Import SDK

```python
from tikhub import Client
```

- InitializeClient

```python
client = Client(base_url="https://api.tikhub.io",
api_key="YOUR_API_TOKEN",
proxies=None,
max_retries=3,
max_connections=50,
timeout=10,
max_tasks=50)
```

- Request user data example

```python
# 请求用户信息 | Request user info
user_info = await client.TikHubUser.get_user_info()
print(user_info)

# 请求用户每日使用情况 | Request user daily usage
user_daily_usage = await client.TikHubUser.get_user_daily_usage()
print(user_daily_usage)

# 计算价格 | Calculate price
price = await client.TikHubUser.calculate_price(endpoint="/api/v1/douyin/app/v1/fetch_one_video", request_per_day=100)
print(price)

# 获取阶梯式折扣百分比信息 | Get tiered discount percentage information
tiered_discount_info = await client.TikHubUser.get_tiered_discount_info()
print(tiered_discount_info)

# 获取一个端点的信息 | Get information of an endpoint
endpoint_info = await client.TikHubUser.get_endpoint_info(endpoint="/api/v1/douyin/app/v1/fetch_one_video")
print(endpoint_info)

# 获取所有端点信息 | Get all endpoints information
all_endpoints_info = await client.TikHubUser.get_all_endpoints_info()
print(all_endpoints_info)
```

- Available properties in Client

```python
# TikHub
self.TikHubUser = TikHubUser(self.client)

# Douyin
self.DouyinWeb = DouyinWeb(self.client)
self.DouyinAppV1 = DouyinAppV1(self.client)
self.DouyinAppV2 = DouyinAppV2(self.client)
self.DouyinAppV3 = DouyinAppV3(self.client)

# TikTok
self.TikTokWeb = TikTokWeb(self.client)
self.TikTokAppV2 = TikTokAppV2(self.client)
self.TikTokAppV3 = TikTokAppV3(self.client)

# Instagram
self.InstagramWeb = InstagramWeb(self.client)

# Weibo
self.WeiboWeb = WeiboWeb(self.client)
```

- use`DouyinAppV1`of`fetch_one_video`The method calls the interface to obtain single video data.

```python
# 获取单个作品数据 | Get single video data
video_data = await client.DouyinAppV1.fetch_one_video(aweme_id="7345492945006595379")
print(video_data)
```

- We have used HTTPX to asynchronously encapsulate most endpoints. If your code is executed synchronously, you can use the following code to prevent asynchronous infection.

TikHub’s API will use**Free plus paid**run in the form.
```python
# 使用asyncio.run防止异步传染到其他代码 | Use asyncio.run to prevent asynchronous infection to other code
video_data = asyncio.run(client.DouyinAppV1.fetch_one_video(aweme_id="7345492945006595379"))
print(video_data)
```

After logging in, you can get 50-100 API requests randomly by checking in, and you can check in once every 24 hours.
- Due to the limited chapters, the complete methods are not listed here. You can view the methods implemented in each attribute by viewing the source code, and the parameters accepted by each method have been added.`type hints`

0 comments on commit 794d6ec

Please sign in to comment.