Skip to content

Instantly share code, notes, and snippets.

def make_request(path, method, payload=None):
# Use API Key and API Token that you've copied from
# your settings page.
headers = {
'apikey': 'apidemo@prisync.com',
'apitoken': 'c18888888888888888888fa135f540',
}
# This is the root URL. All API calls are relative to this URL.
base_url = "https://prisync.com/api/v2"
payload = {
# Name of the product
'name': 'iPhone X, GSM Unlocked 5.8", 64 GB - Space Gray',
# Brand (producer, supplier) of the item. You can set it to "No Brand" if you
# like to
'brand': 'Apple',
# A category you pick. It may be a category within your product hierarchy,
# or it can be a separate tag like "Discounted items", "Low traffic" etc.
# We are calling /add/product endpoint.
# Since this is a creation method, we use POST (in lowercase) as method.
response = make_request('/add/product', 'post', payload)
print(response.status_code, response.text)
urls = [
'https://thelovelystore.com/products/8893774-apple-iphonex-64gb-spacegray',
'https://www.coolblue.nl/product/793610/apple-iphone-x-64gb-zilver.html',
'https://www.apple.nl/shop/buy-iphone/iphone-x/5,8-inch-display-256gb-zilver',
'https://eurogsm.ro/apple-iphone-x-5-8-4g.html'
]
for url in urls:
payload = {
# A URL can be added to a particular product and we need product_id of that.
# Use the product_id you've written down in the previous example.
'product_id': 2055805,
# Just one URL at a time
'url': url
}
payload = {
'product0[name]': 'iPad with WiFi + Cellular, 32GB, Gold',
'product0[brand]': 'Apple',
'product0[category]': 'Computers - Tablets',
'product0[product_code]': 'B00M4L4NHY',
'product0[cost]': '439',
'product1[name]': 'Samsung Galaxy Tab A 10.1-Inch 16 GB',
'product1[brand]': 'Samsung',
'product1[category]': 'Computers - Tablets',
response = make_request('/add/batch', 'post', payload)
print(response.status_code, response.text)
response = make_request('/list/product', 'get')
print(response.status_code, response.text)
{
"results": [
{
"id": "2055805",
"name": "iPhone X, GSM Unlocked 5.8 - 64 GB - Space Gray",
"category": {
"id": "100358",
"name": "Unlocked Cell Phones"
},
"brand": {
response = make_request('/get/product/id/2055805', 'get')
print(response.status_code, response.text)