コード例 #1
0
ファイル: amazon.py プロジェクト: memobijou/erpghost
    def __init__(self, access_key, secret_key, account_id, api_data):
        self.api_data = api_data
        self.client = self.api_data.client

        self.orders_api = mws.Orders(
            access_key=os.environ.get("MWS_ACCESS_KEY"),
            secret_key=os.environ.get("MWS_SECRET_KEY"),
            account_id=os.environ['MWS_ACCOUNT_ID'],
            region="DE",
        )
        self.products_api = mws.Products(
            access_key=os.environ.get("MWS_ACCESS_KEY"),
            secret_key=os.environ.get("MWS_SECRET_KEY"),
            account_id=os.environ['MWS_ACCOUNT_ID'],
            region="DE",
        )
        self.reports_api = mws.Reports(
            access_key=os.environ.get("MWS_ACCESS_KEY"),
            secret_key=os.environ.get("MWS_SECRET_KEY"),
            account_id=os.environ['MWS_ACCOUNT_ID'],
            region="DE",
        )
        self.reports_api.get_report_request_list()
        self.orders_namespace = self.orders_api.NAMESPACE
        self.products_namespace = self.products_api.NAMESPACE
        self.reports_namespace = "{http://mws.amazonaws.com/doc/2009-01-01/}"
        self.orders = []
        super().__init__()
コード例 #2
0
 def get_products_api(self):
     return mws.Products(
         access_key=self.config.get('access_key'),
         secret_key=self.config.get('secret_key'),
         account_id=self.config.get('seller_id'),
         region=self.config.get('region'),
     )
コード例 #3
0
    def request(cls,
                mws_access_key,
                mws_secret_key,
                mws_account_id,
                mws_marketplace_id,
                asins=()):
        """
        Use python amazon mws to request get_matching_product_for_id.

        :param mws_access_key: Your account access key.
        :param mws_secret_key: Your account secret key.
        :param mws_account_id: Your account id.
        :param mws_marketplace_id: Your marketplace id
        :param asins: list of asins.
        :return:
        """
        products_api = mws.Products(mws_access_key, mws_secret_key,
                                    mws_account_id)
        response = products_api.get_competitive_pricing_for_asin(
            mws_marketplace_id, asins=asins)
        return cls.load(response.original)
コード例 #4
0
import mws
import logging
import time
from wholesale import settings
from wholesale.db.models import ProductAmazon
from wholesale.amazon.fees_api import FeesAPI
from decimal import Decimal

products_api = mws.Products(
    settings.AMAZON_MWS["AWS_ACCESS_KEY_ID"],
    settings.AMAZON_MWS["SECRET_KEY"],
    settings.AMAZON_MWS["SELLER_ID"],
    region="DE",
    auth_token=settings.AMAZON_MWS["MWS_AUTH_TOKEN"],
)

fees_api = FeesAPI(
    settings.AMAZON_MWS["AWS_ACCESS_KEY_ID"],
    settings.AMAZON_MWS["SECRET_KEY"],
    settings.AMAZON_MWS["SELLER_ID"],
    settings.AMAZON_MWS["MWS_AUTH_TOKEN"],
)

marketplace_id_germany = "A1PA6795UKMFR9"

last_matching_product_request_time = 0
last_competitive_pricing_request_time = 0
last_lowest_offer_listings_request_time = 0
last_fees_estimate_request_time = 0

コード例 #5
0
 def setUp(self):
     self.api = mws.Products(self.CREDENTIAL_ACCESS,
                             self.CREDENTIAL_SECRET,
                             self.CREDENTIAL_ACCOUNT,
                             auth_token=self.CREDENTIAL_TOKEN)
     self.api._test_request_params = True
コード例 #6
0
ファイル: Amzn.py プロジェクト: seanastrup/Amzn
import math

amazonPublicKey = os.environ.get('AmznPublicKey')
amazonSecretKey = os.environ.get('AmznSecretKey')
amazonAssociateID = os.environ.get('AmznAssociateId')
MWSAccessKey = os.environ.get('AmznMWSPublicKey')
MWSSecretKey = os.environ.get('AmznMWSSecretKey')
MWSAccountID = os.environ.get('AmznMWSSellerID')

timestamp = datetime.datetime.utcnow()
amzdate = timestamp.strftime('%Y%m%dT%H%M%SZ')
datestamp = timestamp.strftime('%Y%m%d')

amazon = bottlenose.Amazon(amazonPublicKey, amazonSecretKey, amazonAssociateID)
products_api = mws.Products(access_key=MWSAccessKey,
                            secret_key=MWSSecretKey,
                            account_id=MWSAccountID,
                            region='US')


class MwsCall:
    def get_xml_response(self):
        test_call = products_api.get_competitive_pricing_for_asin(
            asins='1250158060', marketplaceid='ATVPDKIKX0DER')
        return test_call.original


