This solution allows you to query the Registro de Compras y Ventas from Chile's Servicio de Impuestos Internos (SII) using scraping. It authenticates using a digital certificate stored in Azure Blob Storage and retrieves DTE summaries by document state.
| Package Reference | Version |
|---|---|
| Azure.Storage.Blobs | 12.24.0 |
| Microsoft.Extensions.Azure | 1.11.0 |
| Swashbuckle.AspNetCore | 8.1.0 |
This project requires the following to run successfully:
- A valid digital certificate (.pfx) issued for SII services
- An Azure Storage Account or a local Blob Storage emulator like Azurite to store the certificate file.
Once the app is running, you can query purchases or sales:
curl -X GET "http://localhost:5200/api/RegistroCompraVenta/resumen?rut=11222333-8&year=2025&mes=3&operacion=compra" \
-H "Accept: application/json"rut: RUT of the issuer (e.g.,11222333-8)year: Year between 2023 and current yearmes: Month between 1 and 12operacion:COMPRAorVENTA
The result is grouped by document state: REGISTRO, RECLAMADO, PENDIENTE.
Use appsettings.json or environment variables to configure the certificate source:
{
"StorageConnection": "UseDevelopmentStorage=true",
"StorageConnection:ContainerName": "certificados",
"StorageConnection:BlobName": "certificado1.pfx",
"StorageConnection:CertPassword": "<your-cert-password>"
}You may also define these as Azure App Settings if you're deploying the API to the cloud.
Feel free to file a new issue with a respective title and description in the Sii.RegistroCompraVenta/issues section.
If this tool is useful, feel free to contribute ideas or improvements.
This repository is released under the GNU General Public License v3.0.
