Skip to main content

HTTP SDK for querying pipeline data service

Project description

pipeline-http-sdk

定位

pipeline-http-sdkpipeline-http-service 的 Python 客户端,提供接近 Tushare 的调用体验,返回 pandas.DataFrame

安装

pip install pipeline-http-sdk

快速开始

import pipeline_sdk as ts

ts.set_token("your-token")
pro = ts.pro_api(base_url="http://127.0.0.1:8000")

df = pro.stock_basic(
    fields="ts_code,name,list_date",
    order_by="list_date",
    sort="desc",
    limit=20,
)
print(df.head())

核心接口

统一查询:

df = pro.query(
    "stock_basic",
    ts_code="000001.SZ",
    fields=["ts_code", "name", "list_date"],
    order_by="list_date",
    sort="desc",
    limit=200,
    offset=0,
)

动态方法(等价于 query):

df = pro.stock_basic(ts_code="000001.SZ", limit=50)

获取 API 列表:

apis = pro.list_apis(enabled_only=True)

核心能力

  • set_token() + pro_api() 初始化
  • pro.query(...) 统一查询
  • pro.xxx(...) 动态 API 调用
  • pro.list_apis(...) 拉取可用接口

参数约定

  • 支持普通参数和列表参数
  • 支持分页:limit / offset
  • 支持排序:order_by / sortascdesc
  • 参数语义由服务端解释

异常处理

HTTP 或业务错误会抛出 PipelineSDKError

from pipeline_sdk import PipelineSDKError

try:
    df = pro.query("stock_basic", limit=10)
except PipelineSDKError as exc:
    print("message:", exc)
    print("code:", exc.code)
    print("detail:", exc.detail)

常见错误消息:

  • unauthorized(401)
  • 其它服务端 message(统一透传)

开发与发布

python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*

更多发布步骤:docs/PYPI_PUBLISH.md

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

pipeline_http_sdk-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

pipeline_http_sdk-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pipeline_http_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: pipeline_http_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for pipeline_http_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15b4800e3222c218a7056bb33653b9d7852fd99a1b1255f2259cd1c19e1ab8d8
MD5 be183f937a91c33ab8e159c14457e6a4
BLAKE2b-256 6416960f8ff2ccccf1b2607f59052383e0953482dfe98e8db5d3b5f779968b85

See more details on using hashes here.

File details

Details for the file pipeline_http_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pipeline_http_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6670345b17ac7a72034b3648ddde758b7a3b471e5c574b44c5c7cb9de3359914
MD5 3260a36f6d274633b9ba280742d48319
BLAKE2b-256 3412350911b5b38f8a7c7397a20abcd9793899c8798996a74cbf24f0edcf6da4

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