This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = make_request('/add/batch', 'post', payload) | |
print(response.status_code, response.text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = make_request('/list/product', 'get') | |
print(response.status_code, response.text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"results": [ | |
{ | |
"id": "2055805", | |
"name": "iPhone X, GSM Unlocked 5.8 - 64 GB - Space Gray", | |
"category": { | |
"id": "100358", | |
"name": "Unlocked Cell Phones" | |
}, | |
"brand": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = make_request('/get/product/id/2055805', 'get') | |
print(response.status_code, response.text) |
OlderNewer