Configuring and using the PrestaShop Webservice (API) lets you connect your store with external apps (mobile apps, ERP, CRM, automation scripts, etc.). Hereβs a clear, practical guide.
π§ 1. Enable Webservice in PrestaShop
- Go to Advanced Parameters β Webservice
- Turn ON:
- β Enable PrestaShop Webservice
- Save
π If youβre on Apache, make sure:
- mod_rewrite is enabled
.htaccessis working (Regenerate from SEO & URLs if needed)
π 2. Create API Key
- Go to Advanced Parameters β Webservice
- Click βAdd new webservice keyβ
- Fill:
- Key: Click Generate
- Description: e.g., βMobile App APIβ
- Status: Enable
π 3. Set Permissions
Youβll see a list of resources like:
- products
- categories
- customers
- orders
- carts
Set permissions:
- GET β Read
- POST β Create
- PUT β Update
- DELETE β Remove
π Example:
- For product sync: enable GET, POST, PUT on products
π 4. API Endpoint Structure
Your API base URL:
https://yourdomain.com/api/
Example endpoints:
- Products:
https://yourdomain.com/api/products
- Customers:
https://yourdomain.com/api/customers
π 5. Authentication
PrestaShop API uses Basic Auth:
- Username = API Key
- Password = (leave empty)
π§ͺ 6. Test API in Browser / Postman
Browser test:
https://API_KEY@yourdomain.com/api/products
Postman setup:
- Method: GET
- URL:
https://yourdomain.com/api/products - Auth:
- Type: Basic Auth
- Username: API KEY
- Password: blank
π¦ 7. Example API Requests
β Get all products
GET /api/products
β Get specific product
GET /api/products/1
β Create product (POST)
<prestashop>
<product>
<name>
<language id="1">Test Product</language>
</name>
<price>100</price>
<active>1</active>
</product>
</prestashop>
β Update product
PUT /api/products/1
β Delete product
DELETE /api/products/1
π 8. PHP Example (cURL)
$apiKey = 'YOUR_API_KEY';
$url = 'https://yourdomain.com/api/products';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, $apiKey.':');
$response = curl_exec($ch);
curl_close($ch);
echo $response;
β οΈ 9. Common Issues & Fixes
β 401 Unauthorized
- Wrong API key
- Permissions not set
β 404 Not Found
- Pretty URLs issue β regenerate
.htaccess
β 500 Server Error
- Enable debug mode in PrestaShop
- Check server logs
β Empty response
- Resource permissions missing
π 10. Security Best Practices
- Never expose API key publicly
- Restrict IP access (if possible)
- Use HTTPS only
- Create separate keys per integration
π 11. Use Cases
- Mobile app integration
- ERP / accounting sync
- Inventory automation
- Order processing system
- Marketplace integration
π Pro Tips (Advanced)
- Use filters:
/api/products?filter[price]=[100,200]
- Use display fields:
/api/products?display=[id,name,price]
- Use output format JSON (newer versions):
/api/products?output_format=JSON
Β
