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
