API Categorii

Acesta este sectiunea de help pentru versiunea Legacy a panoului de control. Daca utilizati panoul de control Flex, puteti gasi aici sectiunea de help relevanta.

Foloseste API-ul de categorii pentru a extrage informatii despre categorii, pentru a adauga categorii noi sau pentru a actualiza datelor unor categorii existente.

Campuri disponibile

Lista de mai jos indica toate campurile disponibile pt acest API, care sunt returnate cand extragi o lista sau resursa individuala, care pot fi modificate, care sunt obligatorii in cazul crearii unei resurse noi sau actualizarii unei resurse existente.

Camp Tip Descriere Lista Alterabil
id int Id-ul categoriei  
name string Numele categoriei
description string Descrierea categoriei
meta_title string Meta titlul categoriei
meta_description string Meta descrierea categoriei
parent_id int Id-ul categoriei parinte
page_template string Tipul de template folosit pentru afisare in cazul categoriilor care contin subcategorii (products, subcategories, mixed, highlights)
meta_fields object Campurile aditionale
url string URL-ul categoriei  
meta_links object URL-urile categoriei aferente limbilor active    
subcategories array Lista id-urilor subcategoriilor    
created date Data adaugarii categoriei (format ISO 8601)  
status string Status-ul inregistrarii (active, inactive)

TIP
Orice camp returnat si care nu este documentat poate fi ignorat deoarece nu este inca disponibil.

Extragere lista categorii

Afiseaza lista filtrata de inregistrari.

Tip: Lista resurse
Verb: GET
Url: /api/v2/categories
Filtrare rezultate: Da
Selectie campuri: Da
Includere campuri suplimentare: Da
Paginatie: Da

Codul http de raspuns este 200 in caz de succes, raspunsul va avea forma unei liste de resurse aferente filtrelor definite.

Doar campurile de tip lista vor fi incluse in rezultatul standard. Poti include campuri suplimentare care in mod implicit nu sunt incluse folosind parametrul include si mentionand in mod explicit doar campurile suplimentare (separate prin virgula) pe care le doresti incluse.

GET /api/v2/categories?include=subcategories

Poti filtra campurile pe care le doresti incluse in rezultat pentru fiecare resursa folosind parametrul fields si mentionand in mod explicit doar campurile (separate prin virgula) pe care le doresti incluse (campul id va fi inclus intotdeauna in mod implicit).

GET /api/v2/categories?fields=id,name,parent_id

Filtrare rezultate

Este posibila filtrarea rezultatelor prin apendarea unor parametrii specifici in URL.

Parametru Descriere Exemplu
id Id-ul categoriei id=101
ids Lista id-uri categorii separate prin virgula ids=101,102,103
parent_id Id-ul categoriei parinte parent_id=101
meta_fields Campurile suplimentare meta_fields[field_key]=field_value
created_after Data de la care au fost create inregistrarile (format ISO 8601) created_after=2019-01-01
created_before Data pana la care au fost create inregistrarile (format ISO 8601) created_before=2020-01-01
status Status-ul inregistrarii (active, inactive) status=active
GET /api/v2/categories?parent_id=0&status=active

Sortare rezultate

Este posibila sortarea rezultatelor prin apendarea unor parametrii specifici in URL.

Parametru Descriere Exemplu
name Numele categoriei ascendent sort=name
name.desc Numele categoriei descendent sort=name.desc
created Data adaugarii categoriei ascendent sort=created
created.desc Data adaugarii categoriei descendent sort=created.desc
user_defined In functie de criteriul de ordonare categorii setat la nivel de Cpanel sort=user_defined
GET /api/v2/categories?sort=name

Paginatie

Parametrii de paginatie pot fi adaugati request-ului API pentru a limita numarul de inregistrari pe pagina si a accesa toate paginile disponibile.

Parametru Tip Default
start int 0
limit int 100

Limita maxima de inregistrari pe pagina nu poate depasi valoarea 100.

GET /api/v2/categories?start=100&limit=100

Format request

Exemplu de request CURL care extrage toate inregistrarile:

curl --request GET \
--url 'https://shop.demo.ro/api/v2/categories' \
--header 'Accept: application/json' \
--header 'Content-type: application/json' \
--header 'Authorization: Basic {base64-encoded-credentials}'

