Skip to content

Instantly share code, notes, and snippets.

Prisync prisync

View GitHub Profile
View API Series-2.py
import json
import requests
def make_request(path, method, payload=None):
# Use API Key and API Token that you've copied from
# your settings page.
headers = {
'apikey': 'internal-test-samet-20171227-1@prisync.com',
'apitoken': 'c19287f99149b8c2dca88bcfa135f540',
}
View 10pc_discounted_items.py
response = make_request('/get/product/id/2055805', 'get')
print(response.text)
product_details = json.loads(response.text)
urls = product_details['urls']
for url in urls:
url_response = make_request('/get/url/id/{}'.format(url), 'get')
print(url_response.text)
url_info = json.loads(url_response.text)
View iterate_over_urls_response.json
{
"id": "8273504",
"url": "https://www.coolblue.nl/product/793610/apple-iphone-x-64gb-zilver.html",
"price": "1357.29",
"in_stock": 1,
"last_check": "2018-03-20 11:25:43",
"change_day": "199.30",
"currency": "EUR",
"last_changed": "20/03/2018",
"old_price": "1157.99"
View iterate_over_urls.py
response = make_request('/get/product/id/2055805', 'get')
print(response.text)
product_details = json.loads(response.text)
urls = product_details['urls']
for url in urls:
url_response = make_request('/get/url/id/{}'.format(url), 'get')
print(url_response.text)
View get_particular_product_response.json
{
"id": "2055805",
"name": "iPhone X, GSM Unlocked 5.8 - 64 GB - Space Gray",
"category": {
"id": "100358",
"name": "Unlocked Cell Phones"
},
"brand": {
"id": "191815",
"name": "Apple"
View get_particular_product.py
response = make_request('/get/product/id/2055805', 'get')
print(response.status_code, response.text)
View list_products_response.json
{
"results": [
{
"id": "2055805",
"name": "iPhone X, GSM Unlocked 5.8 - 64 GB - Space Gray",
"category": {
"id": "100358",
"name": "Unlocked Cell Phones"
},
"brand": {
View list_products.py
response = make_request('/list/product', 'get')
print(response.status_code, response.text)
View batch-import-call.py
response = make_request('/add/batch', 'post', payload)
print(response.status_code, response.text)
View 3-products-payload.py
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',
You can’t perform that action at this time.