Tryck enter för att se resultat eller Avbryt.

En ödmjuk introduktion till Prisync API V2.0

Detta inlägg är en introduktion till Prisync API V2.0, som syftar till att förklara grunden och bortom.

Låt oss komma direkt in i det.

The Problem

Let’s assume you are running an ecommerce website, kallas “Härlig Store”, Härlig Store har en anpassad teknik stack, vilket innebär att du (och ditt team) utvecklade det internt. (If you are using Magento, we have an app for that –> Prisync Magento App. If you are using Shopify, we have an app for that, för: –> Prisync Shopify App)

The Lovely Store has a bunch of serious competitors and the competition is so hot that in some products, prices change several times within a day. Självklart, there are more quiet product groups which see price changes just a few times in a week or less.

There are other concerns to handle, som:

  • Varje dag, some products goes out of stock, some of them gets new stock availability in your inventory,
  • Stock unavailability happens on competitors’ webbplatser,
  • New products arrives in your inventory every month

Intuitive Solution

What you basically want is to find and set the right prices for your products, so that you want to stay in the competition and still be profitable! So easy, höger?

Brunn, if you are selling bara 10 produkter, that’s right. Allt du behöver göra är:

  • Visit your 5 major competitors websites several times a day,
  • Collect the price and stock availability information,
  • Save them into an Excel file,
  • Run your price formulas on the Excel,
  • Note the results of the formulas,
  • Log in to admin dashboard of The Lovely Store,
  • Set new prices
  • Wait for your competitors to response and set their prices accordingly,
  • Rinse and repeat.

Om du har 10 produkter och 5 major konkurrenterna, which makes 50 Besök for just one data set of collection. You need to complete this robotic mission at least several times a day. Let’s say you spend 30 second on average for each webpage visit, noting the price and stock, checking the result of the formula and setting a new price on your admin dashboard. (30 seconds would be a world record, but anyway, let’s keep this simple.)

Grattis! You are spending 50 visits x 30 seconds/visit x 4 times which makes more than one and a half hour for just 10 produkter, igen, for just this robotic mission.

More Problems On The Way

Let’s keep this straight, you don’t have just 10 produkter. En average e-commerce website has 1000 till 5000 SKUs, excluding variants [Quora Answer]. Let’s say The Lovely Store have 1200 SKUs. Now we have a conundrum: we need 144,000 sekunder to check and set all the prices, Å andra sidan, a day has only 86,400 sekunder. Brunn, even if you don’t sleep, eat or leave the task for a second, you can only check half of your inventory manually.

Smarter Solution

Let’s do what smart people do and automate this boring task. Prisync provides just right tools for competitor price tracking and dynamic pricing. You can either import your products, track competitors and set your prices using Prisync web dashboard, eller du kan använda API V2.0. I det här inlägget, Vi ska gå in i de tekniska delarna och automatisera ditt dagliga jobb med den API V2.0.

Du kan snabbt besöka Prisync API V2.0 dokumentation för en snabb blick. Inga bekymmer, även om du inte gillar att läsa docs, Jag ska ge en söt nivå av detaljer nedan.

Självstudiekurs om grunderna i API

1. Skapa API-nyckel och API-Token

Skapa ett testkonto på https://prisync.com/register, då får din API-nyckel och API Token via:

Jag. Klicka på Mittkonto rullgardinsmenyn på instrumentpanelen, på det övre högra hörnet (Se bilden nedan)

II. Klicka på inställningar i listmenyn

III. API-uppgifter fliken från öppnade Sidan

IV. Notera din API-nyckel och API-Token

Prisync API-nyckel och API-Token

Du är redo att gå nu. Låt oss gå vidare.

2. Lägga till den första produkten

Instrumentpanelen Prisync har inga produkter just nu, som kan ses nedan:

Tom Prisync Dashboard - API Tutorial

We can now add our first product from a API consuming piece of code. You can call Prisync API V2.0 endpoints using any programming language, such as PHP, Python, Java, Perl or any other programming language.

I quickly implemented a generic method in Python language for making API requests. It takes 3 parameters:

make_request(path, method, payload=None)

path: Path of the API endpoint. E.g.: /add/product
method: HTTP method, choose GET or POST according to the endpoint.
payload: HTTP POST data, required for POST requests.

Obs: The code is tested with Python 2.7.3 och Python 3.5. You need just one Python package to run the examples: requests. You can install it via pip:

pip install requests

