Skip to main content

Cliente Python para integraciones con la API GraphQL de Monday.com

Project description

cartagon-monday-client

Cliente Python para integraciones con la API GraphQL de Monday.com.
Proporciona una capa de alto nivel sobre GraphQL con:

  • Manejo automático de reintentos:
    • HTTP 5xx, 403
    • 401/404 transitorios
    • Errores de complejidad (COMPLEXITY_BUDGET_EXHAUSTED) respetando retry_in_seconds cuando está disponible
  • Paginación automática con items_pagenext_items_page
  • Utilidades de alto nivel para crear, actualizar y consultar ítems, subítems, usuarios y notificaciones
  • Validación de tipos antes de llamar a la API

Requisitos: Python 3.10+


pip install cartagon-monday-client

Importación:

from monday_client import MondayClient

token = "TU_API_TOKEN"
client = MondayClient(api_key=token)

# 1) Probar conexión
print(client.test_connection())  # True si el token es válido

# 2) Listar tableros
boards = client.get_boards(limit=5, page=1)
for b in boards:
    print(f"{b['id']}: {b['name']}")

# 3) Obtener todos los ítems de un tablero (paginación automática)
items = client.get_all_items(board_id=123456789, limit=100)
print("Total ítems:", len(items))

# 4) Obtener ítems incluyendo subítems
items = client.get_all_items(
    board_id=123456789,
    subitems="subitems { id name column_values { value } }"
)

# 5) Crear un ítem
item = client.create_item(
    board_id=123456789,
    item_name="Tarea de ejemplo",
    columns=[
        {"id": "status", "type": "status", "value": "Working on it"},
        {"id": "date", "type": "date", "value": {"date": "2025-09-25"}}
    ]
)
print("Ítem creado:", item)

# 6) Crear un subítem
subitem = client.create_subitem(
    parent_item_id=987654321,
    subitem_name="Subtarea",
    columns=[{"id": "text", "type": "text", "value": "Detalle"}]
)

# 7) Actualizar columnas
client.update_simple_column_value(
    item_id=987654321,
    board_id=123456789,
    column_id="text_column",
    value="Texto actualizado"
)

client.update_multiple_column_values(
    item_id=987654321,
    board_id=123456789,
    columns=[
        {"id": "status", "type": "status", "value": "Done"},
        {"id": "priority", "type": "dropdown", "value": ["High"]}
    ]
)

# 8) Obtener usuarios
users = client.get_users(limit=10)
print("Usuarios:", len(users))

# 9) Enviar una notificación
client.send_notifications(
    user_id=12345,
    target_id=987654321,
    target_type="Post",
    text="Revisa este ítem 👀"
)

# 10) Obtener el tablero padre de un ítem
board_id = client.get_parent_board(item_id=987654321)

API de MondayClient

execute_query(query: str, *, return_key: str | None = None, variables: dict | None = None, timeout: float | None = None, log_query_preview: bool = False) -> dict

Ejecuta una query/mutación GraphQL y devuelve data (o data[return_key]).


test_connection() -> bool

Consulta me y devuelve True si la API responde con un usuario válido.


get_boards(limit: int = 10, page: int = 1, fields: list[str] | str | None = None) -> list[dict]

Devuelve tableros con paginación simple.

  • fields por defecto: ["id","name","workspace_id","state","board_kind"].

get_all_items(board_id: int, limit: int = 50, *, fields: list[str] | str | None = None, columns_ids: list[str] | None = None, subitems: str | None = None, get_group: bool = False) -> list[dict]

Devuelve todos los ítems de un tablero, paginando con cursor.

  • Si fields es None, usa id, name y column_values { ALL_COLUMNS_FRAGMENT }.
  • Si columns_ids se pasa, aplica filtro ids:[...] en column_values.
  • Si subitemsse usa, añada un bloque GraphQL de subitems a la query
  • Si get_group= True se devuelve id y titulo del grupo al que pertenece el item

create_item(board_id: int, item_name: str, *, group_id: str | None = None, columns: list[dict] | dict | None = None, fail_on_duplicate: bool = True, create_labels_if_missing: bool = True, return_fields: list[str] | str | None = None) -> dict

