Using GoPUP: A Python Library for Easy Access to Public Data APIs
This article introduces the GoPUP Python library, explains how to install it, demonstrates retrieving Weibo index data with code examples, shows how to visualize the results using Pandas, Jupyter and Matplotlib, and lists the wide range of public data APIs the library supports.
Hello everyone, I’m Cui Qingcai. Happy National Day! Besides holiday fun, I spent some time learning and want to share a useful tool.
Introduction
The library is called GoPUP (GitHub: https://github.com/justinzm/gopup). It wraps many public APIs, for example the wx_hot_list method to get real‑time WeChat hot article rankings.
Basic Usage
Install the library with pip:
pip3 install gopupUpgrade later with:
pip3 install -U gopupAfter installation you can import the library and call its methods. The example below shows how to fetch the Weibo index for a keyword.
import gopup as gp
df_index = gp.weibo_index(word="疫情", time_type="3month")
print(df_index)The weibo_index API requires two parameters:
Name
Type
Required
Description
word
str
Y
Keyword
time_type
str
Y
One of "1hour", "1day", "1month", "3month"
The output parameters are:
Name
Type
Default
Description
date
datetime
Y
Date index
index
float
Y
Index value
The result is a Pandas DataFrame, e.g.:
疫情 index
2022-07-04 1518338
2022-07-05 1950590
... ...
[93 rows x 1 columns]To view it more clearly you can run the code in a Jupyter notebook:
pip3 install jupyter
jupyter notebookVisualization example using Matplotlib:
import matplotlib.pyplot as plt
plt.figure(figsize=(15,5))
plt.title("微博‘疫情’热度走势图")
plt.xlabel("时间")
plt.ylabel("指数")
plt.plot(df_index.index, df_index['疫情'], '-', label="指数")
plt.legend()
plt.grid()
plt.show()The chart displays the trend of the keyword’s popularity over time.
More Data Sources
GoPUP aggregates many public APIs, covering categories such as:
Index data: Weibo, Baidu, Google, etc.
Statistical data: regional, city, age, gender analyses.
Macro data: Chinese macro‑economic indicators, exchange rates.
Interest rate data: SHIBOR, LPR.
Company data: unicorns, bankruptcies.
Information data: news scripts.
Life data: oil prices, fuel price history.
Poetry data: Tang dynasty poems.
Film & TV data: box office, viewership indices.
University data: lists of Chinese higher‑education institutions.
Pandemic data: NetEase, DingXiangYuan, etc.
For a full list see the official documentation: http://doc.gopup.cn/#/README.
With GoPUP you can skip writing crawlers and directly use ready‑made datasets for analysis and visualization.
That’s all for GoPUP – give it a try!
Sohu Tech Products
A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.