Questo documento si riferisce specificamente alla Versione 2 dell'API EDD.
La documentazione per la Versione 1 è qui.
L'
API REST EDD fornisce accesso alle informazioni sui prodotti tramite l'endpoint /products/. È possibile accedere a più prodotti o a un singolo prodotto.
NOTA: L'endpoint dei prodotti non necessita di una chiave o di un token per visualizzare i prodotti disponibili pubblicamente. Se il tuo prodotto è disponibile pubblicamente sul front-end del tuo sito, è disponibile tramite API senza chiave o token.
Una query di base per i prodotti è simile a questa:
https://example.com/edd-api/v2/products/
Un esempio di risposta per i prodotti è simile a questo,
note di seguito:
{
"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
}
Se gli SKU sono attivati, ma il campo è vuoto, verrà visualizzato un trattino, come nel secondo prodotto nell'esempio sopra.
Filtrare i Prodotti
Prodotti Specifici
Se desideri recuperare informazioni solo per un prodotto specifico, puoi passare un ID prodotto tramite il
parametro product:
https://example.com/edd-api/v2/products/?product=55
Ricerca
Se desideri cercare un prodotto puoi passare una frase di ricerca tramite il
parametro s:
https://example.com/edd-api/v2/products/?s=PDF
Tag e Categorie
Puoi restringere la tua ricerca utilizzando le parole chiave category e tag, seguite da uno slug o un ID. Alcuni esempi:
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
Esempio combinato:
https://example.com/edd-api/v2/products/?category=ebooks&tag=pdf