Crea un ítem.

  • Acepta columns en bruto y los normaliza con create_column_values.
  • return_fields: por defecto "id".

create_subitem(parent_item_id: int, subitem_name: str, *, columns: list[dict] | dict | None = None, fail_on_duplicate: bool = True, create_labels_if_missing: bool = True, return_fields: list[str] | str | None = None) -> dict

Crea un subítem bajo un ítem padre.

  • Acepta columns en bruto o dict ya renderizado.
  • return_fields: por defecto "id".

update_simple_column_value(item_id: int, board_id: int, column_id: str, value: str, *, return_fields: list[str] | str | None = None) -> dict

Actualiza una columna simple.

  • value es obligatorio; usa "" para limpiar.
  • Si la columna espera JSON, pásalo serializado como string (ej: '{"date":"2025-09-25"}').

update_multiple_column_values(item_id: int, board_id: int, columns: list[dict] | dict, *, fail_on_duplicate: bool = True, create_labels_if_missing: bool = True, return_fields: list[str] | str | None = None) -> dict

Actualiza varias columnas en un único llamado.

  • Normaliza columns con create_column_values.
  • Internamente hace doble json.dumps para column_values.

get_items_by_column_value(board_id: int, column_id: str, value: str, fields: list[str] | None = None, operator: str = "any_of", limit: int = 200) -> list[dict]

Filtra ítems por valor en una columna, con query_params.rules.

  • Pagina con cursor hasta agotar resultados.
  • Soporta operadores: any_of, not_any_of, is_empty, contains_text, greater_than, between, etc.

get_item(item_id: int, subitmes:str | None = None, columns_ids: list[str] | None = None, get_group: bool = False) -> dict

Obtiene un ítem por ID.

  • Limita columnas si pasas columns_ids. -Obtiene subitems si se le pasa subitems
  • Si get_group= True se devuelve id y titulo del grupo al que pertenece el item

Otras utilidades

  • board_columns(board_id: int): devuelve columnas de un board.
  • item_columns(item_id: int): columnas de un ítem.
  • subitems_columns(board_id: int): columnas de subitems de un board.
  • delete_item(item_id: int): elimina un ítem.
  • create_item_update(item_id: str, body: str, mention_user: list[dict] = []): crea un update en un ítem.
  • create_column_values(columns: list[dict], fail_on_duplicate: bool = True) -> dict: helper para normalizar column_values.
  • get_users(limit: int = None, page: int | str None, fields: str = None) -> dict: devuelve usuarios.
  • get_parent_board(self, item_id: int | str) -> int | str: Devuelve el id del tablero al que petenece un item
  • send_notification(self, user_id: int | str, target_id: int | str, target_type: str, text: str ) -> str:: Envia una notificación al usuario objetivo

Manejo de errores

  • Errores retriables: HTTP 5xx, 403, 401/404 transitorios, ComplexityException.
  • Errores no retriables: otros GraphQL (ej. InvalidBoardIdException).
  • Si se agotan reintentos → MondayAPIError().

Licencia

MIT — ver archivo LICENSE.


Enlaces

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

cartagon_monday_client-1.0.3.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

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

cartagon_monday_client-1.0.3-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file cartagon_monday_client-1.0.3.tar.gz.

File metadata

  • Download URL: cartagon_monday_client-1.0.3.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for cartagon_monday_client-1.0.3.tar.gz
Algorithm Hash digest
SHA256 2b0e1b61613f2b5ca95c0416d0c2c30eecec467a51bd1910f1cb4183b2387681
MD5 6749bbca0f6bfd8a2caa22fc79bae7fd
BLAKE2b-256 a48ba5f0b107f44491aa44430aad6443c68aa65fd5b141016d08f45ec0438712

See more details on using hashes here.

File details

Details for the file cartagon_monday_client-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for cartagon_monday_client-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8fa9a25c0eb038e42769b0bd3fdc0c2b3aebe5525ef15f1469d7c4ce015377c8
MD5 ed5b4579848b6a7af70d763fc1a7706f
BLAKE2b-256 d50fe368eaabe96f4cfc0261e8b11f72d4f58b5bac201869e2e8a4041e24ddd9

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