PrestaShop API is basically how you let external apps talk to your PrestaShop store โ read data, create orders, update products, customers, etc., without touching the back-office UI.
Hereโs a clean, practical rundown ๐
What is PrestaShop Webservice API?
Itโs a REST-like API built into PrestaShop that uses:
- HTTP
- XML (default) or JSON (newer versions)
- API key authentication
You can manage:
- Products
- Categories
- Customers
- Orders
- Carts
- Stock
- Carriers
- Employees (limited)
- And more
How to Enable PrestaShop API
- Go to Back Office
- Advanced Parameters โ Webservice
- Turn Enable PrestaShop Webservice โ YES
- Click Add new webservice key
- Set permissions (GET / POST / PUT / DELETE)
- Save โ copy the API key ๐
Authentication (Important)
PrestaShop uses Basic Auth
- Username โ API KEY
- Password โ empty
Example:
Authorization: Basic base64(API_KEY:)
Base API URL
https://yourstore.com/api/
Example resources:
/api/products
/api/categories
/api/orders
/api/customers
/api/stock_availables
Quick Test (Browser)
Open:
https://API_KEY@yourstore.com/api/products
If enabled correctly โ youโll see XML output.
CURL Example (GET products)
curl -X GET "https://yourstore.com/api/products" \
-u API_KEY:
PHP Example (Get Products)
$apiKey = 'YOUR_API_KEY';
$url = 'https://yourstore.com/api/products';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $apiKey . ':');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Accept: application/xml'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Create a Product (POST โ XML)
PrestaShop requires full XML structure.
<prestashop>
<product>
<name>
<language id="1">Test Product</language>
</name>
<price>999</price>
<active>1</active>
</product>
</prestashop>
POST to:
/api/products
JSON Support (PrestaShop 1.7.8+)
Add header:
Accept: application/json
Content-Type: application/json
But โ ๏ธ XML is still more stable for POST/PUT.
Common API Errors
| Error | Meaning |
|---|---|
| 401 | Wrong API key / permissions |
| 403 | Webservice disabled |
| 404 | Resource doesnโt exist |
| 500 | Invalid XML structure |
When API is Best Used
โ Mobile apps
โ ERP / CRM integration
โ Auto product sync
โ Stock & order sync
โ Marketplace integration
ย
