Site icon PrestaShop | Magento | CRM Modules

PrestaShop API

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:

You can manage:


How to Enable PrestaShop API

  1. Go to Back Office
  2. Advanced Parameters → Webservice
  3. Turn Enable PrestaShop WebserviceYES
  4. Click Add new webservice key
  5. Set permissions (GET / POST / PUT / DELETE)
  6. Save → copy the API key 🔑

Authentication (Important)

PrestaShop uses Basic Auth

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


 

Exit mobile version