API > Download TicketBAI XML

Download TicketBAI XML

GET  https://{entorno}.ticketbaiws.eus/tbai-xml/

This method downloads the XML files of the request sent to the corresponding Provincial Council (Diputación Foral) and of its response

GET methods accept the parameters either in the body as a JSON payload or as a query string in the URL, as shown in the cURL example.

PARAMETERS

serie string required
Invoice series
A
numero string required
Invoice number
2021000123

GET https://{entorno}.ticketbaiws.eus/tbai-xml/
$ curl --request GET \
     --url 'https://api-test.ticketbaiws.eus/tbai-xml/?serie=A&numero=2021000123' \
     --header 'Accept: application/json' \
     --header 'Token: xxx' \
     --header 'Nif: 00000014Z'
$ composer require ticketbaiws/ticketbaiws-php
<?php
// Installation: composer require ticketbaiws/ticketbaiws-php
require 'vendor/autoload.php';

$tbai = new \TicketbaiWS\Client('xxx', '00000014Z', ['entorno' => 'test']);

$r = $tbai->xmlFactura('A', '2021000123');

if ($r->isError()) {
    echo $r->getMessageText();
} else {
    echo $r->getData('xml_request');
    echo $r->getData('xml_response');
}
$ python -m pip install requests
import requests

url = "https://api-test.ticketbaiws.eus/tbai-xml/"
headers = {"Accept": "application/json", "Token" : "xxx", "Nif" : "00000014Z"}
params = {"serie": "A", "numero": "2021000123"}
response = requests.request("GET", url, headers=headers, params=params)
print(response.text)
CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api-test.ticketbaiws.eus/tbai-xml/?serie=A&numero=2021000123");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

CURLcode ret = curl_easy_perform(hnd);
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api-test.ticketbaiws.eus/tbai-xml/?serie=A&numero=2021000123")
  .get()
  .addHeader("Accept", "application/json")
  .addHeader("Token", "xxx")
  .addHeader("Nif", "00000014Z")
  .build();
  
Response response = client.newCall(request).execute();
{ } Response JSON
HTTP/1.1 200 OK
{ 
	"result": "OK", 
	"return": {
		"serie" : "A",
		"numero" : "2021000123",
		"xml_request" : "<?xml version='1.0' encoding='UTF-8'?><T:TicketBai xmlns:T='urn:tick. ...",
		"xml_response" : "<?xml version='1.0' encoding='UTF-8' standalone ..."
	}, 
	"msg": null 
}

The XML files are returned as text (not base64). If the invoice has Zuzendu corrections (Bizkaia), return is a list with one item per version, with the field zuzendu.

{ } Response (with Zuzendu corrections) JSON
HTTP/1.1 200 OK
{ 
	"result": "OK", 
	"return": [
		{
			"serie" : "A",
			"numero" : "2021000123",
			"xml_request" : "<?xml version='1.0' encoding='UTF-8'?> ...",
			"xml_response" : "<?xml version='1.0' encoding='UTF-8' standalone ...",
			"zuzendu" : 1
		},
		{
			"serie" : "A",
			"numero" : "2021000123",
			"xml_request" : "<?xml version='1.0' encoding='UTF-8'?> ...",
			"xml_response" : "<?xml version='1.0' encoding='UTF-8' standalone ..."
		}
	], 
	"msg": null 
}
{ } Response (not found) JSON
HTTP/1.1 200 OK
{ 
	"result": "ERROR", 
	"return": null, 
	"msg": "TBAI Not Found" 
}

TicketBAI / Verifactu methods

Representation document

BATUZ BIZKAIA specific methods

SII (AEAT)

Customers and products (invoicing tool)

Other methods