Extrage toate inregistrarile, extrage toate campurile

Exemplu request

GET /api/v2/categories
Exemplu raspuns
{
  "data": [
    {
      "id": 101,
      "name": "Men",
      "description": "Best online clothing shops for men",
      "status": "active",
      "parent_id": 0,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00",
      "page_template": "subcategories"
    },
    {
      "id": 102,
      "name": "Women",
      "description": "Women clothing in all styles and sizes",
      "status": "active",
      "parent_id": 0,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00",
      "page_template": "subcategories"
    },
    {
      "id": 103,
      "name": "Accessories",
      "description": "Find a wide selection of accessories for men & women",
      "status": "active",
      "parent_id": 0,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00",
      "page_template": "subcategories"
    },    
    {
      "id": 1011,
      "name": "Pants",
      "description": "Explore the new collection of men pants",
      "status": "active",
      "parent_id": 101,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00"
    },
    {
      "id": 1012,
      "name": "Shirts",
      "description": "Discover our stylish men's shirts",
      "status": "active",
      "parent_id": 101,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00"
    },
    {
      "id": 1013,
      "name": "Shoes",
      "description": "The most stylish and comfortable men's shoes",
      "status": "active",
      "parent_id": 101,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00"
    },
    { ... },
  ],
  "meta": {
    "count": {
      "total": 50,
      "current": 50,
      "start": 0,
      "limit": 100
    },
    "links": {
      "prev": null,
      "current": "/api/v2/categories",
      "next": null
    }
  }
}

Extrage toate inregistrarile, filtreaza doar anumite campuri

Exemplu request

GET /api/v2/categories?fields=id,name,parent_id
Exemplu raspuns
{
  "data": [
    {
      "id": 101,
      "name": "Men",
      "parent_id": 0
    },
    {
      "id": 102,
      "name": "Women",
      "parent_id": 0
    },
    {
      "id": 103,
      "name": "Accessories",
      "parent_id": 0
    },    
    {
      "id": 1011,
      "name": "Pants",
      "parent_id": 101
    },
     {
      "id": 1012,
      "name": "Shirts",
      "parent_id": 101
    },
    {
      "id": 1013,
      "name": "Shoes",
      "parent_id": 101
    },
    { ... },
  ],
  "meta": {
    "count": {
      "total": 50,
      "current": 50,
      "start": 0,
      "limit": 100
    },
    "links": {
      "prev": null,
      "current": "/api/v2/categories",
      "next": null
    }
  }
}

Extrage toate inregistrarile, include campuri suplimentare

Exemplu request

GET /api/v2/categories?include=url
Exemplu raspuns
{
  "data": [
    {
      "id": 101,
      "name": "Men",
      "description": "Best online clothing shops for men",
      "status": "active",
      "parent_id": 0,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00",
      "url": "https://shop.demo.ro/men",
      "page_template": "subcategories"
    },
    {
      "id": 102,
      "name": "Women",
      "description": "Women clothing in all styles and sizes",
      "status": "active",
      "parent_id": 0,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00",
      "url": "https://shop.demo.ro/women",
      "page_template": "subcategories"
    },
    {
      "id": 103,
      "name": "Accessories",
      "description": "Find a wide selection of accessories for men & women",
      "status": "active",
      "parent_id": 0,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00",
      "url": "https://shop.demo.ro/accessories",
      "page_template": "subcategories"
    },    
    {
      "id": 1011,
      "name": "Pants",
      "description": "Explore the new collection of men pants",
      "status": "active",
      "parent_id": 101,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00",
      "url": "https://shop.demo.ro/men-pants"
    },
    {
      "id": 1012,
      "name": "Shirts",
      "description": "Discover our stylish men's shirts",
      "status": "active",
      "parent_id": 101,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00",
      "url": "https://shop.demo.ro/men-shirts"
    },
    {
      "id": 1013,
      "name": "Shoes",
      "description": "The most stylish and comfortable men's shoes",
      "status": "active",
      "parent_id": 101,
      "meta_title": null,
      "meta_description": null,
      "created": "2020-01-01T01:01:01+02:00",
      "url": "https://shop.demo.ro/men-shoes"
    },
    { ... },
  ],
  "meta": {
    "count": {
      "total": 50,
      "current": 50,
      "start": 0,
      "limit": 100
    },
    "links": {
      "prev": null,
      "current": "/api/v2/categories",
      "next": null
    }
  }
}

