PrestaShop Documentation, PrestaShop Tutorials

PrestaShop Webservice

Alright, letโ€™s zoom in specifically on PrestaShop Webservice (the built-in API) and keep it simple + practical ๐Ÿ‘Œ


What is PrestaShop Webservice?

PrestaShop Webservice is the native API system that lets external systems interact with your store using HTTP.

Think of it as:

๐Ÿ‘‰ a secure door to read / create / update / delete store data programmatically.

It works without installing any extra module.


What You Can Control via Webservice

Using /api/ endpoints, you can manage:

  • ๐Ÿ› Products
  • ๐Ÿ“‚ Categories
  • ๐Ÿ‘ค Customers
  • ๐Ÿงพ Orders
  • ๐Ÿ›’ Carts
  • ๐Ÿ“ฆ Stock (stock_availables)
  • ๐Ÿšš Carriers
  • ๐Ÿ’ณ Order states
  • ๐ŸŒ Languages, currencies
  • ๐Ÿ‘จโ€๐Ÿ’ผ Employees (limited)

Enable PrestaShop Webservice (Step-by-Step)

  1. Back Office โ†’ Advanced Parameters
  2. Click Webservice
  3. Enable PrestaShop Webservice
  4. Click Add new webservice key
  5. Generate key ๐Ÿ”‘
  6. Select permissions:
    • GET (read)
    • POST (create)
    • PUT (update)
    • DELETE (remove)
  7. Save

โš ๏ธ No permission = no access, even with correct key.


Base Webservice URL

https://yourstore.com/api/

Example resource:

/api/products

That endpoint lists products or allows product creation (depending on HTTP method).


Authentication Method

PrestaShop uses HTTP Basic Auth

  • Username โ†’ API KEY
  • Password โ†’ empty

Example:

Authorization: Basic base64(API_KEY:)

Browser test:

https://API_KEY@yourstore.com/api/products

Request Types (Very Important)

Method Purpose
GET Fetch data
POST Create new data
PUT Update existing data
DELETE Remove data

Example: Get Products (CURL)

curl -X GET "https://yourstore.com/api/products" \
-u API_KEY:

XML vs JSON

  • XML โ†’ Default & safest (recommended)
  • JSON โ†’ Supported in newer versions (1.7.8+)

Headers for JSON:

Accept: application/json
Content-Type: application/json

โš ๏ธ For POST / PUT, XML is still more reliable.


Create Product Flow (Important Concept)

  1. GET blank schema
/api/products?schema=blank
  1. Fill required fields
  2. POST back to:
/api/products

Skipping required fields = โŒ 500 error.


Common Webservice Errors

Error Reason
401 Wrong API key
403 Permission not granted
404 Invalid endpoint
500 Invalid XML structure
406 Missing required field

Best Practices

โœ” Always fetch schema=blank
โœ” Validate XML before POST
โœ” Limit API key permissions
โœ” Disable API if not used
โœ” Use HTTPS only


Typical Real-World Uses

  • ERP integration
  • Mobile app backend
  • Auto product upload
  • Stock sync
  • Order sync with accounting software
  • Marketplace connectors (Amazon, Flipkart, etc.)

 

About zohaibk

We develop useful addons for #E-Commerce and #CRM software to provide extra features.#PrestaShop,#Magento,#SugarCRM,#Vtiger & #Android #apps
View all posts by zohaibk →