Skip to main content

Python SDK for Weibo API

Project description


Version Download License Status

Python SDK for Weibo API.



pip install pyweibo


  1. Register the Sina Weibo account, and establish a new app in

  2. Get App Key and App Secret from 应用信息 -> 基本信息

  3. Set Redirect URI in 应用信息 -> 高级信息 -> OAuth2.0授权设置 as:



Basic usage

from pyweibo import Auth
auth = Auth()

When running, you need to manually input App Key and App Token:

App Key: <Your App Key>
App Secret: <Your App Secret>

Next the web browser will automatically open the redirect uri.

Copy the uri to the console, and the token will be generated:

Input the url or the token: <The URL or token>

Finally, the token will also be stored in ./token.json.

As for advanced usages, you can specify:

API Client

Basic usage

from pyweibo import Auth, Client

# Get the token
auth = Auth()
token = auth.token.token

# Start the client
client = Client()
data = client.statuses.home_timeline.get(access_token=token)
  • The APIs and their parameters can be referred from official docs.

  • You can access the api call like class attributes, where the last method call must be get or post.

client.api_name_1.api_name_2.get(param1=value1, param2=value2)
  • Also you can use dict index like:
client[api_name_1][api_name_2].get(param1=value1, param2=value2)
  • The return value is a TextDict, where you can access the attributes directly like:
user = data.statuses[0].user
  • Also you can upload the picture with the parameter pic:
with open('image.png', 'rb') as f:
from pyweibo import UploadClient

client = UploadClient()
with open('image.png', 'rb') as f:'Image', pic=f)



Establish new issue if there is any question or advice.





Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyweibo, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size pyweibo-0.1.2-py2.py3-none-any.whl (6.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size pyweibo-0.1.2.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page