Simplified and typed calls to Prestashop webservices.
Access all endpoints offered by Prestashop webservices as well as custom routes added by addons.
npm install @kasual-business/prestashop-api
Initialize the connection
You only need to initialize the api url and api key once.
import { init } from "@kasual-business/prestashop-api" ;
// Init the api url and api key
init ( "https://my-prestashop.com" , "my-api-key" ) ;
import prestashopAPI , { products } from "@kasual-business/prestashop-api" ;
await prestashopAPI . products . list ( ) ;
// or
await products . list ( ) ;
// List all products
await products . list ( ) ;
// Precise custom type
interface CustomProduct extends Product {
custom_key_from_addon: string ;
}
await products . list < CustomProduct > ( ) ;
Filter on name with exact match
// List all products having 1 as id_supplier
await products . list ( {
filters : [ { key : "id_supplier" , value : 1 } ] ,
} ) ;
Filter on name with containing operator
// List all products containing "orange" in name
await products . list ( {
filters : [ { key : "name" , value : "orange" , operator : "contains" } ] ,
} ) ;
// List all products and sort on id DESC
await products . list ( {
sort : [ "id_DESC" ] ,
} ) ;
// List all products and display only id and name
await products . list ( {
display : [ "id" , "name" ] ,
} ) ;
Pagination
// List all products and use skip and limit to paginate
await products . list ( {
skip : 0 ,
limit : 10 ,
} ) ;
It works like list except it only returns the first item of the list.
This can be useful when searching by EAN13, for example.
It avoids having to manipulate the returned array in order to obtain the first element.
// Returns the first product
await products . find ( ) ;
// Returns the first product having his ean13 equals to 123
await products . find ( {
filters : [ { key : "ean13" , value : "123" } ] ,
} ) ;
// Create a product
await products . create ( {
name : "name" ,
// ...rest of the mandatory values
} ) ;
// Create a product with multiple languages
await products . create ( {
name : [
{ id : 1 , value : "My Name 1" } ,
{ id : 2 , value : "My Name 2" } ,
] ,
// ...rest of the mandatory values
} ) ;
// Update product with id 1
await products . update ( 1 , {
name : "new name" ,
} ) ;
// Update the name of product with id 1 with multiple languages
await products . update ( 1 , {
name : [
{ id : 1 , value : "My Name 1" } ,
{ id : 2 , value : "My Name 2" } ,
] ,
} ) ;
// Update the name and the reference
await products . update ( 1 , {
name : [
{ id : 1 , value : "My Name 1" } ,
{ id : 2 , value : "My Name 2" } ,
] ,
reference : "my-ref" ,
} ) ;
// Delete product with id 1
await products . delete ( 1 ) ;
If you have an addon that add additional routes to prestashop's webservices, you can call them like this:
// list
await custom < { items : Item [ ] } > ( "my-custom-route" ) . list ( ) ;
// get
await custom < { item : Item } > ( "my-custom-route" ) . get ( 1 ) ;
// create
await custom < { item : Item } > ( "my-custom-route" ) . create < { name : string } > ( { name : "My name" } ) ;
// update
await custom < { item : Item } > ( "my-custom-route" ) . update < { name : string } > ( 1 , { name : "My new name" } ) ;
// delete
await custom < { item : Item } > ( "my-custom-route" ) . delete ( 1 ) ;
// list with custom query params
const searchParams = new URLSearchParams ( ) ;
searchParams . append ( 'myCustomId' , '1' ) ;
await custom < { items : Item [ ] } > ( 'my-custom-route' ) . list ( {
customSearchParams : searchParams ,
} ) ;
// send body as json instead of xml
await custom < { item : Item } > ( "my-custom-route" ) . create < { name : string } > ( { name : "My name" } , { json : true } ) ;
await custom < { item : Item } > ( "my-custom-route" ) . update < { name : string } > ( 1 , { name : "My new name" } , { json : true } ) ;
Name
Value
Description
display
'full' or string[]
Display specific keys
filters
{key: string; value: string OR number, operator?: Operator}[]
Filter on one or many params
limit
number
Limit the number of items
skip
number
Skip to the index (should specify limit)
sort
(${string}_ASC
OR ${string}_DESC
)[]
Sort ASC or DESC on one several keys
Note: In order to do an OR operator while filtering on a key, just append the same key multiple times.
import { products } from "@kasual-business/prestashop-api" ;
const listProducts = async ( ) => {
const response = await products . list ( {
filters : [
{ key : "id" , value : 1 } ,
{ key : "id" , value : 2 } ,
] ,
} ) ;
} ;
Name
Value
Description
display
'full' or string[]
Display specific keys
Name
Value
Description
display
'full' or string[]
Display specific keys
Name
Value
Description
display
'full' or string[]
Display specific keys
keysToExclude
string[]
Keys to exclude from body
Name
Value
Description
display
'full' or string[]
Display specific keys
Name
Value
Description
display
'full' or string[]
Display specific keys
customSearchParams
URLSearchParams
Add custom search params
Operator can be 'start'
, 'end'
, 'contains'
and 'strict'
.
Name
Parameters
Description
list
ListParams
List all addresses
find
ListParams
Find the first address
get
id, GetParams
Get an address by id
create
body, PostParams
Create an address
update
id, body, PutParams
Update an address by id
delete
id, DeleteParams
Delete an address by id
Name
Parameters
Description
list
ListParams
List all attachments
find
ListParams
Find the first attachment
get
id, GetParams
Get an attachment by id
create
body, PostParams
Create an attachment
update
id, body, PutParams
Update an attachment by id
delete
id, DeleteParams
Delete an attachment by id
Name
Parameters
Description
list
ListParams
List all carriers
find
ListParams
Find the first carrier
get
id, GetParams
Get a carrier by id
create
body, PostParams
Create a carrier
update
id, body, PutParams
Update a carrier by id
delete
id, DeleteParams
Delete a carrier by id
Name
Parameters
Description
list
ListParams
List all cart rules
find
ListParams
Find the first rule
get
id, GetParams
Get a cart rule by id
create
body, PostParams
Create a cart rule
update
id, body, PutParams
Update a cart rule by id
delete
id, DeleteParams
Delete a cart rule by id
Name
Parameters
Description
list
ListParams
List all carts
find
ListParams
Find the first cart
get
id, GetParams
Get a cart by id
create
body, PostParams
Create a cart
update
id, body, PutParams
Update a cart by id
delete
id, DeleteParams
Delete a cart by id
Name
Parameters
Description
list
ListParams
List all categories
find
ListParams
Find the first category
get
id, GetParams
Get a category by id
create
body, PostParams
Create a category
update
id, body, PutParams
Update a category by id
delete
id, DeleteParams
Delete a category by id
Name
Parameters
Description
list
ListParams
List all combinations
find
ListParams
Find the first combination
get
id, GetParams
Get a combination by id
create
body, PostParams
Create a combination
update
id, body, PutParams
Update a combination by id
delete
id, DeleteParams
Delete a combination by id
Name
Parameters
Description
list
ListParams
List all configurations
find
ListParams
Find the first configuration
get
id, GetParams
Get a configuration by id
create
body, PostParams
Create a configuration
update
id, body, PutParams
Update a configuration by id
delete
id, DeleteParams
Delete a configuration by id
Name
Parameters
Description
list
ListParams
List all contacts
find
ListParams
Find the first contact
get
id, GetParams
Get a contact by id
create
body, PostParams
Create a contact
update
id, body, PutParams
Update a contact by id
delete
id, DeleteParams
Delete a contact by id
Name
Parameters
Description
list
ListParams
List all content management systems
find
ListParams
Find the first management sytem
get
id, GetParams
Get a content management system by id
create
body, PostParams
Create a content
update
id, body, PutParams
Update a content by id
delete
id, DeleteParams
Delete a content by id
Name
Parameters
Description
list
ListParams
List all countries
find
ListParams
Find the first country
get
id, GetParams
Get a country by id
create
body, PostParams
Create a country
update
id, body, PutParams
Update a country by id
delete
id, DeleteParams
Delete a country by id
Name
Parameters
Description
list
ListParams
List all currencies
find
ListParams
Find the first currency
get
id, GetParams
Get a currency by id
create
body, PostParams
Create a currency
update
id, body, PutParams
Update a currency by id
delete
id, DeleteParams
Delete a currency by id
Name
Parameters
Description
list
ListParams
List all customer messages
find
ListParams
Find the first customer message
get
id, GetParams
Get a customer message by id
create
body, PostParams
Create a customer message
update
id, body, PutParams
Update a customer message by id
delete
id, DeleteParams
Delete a customer message by id
Name
Parameters
Description
list
ListParams
List all customer threads
find
ListParams
Find the first customer thread
get
id, GetParams
Get a customer thread by id
create
body, PostParams
Create a customer thread
update
id, body, PutParams
Update a customer thread by id
delete
id, DeleteParams
Delete a customer thread by id
Name
Parameters
Description
list
ListParams
List all customers
find
ListParams
Find the first customer
get
id
Get a customer by id
create
body, PostParams
Create a customer
update
id, body, PutParams
Update a customer by id
delete
id, DeleteParams
Delete a customer by id
Name
Parameters
Description
list
ListParams
List all customizations
find
ListParams
Find the first customization
get
id, GetParams
Get a customization by id
create
body, PostParams
Create a customization
update
id, body, PutParams
Update a customization by id
delete
id, DeleteParams
Delete a customization by id
Name
Parameters
Description
list
ListParams
List all deliveries
find
ListParams
Find the first delivery
get
id, GetParams
Get a delivery by id
create
body, PostParams
Create a delivery
update
id, body, PutParams
Update a delivery by id
delete
id, DeleteParams
Delete a delivery by id
Name
Parameters
Description
list
ListParams
List all employees
find
ListParams
Find the first employee
get
id, GetParams
Get an employee by id
create
body, PostParams
Create an employee
update
id, body, PutParams
Update an employee by id
delete
id, DeleteParams
Delete an employee by id
Name
Parameters
Description
list
ListParams
List all groups
find
ListParams
Find the first group
get
id, GetParams
Get a group by id
create
body, PostParams
Create a group
update
id, body, PutParams
Update a group by id
delete
id, DeleteParams
Delete a group by id
Name
Parameters
Description
list
ListParams
List all guests
find
ListParams
Find the first guest
get
id, GetParams
Get a guest by id
create
body, PostParams
Create a guest
update
id, body, PutParams
Update a guest by id
delete
id, DeleteParams
Delete a guest by id
Name
Parameters
Description
list
ListParams
List all image types
find
ListParams
Find the first image type
get
id, GetParams
Get an image type by id
create
body, PostParams
Create an image type
update
id, body, PutParams
Update an image type by id
delete
id, DeleteParams
Delete an image type by id
Name
Parameters
Description
create
ImageTypeRoute, productId, buffer, filename
Create an image
get
ImageTypeRoute, productId, path
Get an image
Name
Parameters
Description
list
ListParams
List all languages
find
ListParams
Find the first language
get
id, GetParams
Get a language by id
create
body, PostParams
Create a language
update
id, body, PutParams
Update a language by id
delete
id, DeleteParams
Delete a language by id
Name
Parameters
Description
list
ListParams
List all manufacturers
find
ListParams
Find the first manufacturer
get
id, GetParams
Get a manufacturer by id
create
body, PostParams
Create a manufacturer
update
id, body, PutParams
Update a manufacturer by id
delete
id, DeleteParams
Delete a manufacturer by id
Name
Parameters
Description
list
ListParams
List all messages
find
ListParams
Find the first message
get
id, GetParams
Get a message by id
create
body, PostParams
Create a message
update
id, body, PutParams
Update a message by id
delete
id, DeleteParams
Delete a message by id
Name
Parameters
Description
list
ListParams
List all order carriers
find
ListParams
Find the first order carrier
get
id, GetParams
Get an order carrier by id
create
body, PostParams
Create an order carrier
update
id, body, PutParams
Update an order carrier by id
delete
id, DeleteParams
Delete an order carrier by id
Name
Parameters
Description
list
ListParams
List all order cart rules
find
ListParams
Find the first order cart rule
get
id, GetParams
Get an order cart rule by id
create
body, PostParams
Create an order cart rule
update
id, body, PutParams
Update an order cart rule by id
delete
id, DeleteParams
Delete an order cart rule by id
Name
Parameters
Description
list
ListParams
List all order details
find
ListParams
Find the first order detail
get
id, GetParams
Get an order detail by id
create
body, PostParams
Create an order detail
update
id, body, PutParams
Update an order detail by id
delete
id, DeleteParams
Delete an order detail by id
Name
Parameters
Description
list
ListParams
List all order histories
find
ListParams
Find the first order history
get
id, GetParams
Get an order history by id
create
body, PostParams
Create an order history
update
id, body, PutParams
Update an order history by id
delete
id, DeleteParams
Delete an order history by id
Name
Parameters
Description
list
ListParams
List all order invoices
find
ListParams
Find the first order invoice
get
id, GetParams
Get an order invoice by id
create
body, PostParams
Create an order invoice
update
id, body, PutParams
Update an order invoice by id
delete
id, DeleteParams
Delete an order invoice by id
Name
Parameters
Description
list
ListParams
List all order payments
find
ListParams
Find the first order payment
get
id, GetParams
Get an order payment by id
create
body, PostParams
Create an order payment
update
id, body, PutParams
Update an order payment by id
delete
id, DeleteParams
Delete an order payment by id
Name
Parameters
Description
list
ListParams
List all order slips
find
ListParams
Find the first order slip
get
id, GetParams
Get an order slip by id
create
body, PostParams
Create an order slip
update
id, body, PutParams
Update an order slip by id
delete
id, DeleteParams
Delete an order slip by id
Name
Parameters
Description
list
ListParams
List all order states
find
ListParams
Find the first order state
get
id, GetParams
Get an order state by id
create
body, PostParams
Create an order state
update
id, body, PutParams
Update an order state by id
delete
id, DeleteParams
Delete an order state by id
Name
Parameters
Description
list
ListParams
List all orders
find
ListParams
Find the first order
get
id, GetParams
Get an order by id
create
body, PostParams
Create an order
update
id, body, PutParams
Update an order by id
delete
id, DeleteParams
Delete an order by id
Name
Parameters
Description
list
ListParams
List all price ranges
find
ListParams
Find the first price range
get
id, GetParams
Get a price range by id
create
body, PostParams
Create a price range
update
id, body, PutParams
Update a price range by id
delete
id, DeleteParams
Delete a price range by id
productCustomizationFields
Name
Parameters
Description
list
ListParams
List all product customization fields
find
ListParams
Find the first product customization field
get
id, GetParams
Get a product customization field by id
create
body, PostParams
Create a product customization field
update
id, body, PutParams
Update a product customization field by id
delete
id, DeleteParams
Delete a product customization field by id
Name
Parameters
Description
list
ListParams
List all product feature values
find
ListParams
Find the first product feature value
get
id, GetParams
Get a product feature value by id
create
body, PostParams
Create a product feature value
update
id, body, PutParams
Update a product feature value by id
delete
id, DeleteParams
Delete a product feature value by id
Name
Parameters
Description
list
ListParams
List all product features fields
find
ListParams
Find the first product feature field
get
id, GetParams
Get a product feature by id
create
body, PostParams
Create a product feature
update
id, body, PutParams
Update a product feature by id
delete
id, DeleteParams
Delete a product feature by id
Name
Parameters
Description
list
ListParams
List all product option values
find
ListParams
Find the first product option value
get
id, GetParams
Get a product option value by id
create
body, PostParams
Create a product option value
update
id, body, PutParams
Update a product option value by id
delete
id, DeleteParams
Delete a product option value by id
Name
Parameters
Description
list
ListParams
List all product options
find
ListParams
Find the first product option
get
id, GetParams
Get a product option by id
create
body, PostParams
Create a product option
update
id, body, PutParams
Update a product option by id
delete
id, DeleteParams
Delete a product option by id
Name
Parameters
Description
list
ListParams
List all product suppliers
find
ListParams
Find the first product supplier
get
id, GetParams
Get a product supplier by id
create
body, PostParams
Create a product supplier
update
id, body, PutParams
Update a product supplier by id
delete
id, DeleteParams
Delete a product supplier by id
Name
Parameters
Description
list
ListParams
List all products
find
ListParams
Find the first product
get
id, GetParams
Get a product by id
create
body, PostParams
Create a product
update
id, body, PutParams
Update a product by id
delete
id, DeleteParams
Delete a product by id
Name
Parameters
Description
list
value, languageId
Search in products and categories
Name
Parameters
Description
list
ListParams
List all shop groups
find
ListParams
Find the first shop group
get
id, GetParams
Get a shop group by id
create
body, PostParams
Create a shop group
update
id, body, PutParams
Update a shop group by id
delete
id, DeleteParams
Delete a shop group by id
Name
Parameters
Description
list
ListParams
List all shop urls
find
ListParams
Find the first shop url
get
id, GetParams
Get a shop url by id
create
body, PostParams
Create a shop url
update
id, body, PutParams
Update a shop url by id
delete
id, DeleteParams
Delete a shop url by id
Name
Parameters
Description
list
ListParams
List all shops
find
ListParams
Find the first shop
get
id, GetParams
Get a shop by id
create
body, PostParams
Create a shop
update
id, body, PutParams
Update a shop by id
delete
id, DeleteParams
Delete a shop by id
Name
Parameters
Description
list
ListParams
List all specific price rules
find
ListParams
Find the first specific price rule
get
id, GetParams
Get a specific price rule by id
create
body, PostParams
Create a specific price rule
update
id, body, PutParams
Update a specific price rule by id
delete
id, DeleteParams
Delete a specific price rule by id
Name
Parameters
Description
list
ListParams
List all specific prices
find
ListParams
Find the first specific price
get
id, GetParams
Get a specific price by id
create
body, PostParams
Create a specific price
update
id, body, PutParams
Update a specific price by id
delete
id, DeleteParams
Delete a specific price by id
Name
Parameters
Description
list
ListParams
List all states
find
ListParams
Find the first state
get
id, GetParams
Get a state by id
create
body, PostParams
Create a state
update
id, body, PutParams
Update a state by id
delete
id, DeleteParams
Delete a state by id
Name
Parameters
Description
list
ListParams
List all stock availables
find
ListParams
Find the first stock available
get
id, GetParams
Get a stock available by id
create
body, PostParams
Create a stock available
update
id, body, PutParams
Update a stock available by id
delete
id, DeleteParams
Delete a stock available by id
Name
Parameters
Description
list
ListParams
List all stock movement reasons
find
ListParams
Find the first stock movement reason
get
id, GetParams
Get a stock movement reason by id
create
body, PostParams
Create a stock movement reason
update
id, body, PutParams
Update a stock movement reason by id
delete
id, DeleteParams
Delete a stock movement reason by id
Name
Parameters
Description
list
ListParams
List all stock movements
find
ListParams
Find the first stock movement
get
id, GetParams
Get a stock movement by id
create
body, PostParams
Create a stock movement
update
id, body, PutParams
Update a stock movement by id
delete
id, DeleteParams
Delete a stock movement by id
Name
Parameters
Description
list
ListParams
List all stocks
find
ListParams
Find the first stock
get
id, GetParams
Get a stock by id
create
body, PostParams
Create a stock
update
id, body, PutParams
Update a stock by id
delete
id, DeleteParams
Delete a stock by id
Name
Parameters
Description
list
ListParams
List all stores
find
ListParams
Find the first store
get
id, GetParams
Get a store by id
create
body, PostParams
Create a store
update
id, body, PutParams
Update a store by id
delete
id, DeleteParams
Delete a store by id
Name
Parameters
Description
list
ListParams
List all suppliers
find
ListParams
Find the first supplier
get
id, GetParams
Get a supplier by id
create
body, PostParams
Create a supplier
update
id, body, PutParams
Update a supplier by id
delete
id, DeleteParams
Delete a supplier by id
Name
Parameters
Description
list
ListParams
List all supply order details
find
ListParams
Find the first supply order detail
get
id, GetParams
Get a supply order detail by id
create
body, PostParams
Create a supply order detail
update
id, body, PutParams
Update a supply order detail by id
delete
id, DeleteParams
Delete a supply order detail by id
Name
Parameters
Description
list
ListParams
List all supply order histories
find
ListParams
Find the first supply order history
get
id, GetParams
Get a supply order history by id
create
body, PostParams
Create a supply order history
update
id, body, PutParams
Update a supply order history by id
delete
id, DeleteParams
Delete a supply order history by id
supplyOrderReceiptHistories
Name
Parameters
Description
list
ListParams
List all supply order receipt histories
find
ListParams
Find the first supply order receipt history
get
id, GetParams
Get a supply order receipt history by id
create
body, PostParams
Create a supply order receipt
update
id, body, PutParams
Update a supply order receipt by id
delete
id, DeleteParams
Delete a supply order receipt by id
Name
Parameters
Description
list
ListParams
List all supply order states
find
ListParams
Find the first supply order state
get
id, GetParams
Get a supply order state by id
create
body, PostParams
Create a supply order state
update
id, body, PutParams
Update a supply order state by id
delete
id, DeleteParams
Delete a supply order state by id
Name
Parameters
Description
list
ListParams
List all supply orders
find
ListParams
Find the first supply order
get
id, GetParams
Get a supply order by id
create
body, PostParams
Create a supply order
update
id, body, PutParams
Update a supply order by id
delete
id, DeleteParams
Delete a supply order by id
Name
Parameters
Description
list
ListParams
List all tags
find
ListParams
Find the first tag
get
id, GetParams
Get a tag by id
create
body, PostParams
Create a tag
update
id, body, PutParams
Update a tag by id
delete
id, DeleteParams
Delete a tag by id
Name
Parameters
Description
list
ListParams
List all tax rule groups
find
ListParams
Find the first tax rule group
get
id, GetParams
Get a tax rule group by id
create
body, PostParams
Create a tax rule group
update
id, body, PutParams
Update a tax rule group by id
delete
id, DeleteParams
Delete a tax rule group by id
Name
Parameters
Description
list
ListParams
List all tax rules
find
ListParams
Find the first tax rule
get
id, GetParams
Get a tax rule by id
create
body, PostParams
Create a tax rule
update
id, body, PutParams
Update a tax rule by id
delete
id, DeleteParams
Delete a tax rule by id
Name
Parameters
Description
list
ListParams
List all taxes
find
ListParams
Find the first tax
get
id, GetParams
Get a tax by id
create
body, PostParams
Create a tax
update
id, body, PutParams
Update a tax by id
delete
id, DeleteParams
Delete a tax by id
Name
Parameters
Description
list
ListParams
List all translated configurations
find
ListParams
Find the first translated configuration
get
id, GetParams
Get a translated configuration by id
create
body, PostParams
Create a translated configuration
update
id, body, PutParams
Update a translated configuration by id
delete
id, DeleteParams
Delete a translated configuration by id
warehouseProductLocations
Name
Parameters
Description
list
ListParams
List all warehouse product locations
find
ListParams
Find the first warehouse product location
get
id, GetParams
Get a warehouse product location by id
create
body, PostParams
Create a warehouse product location
update
id, body, PutParams
Update a warehouse product location by id
delete
id, DeleteParams
Delete a warehouse product location by id
Name
Parameters
Description
list
ListParams
List all warehouses
find
ListParams
Find the first warehouse
get
id, GetParams
Get a warehouse by id
create
body, PostParams
Create a warehouse
update
id, body, PutParams
Update a warehouse by id
delete
id, DeleteParams
Delete a warehouse by id
Name
Parameters
Description
list
ListParams
List all weight ranges
find
ListParams
Find the first weight range
get
id, GetParams
Get a weight range by id
create
body, PostParams
Create a weight range
update
id, body, PutParams
Update a weight range by id
delete
id, DeleteParams
Delete a weight range by id
Name
Parameters
Description
list
ListParams
List all zones
find
ListParams
Find the first zone
get
id, GetParams
Get a zone by id
create
body, PostParams
Create a zone
update
id, body, PutParams
Update a zone by id
delete
id, DeleteParams
Delete a zone by id
Name
Parameters
Description
list
CustomGetParams
List all on custom endpoint
get
id, CustomGetParams
Get on custom endpoint by id
create
body, CustomParams
Create on custom endpoint
update
id, body, CustomParams
Update on custom endpoint by id
delete
id, body, CustomParams
Delete on custom endpoint by id