Skip to main content

3s-cnes-client

Cliente Python assíncrono para consultar estabelecimentos, leitos e profissionais nos serviços SOAP públicos do CNES (Cadastro Nacional de Estabelecimentos de Saúde).

O pacote é exclusivamente assíncrono e usa zeep[async] para consumir os serviços SOAP.

Instalação

pip install 3s-cnes-client

Uso

import asyncio

from cnes_client import CNESClient


async def main():
    async with CNESClient() as client:
        estabelecimento = await client.estabelecimento("7869231")
        leitos = await client.leitos("4013484")
        profissionais = await client.profissionais("4013484")

        print(estabelecimento)
        print(leitos)
        print(profissionais)


asyncio.run(main())

Se preferir fechar o cliente manualmente:

from cnes_client import CNESClient

client = CNESClient()

try:
    leitos = await client.leitos("4013484")
finally:
    await client.close()

Métodos disponíveis

estabelecimento(cnes: str) -> dict

Consulta os dados completos de um estabelecimento pelo código CNES informado.

Retorno: um dicionário com o resultado completo do serviço consultarEstabelecimentoSaude, incluindo dados do estabelecimento, profissionais, leitos, habilitações, equipamentos, SAMU e sumário quando presentes no retorno do CNES.

{
  "EstabelecimentoSaude": {
    "CodigoCNES": {
      "codigo": "7869231"
    },
    "CodigoUnidade": {
      "codigo": "5105307869231"
    },
    "nomeFantasia": {
      "Nome": "CENTRAL DE REGULACAO"
    },
    "nomeEmpresarial": {
      "Nome": "PREFEITURA MUNICIPAL DE LUCIARA"
    },
    "dataAtualizacao": "2026-06-24",
    "fluxoClientela": "ATENDIMENTO DE DEMANDA REFERENCIADA"
  },
  "profissional": [],
  "leito": [],
  "habilitacao": [],
  "equipamento": [],
  "samu": [],
  "sumario": {
    "quantidadeProfissionaisSaude": 3,
    "quantidadeLeitos": 0
  }
}

leitos(cnes: str) -> list[dict]

Consulta os perfis de leitos vinculados ao código CNES informado.

Retorno: uma lista de dicionários contendo as informações de cada perfil de leito.

[
  {
    "codigo": "96",
    "descricao": "SUPORTE VENTILATORIO PULMONAR",
    "dataAtualizacao": "2026-05-18T00:00:00",
    "quantidadeLeito": 4,
    "quantidadeLeitoSUS": 4
  },
  {
    "codigo": "02",
    "descricao": "CARDIOLOGIA",
    "dataAtualizacao": "2026-05-18T00:00:00",
    "quantidadeLeito": 6,
    "quantidadeLeitoSUS": 0
  }
]

profissionais(cnes: str) -> list[dict]

Consulta os profissionais vinculados ao código CNES informado.

Retorno: uma lista de dicionários contendo o CPF e o CNS de cada profissional ligado ao CNES.

[
  {
    "CNS": "709809023050097",
    "CPF": "413******00"
  },
  {
    "CNS": "708408234337161",
    "CPF": "050******35"
  },
  {
    "CNS": "704102842163350",
    "CPF": "085******52"
  },
  {
    "CNS": "700509551692756",
    "CPF": "116******74"
  }
]

Desenvolvimento

python -m pip install -e ".[dev]"
ruff check .
mypy src
pytest
python -m build

Metadata

Release files for 3s-cnes-client 0.2.2

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

Source distribution (sdist)

Source distribution for 3s-cnes-client 0.2.2
File Size Uploaded Provenance Actions
3s_cnes_client-0.2.2.tar.gz 8.1 kB With provenance Details for 3s_cnes_client-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for 3s-cnes-client 0.2.2
File Interpreter ABI Platform Actions
3s_cnes_client-0.2.2-py3-none-any.whl Python 3 none any Details for 3s_cnes_client-0.2.2-py3-none-any.whl

Total release size: 14.1 kB

Release files / 3s_cnes_client-0.2.2.tar.gz

Download URL 3s_cnes_client-0.2.2.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
78b935d9ea96738b755ca6bd2759a02daf429c562335395ca2ff0aed5ac993c7
BLAKE2b-256 checksum
How to use checksums
5858a3186cb47ec90647c1f4e796f4d80ae1c863d2d5467d1690a430d48640e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.

Transparency log

Release files / 3s_cnes_client-0.2.2-py3-none-any.whl

Download URL 3s_cnes_client-0.2.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
820d0efc2537a7907a3c6a59fce6b079abd6781ac9df8bc1641dbcf0e2f2a4cf
BLAKE2b-256 checksum
How to use checksums
a7a689504f35b305143bdea494e3fa9b51aef6f5bd099b7ae71dd90685707023
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.

Transparency log

Security for 3s-cnes-client 0.2.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for 3s_cnes_client-0.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.

Transparency log

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.

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