contafi.api_client.client package
Submodules
contafi.api_client.client.bhe module
Client for managing received Electronic Fee Receipts (BHE).
- class contafi.api_client.client.bhe.Bhe
Bases:
ApiBase
Module for managing received Electronic Fee Receipts (BHE).
Provides methods for listing, retrieving, observing, and downloading received BHEs.
- Parámetros:
api_token (str) – User authentication token. If not provided, it will be retrieved from an environment variable.
api_url (str) – Base URL of the API. If not provided, a default URL will be used.
api_version (str) – API version to use. If not specified, the default version will be used.
api_raise_for_status (bool) – Whether to raise an exception automatically for HTTP error responses (default: True).
- datos(emisor, numero)
Retrieve the details of a specific received BHE.
- Parámetros:
emisor (str) – RUT of the BHE issuer (without dots, includes DV).
numero (int) – BHE document number.
- Devuelve:
JSON response containing the BHE data.
- Tipo del valor devuelto:
dict
- listar(filtros=None)
List received Electronic Fee Receipts (BHEs) with optional filters.
Fetches a paginated list of received BHEs based on the given filters.
- Parámetros:
filtros (dict) – Optional filters to apply to the query.
- Devuelve:
JSON response containing the list of received BHEs.
- Tipo del valor devuelto:
dict
- listar_emisores(nuevos)
List all BHE issuers, optionally filtering by newly added ones.
- Parámetros:
nuevos (str) – Indicates if only issuers who sent a BHE for the first time in the period should be returned.
- Devuelve:
JSON response containing the list of issuers.
- Tipo del valor devuelto:
dict
- observar(emisor, numero, body)
Submit an observation to a previously received BHE.
- Parámetros:
emisor (str) – RUT of the BHE issuer (without dots, includes DV).
numero (int) – BHE document number.
body (dict) – Dictionary containing the observation data (e.g., reason).
- Devuelve:
JSON response with the updated BHE status.
- Tipo del valor devuelto:
dict
- pdf(emisor, numero, filtros=None)
Download the PDF of a specific received BHE.
- Parámetros:
emisor (str) – RUT of the BHE issuer (without dots, includes DV).
numero (int) – BHE document number.
filtros (dict) – Optional filters (e.g., options for download format).
- Devuelve:
PDF file as a byte stream.
- Tipo del valor devuelto:
bytes
contafi.api_client.client.bte module
Client for managing issued Third-Party Electronic Receipts (BTEs).
- class contafi.api_client.client.bte.Bte
Bases:
ApiBase
Module for managing issued Third-Party Electronic Receipts (BTEs).
This class provides methods for issuing, retrieving, canceling, and calculating BTEs, as well as listing related receivers.
- Parámetros:
api_token (str) – User authentication token. If not provided, it will be read from an environment variable.
api_url (str) – Base API URL. If not provided, a default will be used.
api_version (str) – API version. If not provided, a default version will be used.
api_raise_for_status (bool) – Whether to raise an exception on HTTP error responses. Defaults to True.
- anular(numero, body)
Cancel a previously issued BTE.
- Parámetros:
numero (int) – BTE document number to cancel.
body (dict) – Dictionary containing cancellation data (e.g., reason).
- Devuelve:
JSON response with the canceled BTE data.
- Tipo del valor devuelto:
dict
- calcular_monto_bruto(liquido, periodo)
Calculate the gross amount (monto bruto) from a net amount.
- Parámetros:
liquido (int) – Net amount to convert.
periodo (str) – Period used for the conversion.
- Devuelve:
JSON response with the calculated gross value.
- Tipo del valor devuelto:
dict
- calcular_monto_liquido(bruto, periodo)
Calculate the net amount (monto líquido) from a gross amount.
- Parámetros:
bruto (int) – Gross amount to convert.
periodo (str) – Period used for the conversion.
- Devuelve:
JSON response with the calculated net value.
- Tipo del valor devuelto:
dict
- datos(numero)
Retrieve the data of a specific issued BTE.
- Parámetros:
numero (int) – BTE document number.
- Devuelve:
JSON response with the BTE data.
- Tipo del valor devuelto:
dict
- emitir(body)
Issue a new BTE.
- Parámetros:
body (dict) – Dictionary containing the BTE data to be issued.
- Devuelve:
JSON response with the issued BTE.
- Tipo del valor devuelto:
dict
- html(numero)
Retrieve the HTML representation of a specific BTE.
- Parámetros:
numero (int) – BTE document number.
- Devuelve:
HTML content of the BTE as bytes.
- Tipo del valor devuelto:
bytes
- listar(filtros=None)
Retrieve a paginated list of issued BTEs.
- Parámetros:
filtros (dict) – Optional filters to apply (e.g., by period, RUT).
- Devuelve:
JSON response containing the list of issued BTEs.
- Tipo del valor devuelto:
dict
- listar_receptores()
List all receivers associated with issued BTEs.
- Devuelve:
JSON response containing receiver information.
- Tipo del valor devuelto:
dict
- pdf(numero)
Retrieve the PDF file of a specific BTE.
- Parámetros:
numero (int) – BTE document number.
- Devuelve:
PDF file of the BTE as bytes.
- Tipo del valor devuelto:
bytes
contafi.api_client.client.contribuyentes module
Client for managing taxpayers, including roles and permissions.
- class contafi.api_client.client.contribuyentes.Contribuyentes
Bases:
ApiBase
Module for managing taxpayers in ContaFi, including roles and permissions.
Provides methods for querying taxpayer data, managing authorized users, and modifying role-based permissions.
- Parámetros:
api_token (str) – User authentication token. If not provided, it will be read from an environment variable.
api_url (str) – Base API URL. If not provided, a default will be used.
api_version (str) – API version to use. If not specified, a default version will be used.
api_raise_for_status (bool) – Whether to raise an exception on HTTP error responses. Defaults to True.
- agregar_permiso_rol(body)
Add one or more permissions to a role.
- Parámetros:
body (dict) – Dictionary with role ID and permissions to add.
- Devuelve:
JSON response with the updated role.
- Tipo del valor devuelto:
dict
- agregar_usuario_autorizado(body)
Authorize a user for the taxpayer with a specific role.
- Parámetros:
body (dict) – Dictionary containing username and role to assign.
- Devuelve:
JSON response with the authorized user information.
- Tipo del valor devuelto:
dict
- datos(rut)
Retrieve taxpayer information based on RUT.
- Parámetros:
rut (str) – Taxpayer’s RUT (without dots, includes DV).
- Devuelve:
JSON response with taxpayer details.
- Tipo del valor devuelto:
dict
- estadisticas()
Retrieve statistics for the current taxpayer (based on RUT).
- Devuelve:
JSON response containing taxpayer statistics.
- Tipo del valor devuelto:
dict
- obtener_roles()
Retrieve the list of roles available for the taxpayer.
- Devuelve:
JSON response with the role definitions.
- Tipo del valor devuelto:
dict
- quitar_permiso_rol(id_rol, permiso)
Remove a permission from a taxpayer’s role.
- Parámetros:
id_rol (int) – Unique identifier of the role.
permiso (str) – Name of the permission to remove.
- Devuelve:
JSON response with the updated role.
- Tipo del valor devuelto:
dict
- quitar_usuario_autorizado(usuario, rol)
Remove an authorized user and role from the taxpayer.
- Parámetros:
usuario (str) – Username to be removed.
rol (int) – Role ID assigned to the user.
- Devuelve:
JSON response with information of the removed user.
- Tipo del valor devuelto:
dict
- sucursal(sucursal)
Retrieve information for a specific taxpayer branch office.
- Parámetros:
sucursal (int) – Branch office ID.
- Devuelve:
JSON response with branch data.
- Tipo del valor devuelto:
dict
contafi.api_client.client.facturacion module
Client for managing suppliers, purchases, and sales using e-invoicing.
- class contafi.api_client.client.facturacion.Facturacion
Bases:
ApiBase
Module for managing suppliers, purchases, and sales using e-invoicing(DTE).
This class provides methods for retrieving DTE records related to sales and purchases, as well as listing clients and suppliers.
- Parámetros:
api_token (str) – User authentication token. If not provided, it will be read from an environment variable.
api_url (str) – Base API URL. If not provided, a default will be used.
api_version (str) – API version to use. If not specified, a default version will be used.
api_raise_for_status (bool) – Whether to raise an exception on HTTP error responses. Defaults to True.
- listar_clientes()
Retrieve a paginated list of clients associated with sales DTEs.
- Devuelve:
JSON response containing the list of sales clients.
- Tipo del valor devuelto:
dict
- listar_compras(estado, filtros)
Retrieve a paginated list of purchase-related DTEs with full details.
- Parámetros:
estado (int) – Status of the document in the purchase register.
filtros (dict) – Filters to apply to the query(e.g., by supplier, date).
- Devuelve:
JSON response with the paginated list of purchase DTEs.
- Tipo del valor devuelto:
dict
- listar_proveedores()
Retrieve a paginated list of suppliers associated with purchase DTEs.
- Devuelve:
JSON response containing the list of suppliers.
- Tipo del valor devuelto:
dict
- listar_ventas(filtros=None)
Retrieve a paginated list of sales-related DTEs with full details.
- Parámetros:
filtros (dict) – Optional filters to apply to the sales search.
- Devuelve:
JSON response containing the list of sales DTEs.
- Tipo del valor devuelto:
dict
- resumen_ventas_sin_detalle(periodo)
Retrieve a paginated list of sales summaries for a given period.
- Parámetros:
periodo (str) – Period to filter the sales summary list (e.g.,2023-08).
- Devuelve:
JSON response with the paginated list of sales summaries.
- Tipo del valor devuelto:
dict
contafi.api_client.client.ingresos_egresos module
Client for managing and listing monetary transactions (income/expenses).
- class contafi.api_client.client.ingresos_egresos.IngresosEgresos
Bases:
ApiBase
Module for managing and listing monetary transactions (income/expenses).
This class provides access to the list of money movements performed or received by the taxpayer for a given period.
- Parámetros:
api_token (str) – User authentication token. If not provided, it will be retrieved from an environment variable.
api_url (str) – Base API URL. If not provided, a default will be used.
api_version (str) – API version. If not provided, a default version will be used.
api_raise_for_status (bool) – Whether to raise an exception automatically on HTTP error responses. Defaults to True.
- listar_movimientos(periodo)
Retrieve a paginated list of income/expense transactions for a period.
- Parámetros:
periodo (str) – Period for which to retrieve the list of transactions.
- Devuelve:
JSON response with all performed and received movements.
- Tipo del valor devuelto:
dict
contafi.api_client.client.remuneraciones module
Client for retrieving information related to employee payroll.
- class contafi.api_client.client.remuneraciones.Remuneraciones
Bases:
ApiBase
Module for retrieving information related to employee payroll.
This class provides access to salary records (remuneraciones) for a taxpayer, including optional filtering by period.
- Parámetros:
api_token (str) – User authentication token. If not provided, it will be read from an environment variable.
api_url (str) – Base API URL. If not provided, a default will be used.
api_version (str) – API version. If not specified, a default version will be used.
api_raise_for_status (bool) – Whether to raise an exception on HTTP error responses. Defaults to True.
- listar_remuneraciones(periodo=None)
Retrieve a paginated list of remuneration records for the taxpayer.
- Parámetros:
periodo (str) – Optional period to filter the payroll list.
- Devuelve:
JSON response containing the remuneration records.
- Tipo del valor devuelto:
dict
Module contents
Client package for the ContaFi API.