Site icon PrestaShop | Magento | CRM Modules

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:


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

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

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


Β 

Exit mobile version