This post is an introduction to Prisync API V2.0, aiming to explain the foundations and beyond.

Let’s get directly into it.

The Problem

Let’s assume you are running an ecommerce website, called as “The Lovely Store”, The Lovely Store has a custom technology stack, which means you (and your team) developed it internally. (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, too: –> 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. Of course, 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, such as:

Every day, some products goes out of stock, some of them gets new stock availability in your inventory,

Stock unavailability happens on competitors’ websites,

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, right?

Well, if you are selling just 10 products, that’s right. All you need to do is:

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.

If you have 10 products and 5 major competitors, which makes 50 visit 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.)

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

More Problems On The Way

Let’s keep this straight, you don’t have just 10 products. An average e-commerce website has 1000 to 5000 SKUs, excluding variants [Quora Answer]. Let’s say The Lovely Store have 1200 SKUs. Now we have a conundrum: we need 144,000 seconds to check and set all the prices, on the other hand, a day has only 86,400 seconds. Well, 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, or you can use API V2.0. In this post, we’ll go into the tech parts and automate your daily job using the API V2.0.

You can quickly visit Prisync API V2.0 documentation for a quick glance. No worries, even if you don’t like to read the docs, I’ll provide a sweet level of details below.

API Basics Tutorial

1. Create API Key and API Token

I. Click My Account dropdown menu on your dashboard, on the right top corner (see the image below)

II. Click Settings from the dropdown

III. Click API Access Details tab from the opened page

IV. Note your API Key and API Token

You are ready to go now. Let’s proceed.

2. Adding the First Product

Your Prisync Dashboard has no products right now, as can be seen below:

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/productmethod: HTTP method, choose GET or POST according to the endpoint.payload: HTTP POST data, required for POST requests.

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

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

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

Now 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 and competitor URLs. Let’s assume we have 3 major competitors, selling exact same iPhone X configuration. So we need to add 4 URLs (1 for us and 3 for competitors) to the product we’ve added in previous example.

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

Since Prisync already gathered some of the URLs you track, it showed the price and stock availability, immediately. For the rest of the URLs, it’ll collect all the required information and start showing the prices/stocks in a few hours.

––

Now you can code a small middleware, connect your database and iterate over all your products; making a /add/product request for each of your products.

Then you can collect your own URLs and your competitor URLs, then you can call /add/url endpoint to complete your Prisync Dashboard.

3. Batch Import Your Products

There is a batch import endpoint in the API V2.0, so that instead of making one API call for each of your products, you can make a batch import to add up to 1000 products at a time.

/add/batch endpoint is very similar to /add/product endpoint, the only thing to change is the payload.

Batch imports are queued for your convenience, so that request returns a progress status immediately, instead of making your request wait until all is done:

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

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

Note: 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.

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

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

Conclusion

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!