API > Products - Search products

Products - Search / get products

GET  https://{entorno}.ticketbaiws.eus/productos/

GET  https://{entorno}.ticketbaiws.eus/productos/{codigo}/

These are the customers and products of the company's invoicing tool in the private area. They are meant for looking up the customer and the products before issuing an invoice with POST /tbai/: the field names match those of the invoice (nombre, nif, pais_cliente, importe_unitario, tipo_iva, tipo_req...).

They do not depend on the environment: with the test token (api-test) you read and modify the same data as with the production token.

Searches products by text (name in Spanish, English or Basque, reference, brand, HS code or product family) or gets one by its codigo. Read-only: products are created in the private area. Each product includes codigo, referencia, descripcion (plus nombre_en, nombre_eu), marca, familia, codigo_familia, hs_code, cantidad, importe_unitario (excluding VAT), tipo_iva, tipo_req and tipo_retencion.

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

buscar string optional
Text to search for
mantenimiento
referencia string optional
Exact reference
REF-001
familia string optional
Product family code
12
pagina integer optional
Page number, starting at 0
0
cantidad integer optional
Results per page. Default 50, maximum 250
50

The list returns the total number of results in count.

GET https://{entorno}.ticketbaiws.eus/productos/
$ curl --request GET \
     --url 'https://api-test.ticketbaiws.eus/productos/?buscar=mantenimiento&pagina=0&cantidad=50' \
     --header 'Accept: application/json' \
     --header 'Content-Type: 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']);

// GET /productos/ (paginated search; optional filters: referencia, familia)
$r = $tbai->productos()->buscar('mantenimiento', [], 0, 50);

// GET /productos/{codigo}/
// $r = $tbai->productos()->obtener('a1b2c3d4e5');

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

url = "https://api-test.ticketbaiws.eus/productos/"
params = {"buscar": "mantenimiento", "pagina": 0, "cantidad": 50}

headers = {"Accept": "application/json", "Token" : "xxx", "Nif" : "00000014Z"}
response = requests.request("GET", url, params=params, headers=headers)

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/productos/?buscar=mantenimiento&pagina=0&cantidad=50");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Token: xxx");
headers = curl_slist_append(headers, "Nif: 00000014Z");
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/productos/?buscar=mantenimiento&pagina=0&cantidad=50")
  .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": [
        {
            "codigo": "a1b2c3d4e5",
            "referencia": "REF-001",
            "descripcion": "Mantenimiento mensual",
            "nombre_en": "Monthly maintenance",
            "nombre_eu": "Hileko mantentze-lanak",
            "marca": "",
            "familia": "Servicios",
            "codigo_familia": "12",
            "hs_code": "",
            "cantidad": 1,
            "importe_unitario": 50,
            "tipo_iva": 21,
            "tipo_req": 0,
            "tipo_retencion": 0
        }
    ],
    "msg": "Showing 1 to 1 of 1",
    "count": 1
}
{ } Response GET /productos/{codigo}/ JSON
HTTP/1.1 200 OK
{
    "result": "OK",
    "return": {
        "codigo": "a1b2c3d4e5",
        "referencia": "REF-001",
        "descripcion": "Mantenimiento mensual",
        "nombre_en": "Monthly maintenance",
        "nombre_eu": "Hileko mantentze-lanak",
        "marca": "",
        "familia": "Servicios",
        "codigo_familia": "12",
        "hs_code": "",
        "cantidad": 1,
        "importe_unitario": 50,
        "tipo_iva": 21,
        "tipo_req": 0,
        "tipo_retencion": 0
    },
    "msg": ""
}
{ } Response (not found) JSON
HTTP/1.1 200 OK
{
    "result": "ERROR",
    "return": null,
    "msg": "Product not found"
}

TicketBAI / Verifactu methods

Representation document

BATUZ BIZKAIA specific methods

SII (AEAT)

Customers and products (invoicing tool)

Other methods