Filtreaza inregistrarile pe baza de lista de ID-uri, filtreaza doar anumite campuri

Exemplu request

GET /api/v2/categories?ids=101,102&fields=id,name
Exemplu raspuns
{
  "data": [
    {
      "id": 101,
      "name": "Men"
    },
    {
      "id": 102,
      "name": "Women"
    }
  ],
  "meta": {
    "count": {
      "total": 2,
      "current": 2,
      "start": 0,
      "limit": 100
    },
    "links": {
      "prev": null,
      "current": "/api/v2/categories",
      "next": null
    }
  }
}

Extragere date categorie

Afiseaza datele unei singure inregistrari.

Tip: Resursa individuala
Verb: GET
Url: /api/v2/categories/{id}
Filtrare rezultate: Nu
Selectie campuri: Da
Includere campuri suplimentare: Nu
Paginatie: Nu

Codul http de raspuns este 200 in caz de succes, raspunsul va avea forma unei resurse individuale aferente id-ului solicitat.

Poti filtra campurile pe care le doresti incluse in rezultat pentru fiecare resursa folosind parametrul fields si mentionand in mod explicit doar campurile (separate prin virgula) pe care le doresti incluse (campul id va fi inclus intotdeauna in mod implicit).

GET /api/v2/categories/{id}?fields=id,name,parent_id

Format request

Exemplu de request CURL care returneaza o inregistrare individuala:

curl --request GET \
--url 'https://shop.demo.ro/api/v2/categories/101' \
--header 'Accept: application/json' \
--header 'Content-type: application/json' \
--header 'Authorization: Basic {base64-encoded-credentials}'

Extrage toate campurile

Exemplu request

GET /api/v2/categories/101
Exemplu raspuns
{
  "id": 101,
  "name": "Men",
  "description": "Best online clothing shops for men",
  "status": "active",
  "parent_id": 0,
  "meta_title": null,
  "meta_description": null,
  "created": "2020-01-01T01:01:01+02:00",
  "meta_fields": {
    "homepage_display": "on"
  },
  "subcategories": [
    1011,
    1012,
    1013
  ],
  "url": "https://shop.demo.ro/men",
  "meta_links": {
    "en_US": {
      "lang": "en_US",
      "url": "https://shop.demo.ro/en/men"
    }
  },
  "page_template": "subcategories"
}

Filtreaza doar anumite campuri

Exemplu request

GET /api/v2/categories/101?fields=id,name,subcategories
Exemplu raspuns
{
  "id": 101,
  "name": "Men",
  "subcategories": [
    1011,
    1012,
    1013
  ]
}

Adaugare categorie

Permite adaugarea unei noi inregistrari.

Tip: Creare resursa
Verb: POST
Url: /api/v2/categories

Codul http de raspuns este 200 in caz de succes, raspunsul va avea forma unei resurse individuale reprezentand inregistrarea care tocmai a fost adaugata.

Format request

Exemplu de request CURL care creeaza o inregistrare noua:

curl --request POST \
--url 'https://shop.demo.ro/api/v2/categories' \
--header 'Accept: application/json' \
--header 'Content-type: application/json' \
--header 'Authorization: Basic {base64-encoded-credentials}' \
--data-raw '{
  "name": "Women",
  "description": "Women clothing in all styles and sizes",
  "parent_id": 102
}'

Adaugare categorie de tip root

Exemplu request

POST /api/v2/categories
{
  "name": "Women",
  "description": "Women clothing in all styles and sizes",
  "parent_id": 0  
}
Exemplu raspuns
{
  "id": 102,
  "name": "Women",
  "description": "Women clothing in all styles and sizes",
  "status": "active",
  "parent_id": 0,
  "meta_title": null,
  "meta_description": null,
  "created": "2020-01-01T01:01:01+02:00",
  "meta_fields": null,
  "subcategories": null,
  "url": "https://shop.demo.ro/women",
  "meta_links": {
    "en_US": {
      "lang": "en_US",
      "url": "https://shop.demo.ro/en/women"
    }
  }
}

