Skip to main content

简书非官方 SDK - 创造可能性

Project description

JKit

许可证 PyPI 版本 支持的 Python 版本

静态分析 Ruff 类型检查 代码风格 Ruff

创造可能性。

[!WARNING] JKit v3 正在 Beta 测试中,可能随时进行重大变更。

[!WARNING] JKit 为非官方 SDK,可能因相关 API 变动导致功能异常。

功能

  • 简书文章 / 用户 / 专题 / 文集标识符(ID / Slug / URL)校验与转换
  • 获取简书文章、用户、专题、文集数据
  • 获取简书资产数据、钻贝变动记录、持钻奖励数据、收益加成卡数据
  • 获取简书会员分销链接
  • 钻贝互转
  • 获取简书积分兑换平台贝市场订单数据
  • 获取贝交易平台贝市场订单数据

(部分功能需要鉴权凭证)

安装

JKit 需要 Python 3.9 及以上版本。

PyPy 等其它 Python 实现可能运行,但不受支持。

pip install jkit

快速上手

JKit 仅支持异步操作。

import asyncio

from jkit.user import User


async def main() -> None:
    user = User.from_slug("ea36c8d8aa30")

    info = await user.info

    print(f"ID:{info.id}")
    print(f"URL:{user.url}")
    print(f"昵称:{info.name}")


asyncio.run(main())
ID:19867175
URL:https://www.jianshu.com/u/ea36c8d8aa30
昵称:初心不变_叶子

获取凭证

简书

目前仅支持从电脑端获取凭证。

在浏览器中登录简书账号。

打开开发者工具(DevTools)- 存储(Storages)选项卡- Cookie,remember_user_token 对应的值即为凭证。

使用示例:

import asyncio

from jkit.credentials import JianshuCredential
from jkit.private.assets_wallet import AssetsWallet

TOKEN = "<YOUR_TOKEN>"


async def main() -> None:
    credential = JianshuCredential.from_remember_user_token(TOKEN)
    assets_wallet = AssetsWallet(credential=credential)

    print(await assets_wallet.assets_info)


asyncio.run(main())
AssetsInfoData(
    fp_amount=Decimal('88987.0378258294950'),
    ftn_amount=Decimal('7860.19387826272668'),
    assets_amount=Decimal('96847.2317040922062'),
    converting_fp_amount=Decimal('8.46199999999999974')
)

贝交易平台

在浏览器中登录贝交易平台账号。

打开开发者工具(DevTools)- 控制台(Console)选项卡,执行以下代码:

JSON.parse(window.localStorage.app_user_token).token

输出内容即为凭证。(不包含引号)

使用示例:

import asyncio

from jkit.beijiaoyi.ftn_market import FtnMarket
from jkit.credentials import BeijiaoyiCredential

TOKEN = "<YOUR_TOKEN>"


async def main() -> None:
    credential = BeijiaoyiCredential.from_bearer_token(TOKEN)
    ftn_market = FtnMarket(credential=credential)

    async for item in ftn_market.iter_orders(type="BUY"):
        print(item)
        return


asyncio.run(main())
OrderData(
    id=1893596965401399296,
    price=0.046,
    total_amount=10000,
    traded_amount=0,
    remaining_amount=10000,
    minimum_trade_amount=1000,
    maximum_trade_amount=None,
    completed_trades_count=0,
    publish_time=datetime.datetime(2025, 2, 23, 17, 41, 12),
    supported_payment_channels=('WECHAT_PAY', 'ALIPAY'),
    publisher_info=_PublisherInfoField(
        id=3513,
        name='eQn8ME9fnt',
        avatar_url='https://testapi.beijiaoyi.com/Upload/headimg/13.png'
    )
)

Project details


Download files

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

Source Distribution

jkit-3.0.0b5.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jkit-3.0.0b5-py3-none-any.whl (37.1 kB view details)

Uploaded Python 3

File details

Details for the file jkit-3.0.0b5.tar.gz.

File metadata

  • Download URL: jkit-3.0.0b5.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for jkit-3.0.0b5.tar.gz
Algorithm Hash digest
SHA256 f808751b6206e35149eb2837dc002b28a21c470d1b5a70a58715facf03baad0d
MD5 39ed53d42b170064a94d381a932704a7
BLAKE2b-256 14531642aef56339f1a0c7cc71e6d502079e144e16fd0196cc4aff7711bb0ed7

See more details on using hashes here.

File details

Details for the file jkit-3.0.0b5-py3-none-any.whl.

File metadata

  • Download URL: jkit-3.0.0b5-py3-none-any.whl
  • Upload date:
  • Size: 37.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for jkit-3.0.0b5-py3-none-any.whl
Algorithm Hash digest
SHA256 e4fbbc16748be6e9650f6380d0490be0fa3bca9926b4d8b9702197a6233a8a11
MD5 08cd96c22c2cf060e4e389ec9e76e3d6
BLAKE2b-256 c5f80e749c24b2ef7f5d41dcd8baa7e79b94a37536562cc63e91959e56948cd0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page