HOGASHOP API
API Plans
An API user can subscribe to one of the following plans:
-
Free
-
Pro
-
Enterprise
Please refer to the website for more information https://hogalog.ch/preise-api/
Rate limiting
The data of the catalog output is refreshed based on the API plans as follows:
-
Free plan: monthly on 1st day of a month, at 08:10
-
Pro plan: weekly on Monday mornings, 08:30
-
Enterprise plan: daily in the morning, at 08:00
Provided information
The Free plan does not contain price information.
Ordering
-
Free & Pro plan: Use the basket endpoints to manage the basket. Provide the current basket-revision to the order endpoint to place an order from the basket.
-
Enteprise plan: Submit orders directly with the order endpoint, skipping the basket. It is recommended to calculate the basket items before submitting (basket calculate endpoint).
Departments ¶
GET /paginated/departments
Resource ¶
GET/paginated/departments{?search,limit,offset,sortBy,sortOrder,customerId}
Returns the list of available departments for the logged in user.
Example URI
- limit
number(optional) Default: 20- offset
number(optional) Default: 0- search
string(optional) Example: Adankquery string
- first
string(optional)comma separated list of department IDs to be listed first
- sortBy
string(optional)field name for sorting, available fields:
-
department_id
-
department_name
-
customer_id
-
customer_name
-
- sortOrder
string(optional)sorting direction,
ASCby default-
ASC
-
DESC
-
- customerId
number(optional)restricting list by customer Id
200Headers
Content-Type: application/jsonBody
{
"total": 3,
"items": [
{
"id": 2,
"name": "Küche",
"customer": {
"id": 2,
"name": "Gourmet-Restaurant"
},
"itemsInBasket": 0
},
{
"id": 74,
"name": "Biergarten",
"customer": {
"id": 60,
"name": "Gourmet-Restaurant"
},
"itemsInBasket": 3
},
{
"id": 79,
"name": "Bahnhof-Imbiss",
"customer": {
"id": 65,
"name": "Bahnhof-Imbiss"
},
"itemsInBasket": 0
}
]
}Products in Catalog ¶
-
GET /department/1168/available-products -
GET /department/1168/available-products/count
Resource ¶
GET/department/{departmentId}/available-products
Retrieves list of available products for a department.
Example URI
- departmentId
number(required) Example: 5ID of department
200Headers
Content-Type: application/jsonBody
[Schema](https://www.hogashop.ch/schema/productListItems.json)Resource ¶
GET/department/{departmentId}/available-products/count
Calculate amount of available products.
Example URI
- departmentId
number(required) Example: 5ID of department
200Headers
Content-Type: application/jsonBody
40345 (number) - total count of products in search queryProducts in Order Lists ¶
Only products from the department’s order lists are considered. Supplier order lists are excluded.
-
/department/1168/available-orderlist-products -
/department/1168/available-orderlist-products/count
Resource ¶
GET/department/{departmentId}/available-orderlist-products
Retrieves list of available products for a department currently on order lists.
Example URI
- departmentId
number(required) Example: 5ID of department
200Headers
Content-Type: application/jsonBody
[Schema](https://www.hogashop.ch/schema/productListItems.json)Resource ¶
GET/department/{departmentId}/available-orderlist-products/count
Calculate amount of available products, according to search query.
Example URI
- departmentId
number(required) Example: 5ID of department
200Headers
Content-Type: application/jsonBody
345 (number) - total count of products in search queryServer-Side Basket ¶
Always provide the Basket-Revision when modifying the basket endpoints. This way you will receive an error (409 Conflict) if the basket was modified by another user in the meanwhile.
-
GET /department/{departmentId}/basket- read the basket -
GET /department/{departmentId}/basket/overview- overview the basket (totals, without the items) -
POST /department/{departmentId}/basket/items- add products, suppliers IDs and EAN codes are supported -
PUT /department/{departmentId}/basket/part/{partIndex}/item/{itemIndex}- edit a basket item -
DELETE /department/{departmentId}/basket/part/{partIndex}/item/{itemIndex}- remove an item -
DELETE /department/{departmentId}/basket- empty basket -
PUT /department/{departmentId}/basket/part/{partIndex}- add comments, set delivery date -
POST /department/{departmentId}/order/basket-revision/{basket_revision}- Place order from basket
These resources give control over the user’s basket in HOGASHOP. The same basket that is visible when a user gets logged in to the HOGASHOP online application.
POST /department/{departmentId}/basket/calculated- validate an external basket
Resource ¶
GET/department/{departmentId}/basket
Read a basket for a department, considering currently authenticated user. Stored basket is re-calculated providing actual mutations.
Example URI
- departmentId
number(required) Example: 1234
200Headers
Content-Type: application/json
Basket-Revision: 123 - current basket revision numberSchema
:[Schema](https://www.hogashop.ch/schema/basket.json)404Headers
Content-Type: application/jsonBody
{
"message": "Department does not exist",
"code": 40411
}Resource ¶
DELETE/department/{departmentId}/basket{?revision}
Remove basket of a department for currently authenticated user
Example URI
- departmentId
number(required) Example: 1234- revision
number(required) Example: 1234last basket revision number that is known by the client.
204Headers
Content-Type: application/json
Basket-Revision: 123 - updated basket revision400Headers
Content-Type: application/jsonBody
{
"message": "The revision value is expected. The basket data may be out of date.",
"code": 400
}404Headers
Content-Type: application/jsonBody
{
"message": "Department does not exist",
"code": 40411
}409Headers
Content-Type: application/jsonBody
{
"message": "Concurrent update of basket",
"code": 4092
}Resource ¶
GET/department/{departmentId}/basket/overview
Read a basket for a department and return it without items, considering currently authenticated user. Stored basket is re-calculated providing actual mutations.
Example URI
- departmentId
number(required) Example: 1234
200Headers
Content-Type: application/json
Basket-Revision: 123 - current basket revision numberSchema
:[Schema](https://www.hogashop.ch/schema/basketOverview.json)404Headers
Content-Type: application/jsonBody
{
"message": "Department does not exist",
"code": 40411
}Resource ¶
POST/department/{departmentId}/basket/items{?source,ignoreErrors}
Add items to basket. After this the client should GET whole basket to obtain correct parts and totals.
When the basket has products the merge is performed with this rules:
-
Products of type 1 are never merged
-
Same products are merged: the amount of existing basket item will be increased, unless delivery dates are different.
Example URI
- departmentId
number(required) Example: 1234- source
string(optional) Example: webClient name or name of third-party
- ignoreErrors
number(optional) Default: 0 Example: 1Whether to add correct items, ignoring the bad ones.
Choices:
01
Add items to basketThe resource expects the following addToBasketRequest payload. Please refer to the schema for a comprehensive description of the payload structure.
Headers
Content-Type: application/jsonBody
[
{
"product": {
"id": 23
},
"sellingUnit": {
"name": "Sa",
"quantity": 5
}
}
]Schema
:[addToBasketRequest](https://www.hogashop.ch/schema/addToBasketRequest.json)201Headers
Content-Type: application/json
Basket-Revision: 123 - updated basket revisionSchema
:[addToBasketRequest](https://www.hogashop.ch/schema/addToBasketRequest.json)400Headers
Content-Type: application/jsonBody
{
"message": " ... any message about wrong addToBasketRequest schema ... ",
"code": 40023
}404Headers
Content-Type: application/jsonBody
{
"message": "Department does not exist",
"code": 40411
}409Headers
Content-Type: application/jsonBody
{
"message": "Concurrent update of basket",
"code": 4092
}422Headers
Content-Type: application/jsonSchema
:[addToBasketRequest](https://www.hogashop.ch/schema/addToBasketRequest.json)207This response is only possible when ignoreErrors=1 and there was some errors.
Headers
Content-Type: application/jsonSchema
:[addToBasketRequest](https://www.hogashop.ch/schema/addToBasketRequest.json)Resource ¶
PUT/department/{departmentId}/basket/part/{partIndex}/item/{itemIndex}{?revision,source}
Update an item in basket.
Example URI
- departmentId
number(required) Example: 1234- partIndex
number(required) Example: 1- itemIndex
number(required) Example: 2- revision
number(required) Example: 1234last basket revision number that is known by the client.
- source
string(optional) Example: webbasket item’s source.
Headers
Content-Type: application/jsonSchema
:[addToBasketRequestItem](https://www.hogashop.ch/schema/addToBasketRequest.json#/definitions/item)200Headers
Content-Type: application/json
Basket-Revision: 123 - updated basket revisionBody
"Ok"404Headers
Content-Type: application/jsonBody
{"message":"Department does not exist","code":40411}
{"message":"Basket item does not exist","code":40417}409Headers
Content-Type: application/jsonBody
{
"message": "Concurrent update of basket",
"code": 4092
}422Headers
Content-Type: application/jsonSchema
:[addToBasketRequestItem](https://www.hogashop.ch/schema/addToBasketRequest.json#/definitions/item)Resource ¶
DELETE/department/{departmentId}/basket/part/{partIndex}/item/{itemIndex}
Delete an item from basket.
Example URI
- departmentId
number(required) Example: 1234- partIndex
number(required) Example: 1- itemIndex
number(required) Example: 2- revision
number(required) Example: 1234last basket revision number that is known by the client.
204Headers
Content-Type: application/json
Basket-Revision: 123 - updated basket revision404Headers
Content-Type: application/jsonBody
{"message":"Department does not exist","code":40411}
{"message":"Basket item does not exist","code":40417}409Headers
Content-Type: application/jsonBody
{
"message": "Concurrent update of basket",
"code": 4092
}Resource ¶
PUT/department/{departmentId}/basket/part/{partIndex}{?revision,delivery_date,comment,referenceNumber}
Changes delivery date for a whole basket part or/and a comment for basket part
Example URI
- departmentId
number(required) Example: 1234- partIndex
number(required) Example: 1- revision
number(required) Example: 1234last basket revision number that knows the client
- delivery_date
string(required) Example: 2019-08-22delivery date in
YYYY-MM-DDformat- comment
string(required) Example: New comment- referenceNumber
string(required) Example: 22
200Headers
Content-Type: application/json
Basket-Revision: 123 - updated basket revisionBody
"Ok"400Headers
Content-Type: application/jsonBody
{"message": "Invalid delivery date", "code": 40030}
{"message": "Customer input is not allowed"}
{"message": "Not enough query parameters"}
{"message": "The revision value is expected. The basket data may be out of date."}404Headers
Content-Type: application/jsonBody
{"message": "Department does not exist", "code": 40411}
{"message": "Basket is empty", "code": 40416}
{"message": "Basket part index is not exist", "code": 40418}409Headers
Content-Type: application/jsonBody
{
"message": "Concurrent update of basket",
"code": 4092
}Resource ¶
POST/department/{departmentId}/basket/calculated
Calculate a basket object.
Mutations
When input basket has prices and delivery dates defined, the API will check if those values are correct. All values will be recalculated according to the business rules at the moment of this request, and will be written back in the same basket structure. Any differences will be reported in mutation property. When this property isn’t exists one can say that input basket is actual.
It is not necessary to provide dates and prices. The only required properties are “product” and “amount”. Giving that minimized basket the client side can obtain all the missed properties filled in in the response of this resource.
Example URI
- departmentId
number(required) Example: 1234- deliveryStrategy
string(optional) Default: define Example: defineWhat delivery strategy to use calculating delivery dates:
-
define - just define or approve already defined dates
-
unite - try to deliver all products in same day if possible
-
findNearest - select nearest delivery day for each product
Choices:
defineunitefindNearest-
- desiredDeliveryOn
string(optional) Example: 2016-01-01What delivery date is preferred. Resulting delivery dates will be not earlier than this date.
- orderSessionId
string(optional) Example: 7D143C15-D0DF-4718-90AC-022304D96300string used to check against order duplicates
- ignorePriceDecreaseMutation
number(optional) Default: 0 Example: 1show/don’t show prices mutation if was increased ones.
Choices:
01
Headers
Content-Type: application/jsonSchema
:[basket](https://www.hogashop.ch/schema/basket.json)200Headers
Content-Type: application/jsonSchema
:[Schema](https://www.hogashop.ch/schema/basket.json)400Headers
Content-Type: application/jsonBody
{"message":"Wrong department ID","code":4000}
{"message":"Unknown delivery strategy specified","code":40014}
{"message":"Invalid desired delivery date","code":40015}
{"message":" ... any message about wrong basket schema ... ","code":40017}404Headers
Content-Type: application/jsonBody
{
"message": "Department does not exist",
"code": 40411
}Ordering ¶
Always check that a response arrived after calling one of those endpoints.
-
POST /department/{departmentId}/order/basket-revision/{basket_revision}- Place order from basket -
POST /department/{departmentId}/order- order with external basket
Resource ¶
POST/department/{departmentId}/order{?deliveryStrategy,allowDuplicates,ignoreMutations,ignorePriceDecreaseMutation,archive,orderSessionId,supplierReference}
Create an order. Using provided basket the orders will be created. Each basket part produces one order. A basket part is a set of products provided by the same supplier delivered on the same day.
Delivery strategy
Parameter deliveryStrategy can be provided to make delivery dates for each product be calculated in different ways: deliver as fast as possible, deliver in the same day or do not define delivery date at all.
Allowing duplicate orders
Parameter allowDuplicates can to turn off duplicate orders protection. The API won’t create an order when exactly the
same set of products is already ordered or orderSessionId is a duplicate. See explanation of orderSessionId below.
Mutations
When the input basket has prices and/or delivery dates defined the API will apply the current business rules to confirm that information. Is it possible that in the moment of ordering the prices are changed or the delivery time is passed. This makes the request to be rejected with code “400 Bad request: basket isn’t actual”. To refresh the information a different API resource should be used, for example POST /department/{departmentId}/basket/calculated.
It is not necessary to provide prices and delivery dates in the basket, if your client side isn’t interested in validating them and report mutations. Orders will be created for nearest delivery dates with current prices. Parameter ignoreMutations can make API to create orders no matter if the basket actual or not.
Order session ID
Second level of duplicate orders protection.
The idea behind is to give an unique ID to a user’s session, the context a person in. For example when a user puts the first product in the basket the client application can generate this ID and remember. After order was created and the client application have received “201 Created” status code from the server this ID can be forgotten until next basket (set of products) will be collected.
This orderSessionId parameter should be provided in POST /department/{departmentId}/order request to make server to check if an order is already created within this session (with this basket). The duplicate is possible because of poor internet connection, when the client application does “create order” request but receives no response. This makes basket to remain, user can do request again. This time, when client application provide the same orderSessionId, the server won’t create a duplicate, but rejects the request with status code 409.
Example URI
- departmentId
number(required) Example: 1234- deliveryStrategy
string(optional) Default: define Example: defineWhat delivery strategy to use calculating delivery dates:
-
define - just define or approve already defined dates
-
unite - try to deliver all products in same day if possible
-
findNearest - select nearest delivery day for each product
-
withoutDate - send order without date
Choices:
defineunitefindNearestwithoutDate-
- allowDuplicates
number(optional) Default: 0 Example: 1Choices:
01- ignoreMutations
number(optional) Default: 0 Example: 1Choices:
01- ignorePriceDecreaseMutation
number(optional) Example: 1Show/don’t show prices mutation if was increased ones. +Default: 0
Choices:
01- archive
number(optional) Default: 0 Example: 1-
0 - normal order
-
1 - order is marked as “blind” - no notifications will be sent to supplier or customer
Choices:
01-
- orderSessionId
string(optional) Example: sessionIdentifierArbitrary string to identify order session.
- supplierReference
string(optional) Example: ref123Arbitrary string to identify supplier reference field.
Body
:[Schema](https://www.hogashop.ch/schema/basket.json)201List of created orders ids.
Headers
Content-Type: application/jsonBody
[
123,
124
]400Headers
Content-Type: application/jsonBody
{message: "Wrong department ID", code: 4000}
{message: " ... any message about wrong basket schema ... ", code: 40017}
for example {message: "The object must contain the properties ["customer","parts"].","path":"/", code: 40017}
{message: "Unknown delivery strategy specified", code: 40014}
{message: "Basket data is expired", code: 40019}403Headers
Content-Type: application/jsonBody
{message: "You have no rights to create orders", code: 4036}404Headers
Content-Type: application/jsonBody
{message: "Customer not found. Id: %s", code: 40411}
{message: "Department not found. Id: %s", code: 40411}409Headers
Content-Type: application/jsonBody
{message: "Using this data an order has already been created (order session id = {orderSessionId}).", code: 4090}
{message: "Same products already were ordered", code: 4091}500Body
any server errorResource ¶
POST/department/{departmentId}/order/basket-revision/{basket_revision}{?part,deliveryStrategy,allowDuplicates,ignoreMutations,ignorePriceDecreaseMutation,archive,orderSessionId,supplierReference}
Create an order using the basket stored at the server. See the detailed description in the POST /department/{departmentId}/order paragraph.
To make an order the client side should provide basket-revision. It protects from wrong orders, when basket has been updated by different client.
Example URI
- departmentId
number(required) Example: 1234- basket_revision
number(required) Example: 1234Current basket revision
- part
number(optional) Example: 1Number of basket part to place order. If omitted, order will be placed for the whole basket
- deliveryStrategy
string(optional) Default: define Example: defineWhat delivery strategy to use calculating delivery dates:
-
define - just define or approve already defined dates
-
unite - try to deliver all products in same day if possible
-
findNearest - select nearest delivery day for each product
-
withoutDate - send order without date
Choices:
defineunitefindNearestwithoutDate-
- allowDuplicates
number(optional) Default: 0 Example: 1Choices:
01- ignoreMutations
number(optional) Default: 0 Example: 1Choices:
01- ignorePriceDecreaseMutation
number(optional) Default: 0 Example: 1Show/don’t show prices mutation if was increased ones
Choices:
01- archive
number(optional) Default: 0 Example: 1-
0 - normal order
-
1 - order is marked as “blind” - no notifications will be sent to supplier or customer
Choices:
01-
- orderSessionId
string(optional) Example: sessionIdentifierArbitrary string to identify order session
- supplierReference
string(optional) Example: ref123Arbitrary string to identify supplier reference field
201List of created orders ids.
Headers
Content-Type: application/json
Basket-Revision: {newRevisionNumber} - only for partial ordersBody
[
123,
124
]400Headers
Content-Type: application/jsonBody
{message: "Wrong department ID", code: 4000}
{message: "Wrong revision number", code: 4000}
{message: "Wrong basket part", code: 4000}
{message: "Unknown delivery strategy specified", code: 40014}403Headers
Content-Type: application/jsonBody
{message: "You have no rights to create orders", code: 4036}
{message: "You have no rights to create archive orders", code: 4036}404Headers
Content-Type: application/jsonBody
{message: "Department not found. Id: %s", code: 40411}409Headers
Content-Type: application/jsonBody
{message: "Using this data an order has already been created (order session id = {orderSessionId}).", code: 4090}
{message: "Same products already were ordered", code: 4091}
{message: "Basket data is expired", code: 40019}500Body
any server error