Skip to main content

浙江社保医保税务参保一件事

开发中。对接浙江政务服务网受理平台的单人职工参保登记和职工参保暂停。SDK 支持按指定方式登录并返回单位会话。业务客户端可以复用该会话、调用方已有会话或自定义发送器。

安装和导入

独立发行包名为 zhejiang-social-security。安装已构建的 wheel 后,从 zhejiang_social_security 导入。它依赖 requests 和账密登录使用的 gmalg。

python -m pip install zhejiang_social_security-0.3.1-py3-none-any.whl
from zhejiang_social_security import ReceptionContext, ZhejiangClient

使用地区总包 regional-social-security 时,安装 [zhejiang] 登录依赖并从该包的浙江入口导入。

from regional_social_security.zhejiang import ReceptionContext, ZhejiangClient

从仓库根目录构建浙江独立包,构建环境需安装 build。

python scripts/build_zhejiang_sdk.py --outdir dist

法人账密登录

from zhejiang_social_security import PasswordCredentials, ReceptionContext, ZhejiangClient, login_session

with login_session(
    "password",
    PasswordCredentials(username, password),
    matter_id=entry_matter_id,
    captcha_provider=read_captcha,
    sms_code_provider=read_sms_code,
) as session:
    client = ZhejiangClient(session=session)
    page = client.get_reception(ReceptionContext(entry_matter_id))

read_captcha 接收当次图片的字节并返回经办人填写的验证码。站点要求短信验证时,read_sms_code 接收站点提供的号码提示并返回六位短信验证码。缺少所需输入或站点提示处理电子印章时,SDK 返回 SDKError(kind="verification")。受理平台确认已登录后才返回会话。调用方也可以通过 session= 传入预配置代理的 HTTP 会话。账密、短信和受理会话的流程已用模拟响应测试,真实法人账号的跨站回跳待验证。

调用接口

client = ZhejiangClient(session=unit_http_session)
entry = ReceptionContext(matter_id=entry_matter_id)
page = client.get_reception(entry)
context = ReceptionContext(entry_matter_id, page["sequenceNo"])
scene = client.get_reception(context, view_id="SceneGuide")

matter_id 来自办理入口的父事项。每张新办件先读取站点返回的 sequenceNo,后续使用同一办件流水和单位会话。根据响应的 next 和页面条件推进,提交场景时使用当前页面给出的选项编码。增员抓包中的场景曾同时选中人社参保、医保参保和年度工资申报,需要按实际办理范围选择。

方法 请求与结果
get_reception 读取 /matter/reception 的页面数据和流转步骤,通知、办理条件、办理情形和确认页共用此接口。
check_scene_condition 按情形配置发送 SceneGuideConditionCheck,返回 checkSuccess。为 False 时停止。
submit_scene 发送 SubmitSceneGuide,响应保留 selectedSubMatters 和后续步骤。
get_form_schema 读取 /form/formrender,解码内层 formSchema,保留字段和动态请求配置。
run_form_script 发送 propertiesAsyncDatashare、commonAsyncDatashare 或 processFormData。传表单配置中的 scriptId、requestId 和当前业务参数,返回内层 data。若内层带 success 等状态,调用方按对应数据源处理。
removal_reason_options 查询当前暂停参保的动态原因字典,按站点顺序返回 tuple[Option, ...]。例如 6322 对应「劳动合同期满终止」,用于表单字段 self.ZPYY22。
submit_form 发送 FormSubmit。传页面构造的平铺字段及草稿配置 JSON 字符串 draft_schema,响应给出后续步骤。草稿配置由表单渲染生成。
submit_order 确认页面的材料与校验要求办妥后,显式调用 SubmitOrder。一次调用发送一次;执行成功后根据后续步骤查办件结果。
get_result 读取 Result 视图,返回原始业务数据。现场回执及办结字段尚待核对。

接口分步调用。调用方按页面配置完成现场校验、草稿渲染及有条件的材料步骤后,再调用正式提交。动态数据源参数随表单不同,SDK 保留其字段和类型。异常使用 SDKError.kind、step、code 区分输入、业务、HTTP、协议、会话和传输错误。表单送交或正式申报收到超时或无法确认结果的响应时返回 kind="unknown",请先通过办件查询核对结果再决定是否重提。

证据见 源码对照。增员 HAR 实录到 FormConfirm,减员 HAR 实录到表单校验。最终提交及结果页流转依据是归档 InfoConfirm.js,模拟测试核对请求及错误处理。生产办件回执、减员提交的完整表单和最终业务状态待现场验证。

Metadata

Release files for zhejiang-social-security 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zhejiang-social-security 0.3.1
File Size Uploaded Provenance Actions
zhejiang_social_security-0.3.1.tar.gz 23.9 kB Without provenance Details for zhejiang_social_security-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zhejiang-social-security 0.3.1
File Interpreter ABI Platform Actions
zhejiang_social_security-0.3.1-py3-none-any.whl Python 3 none any Details for zhejiang_social_security-0.3.1-py3-none-any.whl

Total release size: 50.4 kB

Release files / zhejiang_social_security-0.3.1.tar.gz

Download URL zhejiang_social_security-0.3.1.tar.gz
Size 23.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a86e6988bcc7a982953562f116ac4321eeeadc3b6700600d9c3f5a4562cd448b
BLAKE2b-256 checksum
How to use checksums
5bcd084c73348d60d5b31074f5daa140aa473b4224e523af7f1da9b35afef65b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Release files / zhejiang_social_security-0.3.1-py3-none-any.whl

Download URL zhejiang_social_security-0.3.1-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2a8fbf054f79b131a124bfc4f07e6648bc03dcfafad666879904c231652deb8
BLAKE2b-256 checksum
How to use checksums
98d9523eaa159fc547c6e315ea1f89d550ae002e793058f36ff08b7711647e57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.2

Security for zhejiang-social-security 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page