Skip to main content

Initialize

In this step, you will learn how to initialize API by setting up important data that will be used throughout the website.

Initialize an API to retrieve user login profile information, notifications, and categories while passing the bearer token of the logged-in user.

  • Endpoint: api/customer/initialize

  • Http Method: GET

If an authentication token is not sent in the header, the API will generate a new token and return it in the response as a guest user profile. If a token is sent in the header, the API will return the profile of the authenticated user.

  • Success Response:

The response contains the following information:

KeyDescription
categoriesA list of categories and their associated subcategories. Each category object contains the following information Categories Resource.
user_activethe user's account is currently active or not.
profileThe profile object contains the customer's ID, name, email, and phone number Customer Profile Resource.
localizationAn object of localization website that includes the following keys related to currency, flag and country Localization Resource.
unreadNotificationsthe count of unread notifications that the user has.
notificationsan array of notifications that the user has received Notification Resource.
giftsan array of gift items that the user has received.
cartan array of products that the user has added to their shopping cart Product Resource.
favourites_countthe count of products that the user has marked to their favorites list.
favouritesan array of products that the user has marked as favorites Product Resource.
compare_countthe count of products that the user has added to their comparison list.
comparean array of products that the user has added to their comparison list Product Resource.
cl_idThe unique identifier of the campaign.
last_order_idThe ID of the order that the customer did not rate. If the customer chooses to skip rating, the API will show the previous order for them to either skip or rate.
tip

Check the last_order_id key in the response. If the key is not null, it means there is a previous order that the customer did not rate. You can use this last_order_id to prompt the customer to rate the order and show a popup for rating. If the key is null, there are no pending orders to rate. you can check Rate Order API.

{
"code": 200,
"data": {
"localization": {
"name_en": "Saudi Arabia",
"name_ar": "السعودية",
"currency_code_en": "SAR",
"currency_code_ar": "ر.س",
//...
},
"categories": [
{
"name": "ELECTRONICS",
"name_en": "ELECTRONICS",
//...
}
],
"profile": {
"name": "Test",
"last_name": "API",
"email": "doc@supercommerce.io",
//...
},
"user_active": true,
"cart": [],
"gifts": [],
"favourites": [],
"compare": [],
"notifications": [
{
"title": "Order Status Change",
"title_ar": "تغيير حالة الطلب",
"body": "Order #6166 Status is now Shipped",
"body_ar": "تم تغيير حالة الطلب #6166 الي في الطريق",
//..
}
],
"cl_id": null
}
}
  • Query Parameters:
    • utm_campaign: (optional|string): a string representing the campaign name for tracking purposes

This would pass the value name of campaign for the utm_campaign parameter to the API endpoint. You could then use this parameter in your API logic to track the effectiveness of your summer sale campaign.

info

Check the following section to learn more about the Initialize API Reference