Drücken Sie Enter, um das Ergebnis zu sehen oder Esc um abzubrechen.

Prisync API Tutorial Serie-2 sammeln die Produktdaten

Willkommen Sie bei der 2. Prisync API Tutorial Serie mit dem Ziel, die API Grundlagen klären.

In den ersten blogpost, Ich spekulierte über:

  • welche Probleme Prisync (und die API v2. 0) im Namen von euch löst,
  • Erstellen der API-Schlüssel und token,
  • Hinzufügen Ihr erste Produkt per API v2. 0,
  • Ihre URL und eine Reihe von Konkurrenten URLs hinzufügen,
  • and batch importing via the API.

PurposePrisync API Tutorial

In diesem Beitrag, I’ll go through gathering the data using Prisync API V2.0. Noch, you can re-visit the first post of Prisync API Tutorial Series and API documentation.

Erste Sachen erste, I’ll assume that you followed first post and you’ve already added a couple of products to your Prisync account. No worries if you don’t have any products. Just go back and complete the first tutorial or you can add products on your Dashboard. Außerdem, we’ll need the make_request method that we used in the first post so that let me recap it below:

It’s a tiny method which calls the API endpoints, adding the authentication headers.

Listing the Products You Have

Prisync API V2.0 has /list/product (link to doc) Endpunkt, which basically lists all products on your account.

All you need to do is making a request to the /list/product Endpunkt:

The response is below:

Voilà! I got all the products (since I only have 4 von ihnen) in just one request. results is a JSON array, returning list of products up to 100 items. When you have more than 100 Produkte, the result is paginated by 100. Therefore in every response, the API returns the next page’s URL so that you can iterate within a for loop.

Each item in the results list represents a single product. So each product contains:

  1. ID
  2. Name
  3. Category (both name and category ID)
  4. Brand (both name and brand ID)
  5. Product Code (SKU, EAN or any other internal product code)

Each product on your Prisync account has several URLs including your own URL and competitor URLs. Another step we reached, we now need to retrieve that URLs.

This is easy to do. What you need is calling the get a particular product (link to doc) Endpunkt. Let’s call it for theiPhone X, GSM Unlocked 5.8 – 64 GB – Space Gray“. I need the product id of it and it lays down in the /list/product request response:

id”: “2055805”
“Name”: “iPhone X, GSM Unlocked 5.8 – 64 GB – Space Gray”,iphone 8 space gray - Prisync API Tutorial

 

Getting the Particular Product

Seems like we are almost there. Let’s put the ID into the URL and call make_request method:

Here is the response:

This endpoint returns more details about the product, wie product_cost, external_ref, smart_price und URLs. Consequently we are interested in URLs, so we’ll dive into others in next posts.

Since we want to focus on urls field let’s dig it up. It contains an array of integers, each pointing to a URL belonging to this product. In this product, Es gibt 4 URLs whose IDs are 8273503, 8273504, 8273505 und 8273506.

Due to we have IDs of the URLs, next step is calling get a specific URL (link to doc) Endpunkt.

Getting a Particular URL

It is just a simple for loop iterating over all URL IDs and getting URL details:

and here is the output of the piece of code:

… (Es gibt 3 other URL data, so I just removed them for the sake of simplicity.)


In the URL details, there is several fields and most of them self explanatory. For the details of each field, you can look up in the API docs.

Since we have all the competitor prices, it is easy to write a piece of code to find the items which got mehr als 10% discounts today:

Schließlich, the output is:

Discount alert at https://www.CoolBlue.nl/Product/793610/Apple-iPhone-x-64GB-Zilver.html


And finally we know that CoolBlue.nl discounted the price more than 10% heute.


To sum up all the code of this post:

There are numerous things to do if you have access to the competitor prices, which Prisync can proudly present. Just to mention a few of them:

  • First of all you can monitor your competitors actively and generate custom alerts depending on your pricing strategy.
  • in addition to that, set your prices when the market is stale so that you can create volatility, which directly affects your profit margins.
  • Another feature you can develop is ignoring discounts if the stock is not available on the competitor.
  • in addition, you can implement other ideas that you and your team come up with!

Thanks for following up to this point. This is the second post of our API article series. See you in next posts of Prisync API Tutorial Series.