Acest document se referă în mod specific la Versiunea 2 a API-ului EDD.
Documentația pentru Versiunea 1 este aici.
API-ul REST EDD
EDD REST API oferă acces la informații despre produse prin intermediul endpoint-ului /products/. Puteți accesa mai multe produse sau un singur produs.
NOTĂ: Endpoint-ul de produse nu necesită o cheie sau un token pentru a reda produsele disponibile public. Dacă produsul dvs. este disponibil public pe prima pagină a site-ului dvs., acesta este disponibil prin API fără o cheie sau un token.
O interogare de bază pentru produse arată astfel:
https://example.com/edd-api/v2/products/
Un exemplu de răspuns pentru produse arată astfel,
note mai jos:
{
"products": [
{
"info": {
"id": 45,
"slug": "pdf-test",
"title": "PDF Test",
"create_date": "2016-05-23 18:44:51",
"modified_date": "2016-06-08 17:30:54",
"status": "publish",
"link": "https://example.com/?post_type=download&p=45",
"content": "",
"excerpt": "",
"thumbnail": false,
"category": [
{
"term_id": 3,
"name": "ebooks",
"slug": "ebooks",
"term_group": 0,
"term_taxonomy_id": 3,
"taxonomy": "download_category",
"description": "",
"parent": 0,
"count": 2,
"filter": "raw",
"object_id": 45
}
],
"tags": [
{
"term_id": 7,
"name": "pdf",
"slug": "pdf",
"term_group": 0,
"term_taxonomy_id": 7,
"taxonomy": "download_tag",
"description": "",
"parent": 0,
"count": 1,
"filter": "raw",
"object_id": 45
}
],
"sku": "AAMAM2016"
},
"stats": {
"total": {
"sales": "0",
"earnings": "0.00"
},
"monthly_average": {
"sales": "0",
"earnings": "0.00"
}
},
"pricing": {
"amount": "1.00"
},
"files": [
{
"index": "0",
"attachment_id": "18",
"name": "WCCHI_2014_page_speed",
"file": "https://example.com/wp-content/uploads/edd/2016/05/WCCHI_2014_page_speed.pdf",
"condition": "all"
}
],
"notes": "",
"licensing": {
"enabled": false,
"version": "",
"exp_unit": "days",
"exp_length": ""
}
},
{
"info": {
"id": 42,
"slug": "variable-license",
"title": "Variable license",
"create_date": "2016-05-20 22:21:38",
"modified_date": "2016-05-23 17:32:47",
"status": "publish",
"link": "https://example.com/?post_type=download&p=42",
"content": "",
"excerpt": "",
"thumbnail": false,
"category": false,
"tags": false,
"sku": "-"
},
"stats": {
"total": {
"sales": "0",
"earnings": "0.00"
},
"monthly_average": {
"sales": "0",
"earnings": "0.00"
}
},
"pricing": {
"monthly": "10.00",
"yearly": "120.00"
},
"files": [
{
"index": "0",
"attachment_id": "18",
"name": "WCCHI_2014_page_speed",
"file": "https://example.com/wp-content/uploads/edd/2016/05/WCCHI_2014_page_speed.pdf",
"condition": "all"
}
],
"notes": "",
"licensing": {
"enabled": true,
"version": "",
"exp_unit": "days",
"exp_length": ""
}
},
{
"info": {
"id": 17,
"slug": "i-am-pippin-williamson-and-so-can-you",
"title": "I am Pippin Williamson, and so can YOU",
"create_date": "2016-05-17 14:03:50",
"modified_date": "2016-06-02 19:51:17",
"status": "publish",
"link": "https://example.com/?post_type=download&p=17",
"content": "This is a test",
"excerpt": "",
"thumbnail": false,
"category": [
{
"term_id": 3,
"name": "ebooks",
"slug": "ebooks",
"term_group": 0,
"term_taxonomy_id": 3,
"taxonomy": "download_category",
"description": "",
"parent": 0,
"count": 2,
"filter": "raw",
"object_id": 17
}
],
"tags": false,
"sku": "-"
},
"stats": {
"total": {
"sales": "4",
"earnings": "78.000000"
},
"monthly_average": {
"sales": "4",
"earnings": "78.000000"
}
},
"pricing": {
"amount": "20.00"
},
"files": [
{
"index": "0",
"attachment_id": "18",
"name": "WCCHI_2014_page_speed",
"file": "https://example.com/wp-content/uploads/edd/2016/05/WCCHI_2014_page_speed.pdf",
"condition": "all"
}
],
"notes": "This is my download note!",
"licensing": {
"enabled": false,
"version": "",
"exp_unit": "",
"exp_length": ""
}
},
],
"request_speed": 0.0075628757476807
}
Dacă SKU-urile sunt activate, dar câmpul este gol, va afișa o cratimă, ca în cazul celui de-al doilea produs din exemplul de mai sus.
Filtrarea produselor
Produse specifice
Dacă doriți să preluați informații doar pentru un produs specific, puteți transmite un ID de produs prin intermediul
parametrului product:
https://example.com/edd-api/v2/products/?product=55
Căutare
Dacă doriți să căutați un produs, puteți transmite o frază de căutare prin intermediul
parametrului s:
https://example.com/edd-api/v2/products/?s=PDF
Tag-uri și Categorii
Puteți restrânge căutarea folosind cuvintele cheie category și tag, urmate de un slug sau ID. Câteva exemple:
https://example.com/edd-api/v2/products/?category=ebooks
https://example.com/edd-api/v2/products/?category=3
https://example.com/edd-api/v2/products/?tag=pdf
https://example.com/edd-api/v2/products/?tag=42
Exemplu combinat:
https://example.com/edd-api/v2/products/?category=ebooks&tag=pdf