That’s all. Whole code of make_request method is just 20 lines, shown below:

We’ll use make_request method through all examples in rest of the blogpost.

We’re all set for adding the first product. Let’s prepare the data of our first product. Let’s assume our first product is the new mighty Apply iPhone X:

Faktiskt, the rest of addition is just calling the make_request method with the payload we prepared.

Result: (200, u'{"id":"2055805","result":true}')

Voilà! We added our first product to our Prisync account. This is how Prisync Dashboard looks now:

Prisync Dashboard With Single Product - API Tutorial

Let’s look into the API result, we’ll need that later:

response.status_code: 200, HTTP 200 code, indicating that

the operation was successful.

response.text: A JSON string, including a success message

if the operation is successful. If there happens an error,

this message will clarify the situation. Now addition

is successful, so that it returns the product_id of the

product we added and "result: true" message. Write down

the product_id, we'll use it in next example.

3. Adding my URL and competitor URLs to the product

Nu we’ve told Prisync that we are selling an iPhone X. Prisync Engine will start collection of prices and stock availability, right after we add our own URL och competitor URLs. Let’s assume we have 3 major konkurrenterna, selling exact same iPhone X configuration. So we need to add 4 URL: er (1 for us and 3 for competitors) to the product we’ve added in previous example.

–– My product page URL (which I sell iPhone X at):
https://thelovelystore.com/products/8893774-apple-iphonex-64gb-spacegray (Obviously a fake URL)

–– Competitor-1 product page URL:
https://www.coolblue.nl/product/793610/apple-iphone-x-64gb-zilver.html

–– Competitor-2 product page URL:
https://www.apple.nl/shop/buy-iphone/iphone-x/5,8-inch-display-256gb-zilver

–– Competitor-3 product page URL:
https://eurogsm.ro/apple-iphone-x-5-8-4g.html

Första, we’ll generate a list of URLs including those:

Sedan, let’s make a request to /add/url endpoint for each of the URLs.

…och, done. You’ve successfully added your URL and 3 competitor URLs. You’ll see 4 lines of response, each indicating a successful-200 result:

(200, u'{"id":"8273503","result":true}')
(200, u'{"id":"8273504","result":true}')
(200, u'{"id":"8273505","result":true}')
(200, u'{"id":"8273506","result":true}')

Nu, you have a fully operational product on your Prisync Dashboard. Let’s see how it looks:

Prisync Dashboard with Single Product and 4 URL: er - API Tutorial

Since Prisync already gathered some of the URLs you track, it showed the price and stock availability, immediately. For the rest of the URLs, den ska samla in all nödvändig information och starta visar de priser/lager i några timmar.

––

Nu kan du koda en liten middleware, Anslut din databas och iterera över alla dina produkter; att göra en /add/product begäran för varje produkt.

Sedan kan du samla dina egna webbadresser och din konkurrent webbadresser, sedan kan du ringa /add/url slutpunkten att slutföra din Prisync instrumentpanel.

3. Batch importera dina produkter

Det finns en batch importera slutpunkt i den API V2.0, så att istället för att göra ett API kallar för varje produkt, Du kan göra en batch importera för att lägga till upp till 1000 produkter i taget.

/lägga till/batch slutpunkten är mycket liknar /add/product Endpoint, Det enda att ändra är nyttolast.

Låt oss lägga 3 produkter på en gång:

Sedan ringa /lägga till/batch Endpoint:

Batch import köas för din bekvämlighet, så denna begäran returnerar ett framsteg ställningen omedelbart, instead of making your request wait until all is done:

(200, u'{"message":"Processing.

(%0)","status":"on_progress","total":"3","processed":0}')

Obs: Now you can either wait a bit to let the progress being completed, or you can make a call to /progress/batchImport endpoint to see the percentage completed.

Vanligtvis, batch imports are processed very fast, so this time there is no need to make a /progress/batchImport samtal. Now our Prisync Dashboard looks like this:

Prisync Dashboard with 4 Produkter - API Tutorial

We can now return to adding URLs to the product we’ve just added, as we’ve done in example 2.

Slutsats

In this introductory blog post, I explained simply how to use Prisync API V2.0. The examples I showed was really the introduction. After a few hours, Prisync will provide you full price and stock availability information and beyond that you will be able to create custom reports according to your company’s need, dynamically add/edit and delete products, add new competitors, set up a dynamic pricing engine with the rules you specified.

There are other API blog posts showing more examples, so stay in touch!