Site icon PrestaShop | General Knowledge

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 Webservice โ†’ YES
  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

ErrorMeaning
401Wrong API key / permissions
403Webservice disabled
404Resource doesnโ€™t exist
500Invalid XML structure

When API is Best Used

โœ” Mobile apps
โœ” ERP / CRM integration
โœ” Auto product sync
โœ” Stock & order sync
โœ” Marketplace integration


ย 

Exit mobile version