Back

PrestaShop API Essential Guide

Aug 9, 20246 minute read

What type of API does PrestaShop provide?

SOAP API

PrestaShop has traditionally supported a SOAP-based web service API. SOAP (Simple Object Access Protocol) is an XML-based messaging protocol for exchanging structured data between systems.

REST API

While not explicitly mentioned, many modern e-commerce platforms offer REST APIs, so PrestaShop likely supports REST as well. REST (Representational State Transfer) is an architectural style that uses HTTP methods to access and manipulate data resources.

GraphQL API

There is a third-party GraphQL module available for PrestaShop that enables GraphQL-based access to store resources. GraphQL is a query language and runtime for APIs that allows clients to request specific data they need.

Key points to consider:

  • The native PrestaShop API appears to be SOAP-based historically.
  • REST is very common for e-commerce platforms but not explicitly confirmed for PrestaShop.
  • GraphQL support is available through a third-party module, not natively.
  • The choice between API types often depends on specific project needs and preferences.

Best practices:

  • Evaluate your specific requirements to determine which API type best fits your use case.
  • Consider factors like ease of use, flexibility, performance, and compatibility with your tech stack.
  • If using the GraphQL module, follow the installation and setup instructions carefully.
  • Refer to PrestaShop's official documentation for the most up-to-date information on supported API types and best practices.

Does the PrestaShop API have webhooks?

Webhooks in PrestaShop API

The official PrestaShop API does have support for webhooks. However, the webhook functionality is primarily associated with PrestaShop Billing, which is a separate service from the core PrestaShop API.

Types of Events

The search results mention several types of events you can subscribe to:

  1. Subscription-related events:

    • Subscription created
    • Subscription updated
    • Subscription cancelled
  2. Other potential events (based on the API2Cart integration, which may differ from the official PrestaShop API):

    • Product updates
    • Order updates
    • Customer updates

Key Points to Consider

  1. Webhook Configuration:

    • Webhooks need to be configured manually in PrestaShop Billing.
    • You need to create a POST endpoint and communicate it to PrestaShop.
  2. Security:

    • PrestaShop adds an Authorization header to webhook requests for security.
    • The webhook system's IP address is 34.77.109.237, which you can use to filter incoming requests.
  3. Response Handling:

    • Your endpoint should return a 2xx HTTP status. If not, PrestaShop will retry sending the webhook at exponential time intervals.
  4. Event Processing:

    • You need to implement a way to process these events on your side.

Best Practices

  1. Implement proper security measures, such as validating the Authorization header and filtering requests based on the PrestaShop webhook IP address.

  2. Ensure your endpoint can handle retries and idempotent operations to avoid processing duplicate events.

  3. Consider caching certain data to reduce load on the store and improve performance, especially for relatively stable information.

  4. Use the cart.validate method if you need to clear the cache for a specific store after making changes.

While the official PrestaShop API does support webhooks, the functionality seems to be primarily focused on billing-related events. For more general events related to products, orders, or customers, you might need to explore additional solutions or third-party integrations.

Rate Limits and other limitations

Based on the search results provided, there is no specific information about API rate limits for the PrestaShop API. The search results do not contain any details about rate limiting for PrestaShop's API.

However, I can provide some general information about API rate limits and best practices:

Key points to consider:

  • Many APIs implement rate limiting to prevent abuse and ensure fair usage across clients.

  • Common rate limit approaches include:

    • Limits per time window (e.g. 100 requests per minute)
    • Daily limits
    • Limits per API key or user account
  • Rate limits are typically communicated via API documentation or response headers.

  • Exceeding rate limits usually results in HTTP 429 (Too Many Requests) errors.

Best practices:

  • Check the API documentation for any published rate limit information.

  • Monitor rate limit headers in API responses if provided.

  • Implement backoff and retry logic in your code to handle rate limit errors gracefully.

  • Consider caching API responses where appropriate to reduce the number of requests.

  • If you require higher limits, reach out to the API provider to discuss options.

