Skip to main content

Setup

To talk to a shop you need two things: the shop's API base URL and a webservice API key. Both go into the client when you create it.

Getting an API key​

In the PrestaShop back office:

  1. Go to Advanced Parameters → Webservice and enable the webservice.
  2. Add a new key. PrestaShop generates the key string for you.
  3. Grant the key permissions for the resources you'll use (products, categories, stock, and so on) — and the HTTP methods you need (GET, POST, PUT, DELETE).
  4. Make sure the key is associated with your shop.

Your base URL is your shop URL followed by /api/, for example https://your-shop.com/api/.

note

The webservice uses HTTP Basic auth, with the API key as the username and an empty password. PrestaKit handles this for you, you just supply the key.

Creating the client​

Register the client once at startup:

using Microsoft.Extensions.DependencyInjection;

builder.Services.AddPrestaShopClient(options =>
{
options.BaseUrl = new Uri("https://your-shop.com/api/");
options.ApiKey = "YOUR_WEBSERVICE_KEY";
});

Then inject IPrestaShopClient anywhere:

public class ProductService(IPrestaShopClient client)
{
public Task<Product> GetAsync(long id) => client.Products.GetAsync(id);
}

The DI registration configures the underlying HttpClient (base address and authentication) for you, and its lifetime is managed by the container.

Options​

PrestaShopClientOptions has two properties:

PropertyTypeDescription
BaseUrlUriThe shop's API base URL, e.g. https://shop.com/api/.
ApiKeystringThe webservice API key.

Next: Make your first request.