Viki

Viki 写东西的地方

努力上进且优秀
github
email
x
steam
bilibili
douban

Understand the World API in 60 seconds every day

Background#

Recently, I was quite interested in playing with QQ bots and often integrated data with third-party APIs, using the oicq protocol library to implement some simple but meaningful functions, having fun with group friends.

A representative example is "Understand the World in 60 Seconds". Ten or so short hot news items are delivered daily. Although the function is simple, the content is meaningful, especially for kids like us who never read the news.

Why Do It Yourself#

Unfortunately, many website APIs are not stable enough, intermittently going down or directly shutting down. So I did a Google search and found that the data sources for most interfaces point to this Understand the World in 60 Seconds Zhihu column.

How It Was Done#

After some fierce operations (to put it simply, just a simple JSON GET request, no encryption, cross-origin, request header restrictions, etc., press F12 and the interface pops up), I found its column data interface:

https://www.zhihu.com/api/v4/columns/c_1261258401923026944/items

Optional parameters for this API's URL:

  • limit Number of data items to return
  • offset Pagination parameter

After obtaining the data, in order to quickly create a high-performance, low-latency API with caching capabilities, I chose deno and deployed it using Deno Deploy, setting it to only return data for the current day on each request. Additionally, I set up request caching, meaning that only one request is sent to Zhihu per day. From the second request onwards, the cache is used directly, speeding up API response time and reducing the load on Zhihu servers.

How to Use This#

Here is a deployed API address that you can use directly:

=== Update July 2024 ===

Version 2 has been released, standardizing the JSON response. Feel free to use:
https://60s.viki.moe?v2=1

Check out the source code at vikiboss/60s - GitHub, feel free to deploy it yourself or star it~

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.