class AmazonCall:
    def get_XML_response(isbn, group):
        try:
            return amazon.ItemLookup(ItemId=isbn,
                                     SearchIndex='Books',
コード例 #7
0
import time
import datetime
from time import sleep

config = configparser.ConfigParser()
config.read('../../account.ini')
manne_conf = config['MANNE']

access_key = manne_conf['aws_access_key_id']
seller_id = manne_conf['seller_id']
secret_key = manne_conf['secret_key']
mws_auth_token = manne_conf['mws_auth_token']
marketplace_de = 'A1PA6795UKMFR9'

# mws test
products_api = mws.Products(access_key, secret_key, seller_id, region='DE')
inventory_api = mws.Inventory(access_key, secret_key, seller_id, region='DE')
reports_api = mws.Reports(access_key,
                          secret_key,
                          seller_id,
                          auth_token=mws_auth_token,
                          region='DE')
# products = products_api.list_matching_products(marketplaceid=marketplace_de, query='tv')
# print('amazon geht: ' + str(products.response.status_code == 200))

#
# # bigbuy test
# headers = {'Authorization': 'Bearer ' + manne_conf['bigbuy_api_key']}
# test_url = '/rest/catalog/categories.json?isoCode=de&_format=json'
# url = '/rest/shipping/carriers.json?_format=json'
# production_api = 'https://api.bigbuy.eu'
コード例 #8
0
def get_products(region, marketplace, pageNum, prodname):
    global cached_records
    print(region, marketplace)
    fetch_report()
    orders_api = mws.Reports(
        access_key='AKIAI5SXHL3KQ5TMYPQQ',
        secret_key='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',
        account_id='A3TUGG788NOEF7',
        region='UK')
    products_api = mws.Products(
        access_key='AKIAI5SXHL3KQ5TMYPQQ',
        secret_key='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',
        account_id='A3TUGG788NOEF7',
        region=region)
    for i in (orders_api.get_report_request_list(
            types=['_GET_MERCHANT_LISTINGS_ALL_DATA_'
                   ]).parsed['ReportRequestInfo']):
        if (i['ReportType']['value'] == '_GET_MERCHANT_LISTINGS_ALL_DATA_'
            ) and 'GeneratedReportId' in i:
            report_id = i['GeneratedReportId']['value']
            break
    report_lines = ((
        orders_api.get_report(report_id).parsed).decode('latin1').split('\n'))
    columns = {}
    for idx, column in enumerate(report_lines[0].strip().split('\t')):
        columns[idx] = column.strip().replace('\ufeff', '')
    records = []
    if prodname == '' or prodname == 'undefined':
        for i in report_lines[1:]:
            record = {}
            if i:
                for idx, j in enumerate(i.split('\t')):
                    record[columns[idx]] = j.strip().replace('\ufeff', '')
                record['SmallImage'] = products_api.get_matching_product(
                    marketplace,
                    [record['asin1']]).parsed['Product']['AttributeSets'][
                        'ItemAttributes']['SmallImage']['URL']['value']
                record['handle'] = ''.join(
                    ([c for c in record['item-name'].lower() if c.isalnum()]))

                record['in-shopify'] = bool(get_prod_id(record))
                data = get_prod(record)
                if data and '|' in data['title']:
                    record['restock-date'] = data['title'][data['title'].
                                                           rfind(' ') + 1:]
                records += [record]
    else:
        for i in report_lines[1:]:
            print(i)
            record = {}
            if i and prodname in i:
                for idx, j in enumerate(i.split('\t')):
                    record[columns[idx]] = j.strip().replace('\ufeff', '')
                record['SmallImage'] = products_api.get_matching_product(
                    marketplace,
                    [record['asin1']]).parsed['Product']['AttributeSets'][
                        'ItemAttributes']['SmallImage']['URL']['value']
                record['handle'] = ''.join(
                    ([c for c in record['item-name'].lower() if c.isalnum()]))
                record['in-shopify'] = bool(get_prod_id(record))
                data = get_prod(record)
                if data and '|' in data['title']:
                    record['restock-date'] = data['title'][data['title'].
                                                           rfind(' ') + 1:]
                records += [record]
    cached_records = records
    afile = open('records', 'wb')
    pickle.dump(records, afile)
    afile.close()
    return records
コード例 #9
0
ファイル: amazon.py プロジェクト: rgowen/BookInfoApi
    price = context.xpath('.//*[local-name()="Amount"]')[0].text
    return BookData(title, price, rank)


# load mws credentials from config file
with open(
        'mws.cfg', 'r'
) as f:  # 0 = MWS_ACCOUNT_ID, 1 = MWS_ACCESS_KEY, 2 = MWS_SECRET_KEY, 3 = MARKETPLACE_ID
    mws_cred = [line.strip() for line in f]


def isbn_to_asin(isbn):  # returns isbn10 (asin)
    clean = isbnlib.canonical(isbn)
    if (len(isbn) == 10):
        if (isbnlib.is_isbn10(clean)):
            return clean
        else:
            return '0'
    elif (len(isbn) == 13):
        if (isbnlib.is_isbn13(clean)):
            return isbnlib.to_isbn10(clean)
    else:
        return '0'


marketplace_id = mws_cred[3]  # easier to use variable for marketplace id
products_api = mws.Products(account_id=mws_cred[0],
                            secret_key=mws_cred[2],
                            access_key=mws_cred[1],
                            region='US')
コード例 #10
0
secret_key = conf['secret_key']
account_id = conf['seller_id']
auth_token = conf['mws_auth_token']
bigbuy_api_key = conf['bigbuy_api_key']
de_marketplace = 'A1PA6795UKMFR9'
region = 'DE'

#initialising
bigbuy_url = 'https://api.bigbuy.eu'
bb_header = {'Authorization': 'Bearer ' + bigbuy_api_key}
feed_api = mws.Feeds(access_key=access_key,
                     secret_key=secret_key,
                     account_id=account_id,
                     auth_token=auth_token)
products_api = mws.Products(access_key=access_key,
                            secret_key=secret_key,
                            account_id=account_id,
                            auth_token=auth_token)
reports_api = mws.Reports(access_key=access_key,
                          secret_key=secret_key,
                          account_id=account_id,
                          auth_token=auth_token,
                          region=region)


def get_sku_list():
    #changed report_type
    report_request = reports_api.request_report(
        report_type='_GET_MERCHANT_LISTINGS_ALL_DATA_',
        marketplaceids=de_marketplace)
    if report_request.response.status_code == 200:
        starting_date = datetime.datetime.now() - datetime.timedelta(hours=6)