Adaugare subcategorie si campuri aditionale

Exemplu request

POST /api/v2/categories
{
  "name": "Pants",
  "description": "Explore the new collection of men pants",
  "status": "active",
  "parent_id": 101,
  "meta_fields": {
    "homepage_display": "on"
  }
}
Exemplu raspuns
{
  "id": 1011,
  "name": "Pants",
  "description": "Explore the new collection of men pants",
  "status": "active",
  "parent_id": 101,
  "meta_title": null,
  "meta_description": null,
  "created": "2020-01-01T01:01:01+02:00",
  "meta_fields": {
    "homepage_display": "on"
  },
  "subcategories": null,
  "url": "https://shop.demo.ro/men-pants",
  "meta_links": {
    "en_US": {
      "lang": "en_US",
      "url": "https://shop.demo.ro/en/men-pants"
    }
  }
}

Modificare date categorie

Permite actualizarea unei inregistrari existente pe baza de ID.

Tip: Actualizare resursa
Verb: PATCH
Url: /api/v2/categories/{id}

Codul http de raspuns este 200 in caz de succes, raspunsul va avea forma unei resurse individuale reprezentand inregistrarea care tocmai a fost actualizata.

Format request

Exemplu de request CURL care actualizeaza o inregistrare existenta:

curl --request PATCH \
--url 'https://shop.demo.ro/api/v2/categories/101' \
--header 'Accept: application/json' \
--header 'Content-type: application/json' \
--header 'Authorization: Basic {base64-encoded-credentials}' \
--data-raw '{
  "description": "Best online clothing shops for men",
  "meta_title": "Men Clothing & Shoes"
}'

Actualizare date categorie

Exemplu request

PATCH /api/v2/categories/101
{
  "meta_title": "Men Clothing & Shoes",
  "meta_fields": {
    "homepage_display": "off"
  },
}
Exemplu raspuns
{
  "id": 101,
  "name": "Men",
  "description": "Best online clothing shops for men",
  "status": "active",
  "parent_id": 0,
  "meta_title": "Men Clothing & Shoes",
  "meta_description": null,
  "created": "2020-01-01T01:01:01+02:00",
  "meta_fields": {
    "homepage_display": "off"
  },
  "subcategories": [
    1011,
    1012,
    1013
  ],
  "url": "https://shop.demo.ro/men",
  "meta_links": {
    "en_US": {
      "lang": "en_US",
      "url": "https://shop.demo.ro/en/men"
    }
  },
  "page_template": "subcategories"
}

Schimbare status categorie

Exemplu request

PATCH /api/v2/categories/101
{
  "status": "inactive"
}
Exemplu raspuns
{
  "id": 101,
  "name": "Men",
  "description": "Best online clothing shops for men",
  "status": "inactive",
  "parent_id": 0,
  "meta_title": null,
  "meta_description": null,
  "created": "2020-01-01T01:01:01+02:00",
  "meta_fields": {
    "homepage_display": "on"
  },
  "subcategories": [
    1011,
    1012,
    1013
  ],
  "url": "https://shop.demo.ro/men",
  "meta_links": {
    "en_US": {
      "lang": "en_US",
      "url": "https://shop.demo.ro/en/men"
    }
  },
  "page_template": "subcategories"
}

Stergere categorie

Permite stergerea unei inregistrari existente pe baza de ID. Aceasta implica si stergerea tuturor informatiilor aditionale.

Tip: Stergere resursa
Verb: DELETE
Url: /api/v2/categories/{id}

Codul http de raspuns este 200 in caz de succes.

Format request

Exemplu de request CURL care sterge o inregistrare existenta:

curl --request DELETE \
--url 'https://shop.demo.ro/api/v2/categories/101' \
--header 'Accept: application/json' \
--header 'Content-type: application/json' \
--header 'Authorization: Basic {base64-encoded-credentials}'

Exemplu request

DELETE /api/v2/categories/101
Exemplu raspuns
{
  "ok": true
}
Ultima modificare: 20 Dec 2023
Te-a ajutat acest articol?
Mai ai nevoie si de alte informatii?