Since the PrestaShop API documentation does not seem to specify rate limits, you may want to contact PrestaShop support directly to inquire about any limits that may be in place. Implementing conservative request rates and monitoring for rate limit errors would be a prudent approach when working with their API.

Latest API Version

Based on the search results provided, here are the key points regarding the most recent version of the PrestaShop API:

  1. The most recent stable version of PrestaShop is 8.1.5 [3].

  2. The latest development version is PrestaShop 9.0.0 Alpha 1, which was released on June 6, 2023 [3].

  3. The PrestaShop Webservice API allows merchants to give third-party tools access to their shop's database through a CRUD API [2].

Key points to consider:

  • PrestaShop 8 is the current major version, with 8.1.5 being the latest patch release [3].
  • The API documentation for PrestaShop 8 is available in the developer documentation [2].
  • PrestaShop is moving towards Symfony 6 and making significant changes in its architecture [3].

Best practices:

  • When developing for PrestaShop, always check the documentation for the specific version you're working with, as there may be differences between major versions.
  • Keep an eye on the PrestaShop GitHub repository for updates and new releases.
  • If you're starting a new project, consider using the latest stable version (8.1.5) unless you have specific requirements for an older version.

It's important to note that while PrestaShop 9.0.0 Alpha 1 has been released, it's not recommended for production use as it's still in the alpha stage. For production environments, the latest stable version (8.1.5) should be used.

How to get a PrestaShop developer account and API Keys?

To get a developer account for PrestaShop to create an API integration, here are the key steps:

1. Register with PrestaShop

You need to register with PrestaShop to get access to their developer resources. This can typically be done through their developer portal or by contacting their solutions engineering team.

2. Obtain Client Credentials

Once registered, you'll need to get your client credentials from PrestaShop. These are required to authenticate and access the APIs. Contact PrestaShop Solution Engineers ([email protected]) to obtain your client ID and secret.

3. Request an Access Token

With your client credentials, you can request an access token from the PrestaShop Authorization Server. This token is needed to make API calls. The process follows the OAuth 2.0 protocol.

4. Set Up Your Development Environment

Install PrestaShop locally or use a preconfigured environment to test your integration.

5. Integrate PrestaShop Account

You'll likely need to integrate PrestaShop Account into your module/application. This involves installing the PrestaShop Account component and configuring your module to work with it.

6. Review API Documentation

Familiarize yourself with the PrestaShop API documentation. It provides details on available endpoints, request/response formats, and best practices.

What can you do with the PrestaShop API?

Here are the key data models you can interact with using the PrestaShop API, along with what is possible for each:

Products

  • Read product information including name, price, images, combinations, etc.
  • Create new products
  • Update existing product details
  • Delete products
  • Manage product categories and attributes
  • Handle product stock/inventory

Orders

  • Retrieve order details including customer info, products ordered, totals, etc.
  • Create new orders
  • Update order status
  • Cancel orders
  • Manage invoices and shipping

Customers

  • Get customer account information
  • Create new customer accounts
  • Update customer details
  • Delete customer accounts
  • Manage customer groups and addresses

Carts

  • View active cart contents
  • Add/remove items from carts
  • Update cart quantities
  • Apply discounts/vouchers to carts
  • Convert carts to orders

Categories

  • Retrieve category tree and details
  • Create new categories
  • Update category information
  • Delete categories
  • Manage category hierarchy

Carriers/Shipping

  • Get available shipping carriers and methods
  • Create new shipping options
  • Update shipping rates and zones
  • Manage shipping restrictions

Prices/Currencies

  • Retrieve product prices and discounts
  • Manage currency exchange rates
  • Create/update specific prices and price rules

Stock

  • Check product stock levels
  • Update stock quantities
  • Manage warehouses and stock movements

Images

  • Upload product/category images
  • Retrieve image details and URLs
  • Delete images

Configurations

  • Get/set shop configuration values
  • Manage languages, localization settings
  • Update theme and layout options

This covers the main data models, but the API allows interaction with many other PrestaShop entities as well. The exact capabilities may vary depending on which specific API implementation is being used (e.g. native webservice vs REST API module).