AFRelay is a middleware that eliminates the need to manually build XML and lets developers work with AFIP as if it were a REST API.
Total control.: Free. No SaaS. No closed-source infrastructure.
Without requiring the developer to get involved with SOAP.
- Async network I/O keeps the event loop free while waiting for slow external services.
- Automatically renews the access ticket each 11 hours and when the service starts.
- Does not automatically handle errors or raise exceptions, only returns information as JSON.
To use this service, you need a fiscal key and the corresponding certificates to authenticate with AFIP/ARCA web services.
The steps to obtain the certificates are available on the official website:
https://www.arca.gob.ar/ws/documentacion/certificados.asp
Once authenticated, the authentication web service will provide two credentials:
- A private key with the extension "
.key" - An X.509 certificate with the extension "
.pem"
- Clone the repository
git clone https://github.com/NehuenLian/AFRelay- Go to repository
cd AFRelay- Start the container
docker compose up- Health Check readiness:
curl -i http://localhost:8000/health/readiness- See OpenAPI docs
http://localhost:8000/docs- Clone the repository
git clone https://github.com/NehuenLian/AFRelay- Go to repository
cd AFRelay- Install dependencies
pip install -r requirements-dev.txt- Startup FastAPI
uvicorn service.api.app:app --reload- Health Check readiness:
curl -i http://127.0.0.1:8000/health/readiness- See OpenAPI docs
http://localhost:8000/docs-
Full tests:
pytest -v --cov
-
Unit tests:
pytest tests/unit -v --cov
-
Integration tests:
pytest tests/integration -v --cov
-
Access ticket persistence: If the container or server where the service is deployed goes down, there is no problem with access tickets (
loginTicketResponse.xml). On restart, if a TA (Access Ticket) comes in and the files are missing, the service will detect it and automatically generate a new ticket. -
Flexible deployment: Using Docker is optional. The service can run directly or inside any Python environment, as long as input and output file formats are respected. Protecting credentials (tokens, certificates) is the responsibility of the user or system administrator.
AFRelay
├── config/
├── host_certs/
├── host_xml/
├── service/
│ ├── api/
│ ├── app_certs/
│ ├── controllers/
│ ├── crypto/
│ ├── payload_builder/
│ ├── soap_client/
│ ├── time/
│ ├── utils/
│ └── xml_management/
├── tests/
├── requirements-dev.txt
└── requirements.txt
This project is licensed under the MIT license (a permissive open-source license).
You are free to use, copy, modify, and distribute the software, always including the copyright notice and without any warranties.
Author: Nehuen Lián https://github.com/NehuenLian