def main(goalNumShops, jsonListingOutput): '''simple script to find goalNumShops number of shops from the etsy API, outputs shop listing data in json format''' api = Etsy('6hy9gw6rl7wbi4yklg3ezfx6', etsy_env=EtsyEnvProduction()) myNumShops = 0 myShops = [] #list of shops currOffset = 0 arbitraryOffset = 50 #for changing offset later currShopNames = {} while len(myShops) < goalNumShops: print currOffset, len(myShops) getMoreStores = api.findAllShops(limit=100, offset=(currOffset)) #this api call maxes out at 100. for shop in getMoreStores: if shop['shop_name']: myShops.append(shop) currShopNames[shop['shop_name']]=shop['shop_id'] if len(myShops) >= goalNumShops: break currOffset += arbitraryOffset #get a different offset from top time.sleep(1) #avoid making too many API calls too fast. currStoreListings = {} i = 0 for shop in myShops: print shop['shop_name'],i currStoreListings[shop['shop_name']] = api.findAllShopListingsActive(shop_id=shop['shop_id']) time.sleep(0.25)#so as to not making too many calls at once to API (gets angry when > 5 / second?) i+=1 jsonFile = open(jsonListingOutput,'wb') json.dump(currStoreListings,jsonFile, indent=4) jsonFile.close()
def etsy_colors(request, color): try: color_hex = name_to_hex(color) except ValueError: raise Http404('Color not valid') etsy = Etsy(settings.ETSY_CONSUMER_KEY, settings.ETSY_SHARED_SECRET) response = etsy.show_listings(color=color_hex) results = response['results'] if not results: raise Http404('no results') listings = [] for item in results: listing = {} listing['url'] = item['url'] listing['title'] = item['title'] result = etsy.get_image_for_listing(item['listing_id']) image_url = result['results'][0]['url_170x135'] listing['image_url'] = image_url listings.append(listing) return {'listings': listings, 'color': color}
def main(jsonListingInfo, jsonListingOutput): '''simple script to find storeData given a set of stores in the listing data from the etsy API, outputs shop data in json format''' api = Etsy('6hy9gw6rl7wbi4yklg3ezfx6', etsy_env=EtsyEnvProduction()) listingFile = open(jsonListingInfo,'r') theStores = json.load(listingFile) listingFile.close() storeData = {} i=0 for store in theStores: if i%50 == 0: #to watch progress of api calls print store, i storeData[store]=api.getShop(shop_id=store) time.sleep(0.5)#don't make etsy annnngrrry!! i+=1 jsonFile = open(jsonListingOutput,'wb') json.dump(storeData,jsonFile, indent=4) jsonFile.close()
oauth_consumer_secret=config.oauth_consumer_secret, etsy_env=etsy_env) else: sys.stderr.write('ERROR: You must set oauth_consumer_key and oauth_consumer_secret in config.py\n') sys.exit(1) if hasattr(config, 'oauth_token_key') and hasattr(config, 'oauth_token_secret'): oauth_client.token = oauth.Token( key=config.oauth_token_key, secret=config.oauth_token_secret) else: webbrowser.open(oauth_client.get_signin_url()) oauth_client.set_oauth_verifier(raw_input('Enter OAuth verifier: ')) write_config_file(oauth_client.token) etsy_api = Etsy(etsy_oauth_client=oauth_client, etsy_env=etsy_env, log=my_log) # print 'oauth access token: (key=%r; secret=%r)' % (oauth_client.token.key, oauth_client.token.secret) print('findAllShopListingsActive => %r' % etsy_api.findAllShopListingsActive(shop_id=config.user_id, sort_on='created', limit=1)) # print('getListing => %r' % etsy_api.getListing(listing_id=63067548)) print('findAllUserShippingTemplates => %r' % etsy_api.findAllUserShippingTemplates(user_id=config.user_id)) def testCreateListing(): print "Creating listing..." result = etsy_api.createListing( description=config.description, title=config.title,
etsy_env=etsy_env) else: sys.stderr.write('ERROR: You must set oauth_consumer_key and ' 'oauth_consumer_secret in config.py\n') sys.exit(1) if (hasattr(config, 'oauth_token_key') and hasattr(config, 'oauth_token_secret')): oauth_client.token = oauth.Token(key=config.oauth_token_key, secret=config.oauth_token_secret) else: webbrowser.open(oauth_client.get_signin_url()) oauth_client.set_oauth_verifier(input('Enter OAuth verifier: ')) write_config_file(oauth_client.token) etsy_api = Etsy(etsy_oauth_client=oauth_client, etsy_env=etsy_env, log=my_log) # print 'oauth access token: (key=%r; secret=%r)' % # (oauth_client.token.key, oauth_client.token.secret) print('findAllShopListingsActive => %r' % etsy_api.findAllShopListingsActive( shop_id=config.user_id, sort_on='created', limit=1)) # print('getListing => %r' % etsy_api.getListing(listing_id=63067548)) print('findAllUserShippingTemplates => %r' % etsy_api.findAllUserShippingTemplates(user_id=config.user_id)) def testCreateListing(): print("Creating listing...")
from etsy import Etsy e = Etsy('9avabtnm6p26odme939o3o8y', '293yf9k467') #print e.find_user('kakmedvedrbv') #print e.findAllUserFavoriteUsers('kakmedvedrbv') e.authorize(permissions=['favorites_rw']) #e.get_user_info('__SELF__')
def get_listing(listing_id): etsy_api = Etsy(api_key=Etsy_API_ID, etsy_env=etsy_env) listing_images = etsy_api.findAllListingImages(listing_id=int(listing_id)) listing_img_url = listing_images[0]['url_75x75'] return etsy_api.getListing(listing_id=listing_id), listing_img_url
import storagesqlite from etsy import Etsy storage = storagesqlite.Storage('etsy.db') e = Etsy(storage, '9avabtnm6p26odme939o3o8y', '293yf9k467', permissions=['favorites_rw']) def endpointfromuri(uri): parts = uri.split('/') result = '' params = [] for chunk in uri.split('/')[1:]: if chunk == '' or chunk[0] != ':': result += '/' + chunk else: result += '/%s' params.append(chunk[1:]) result = '\'' + result + '\'' if len(params) == 1: result += ' % ' + params.pop() elif len(params) > 1: result += ' % (' + ", ".join(params) + ')' return result def gen_method(record): template = """ def %s(self, %s): \"\"\"%s\"\"\" endpoint = %s
import config except ImportError: config = None write_config_file(oauth_token=None) if hasattr(config, 'oauth_consumer_key') and hasattr(config, 'oauth_consumer_secret'): oauth_client = EtsyOAuthClient( oauth_consumer_key=config.oauth_consumer_key, oauth_consumer_secret=config.oauth_consumer_secret, etsy_env=etsy_env) else: sys.stderr.write('ERROR: You must set oauth_consumer_key and oauth_consumer_secret in config.py\n') sys.exit(1) if hasattr(config, 'oauth_token_key') and hasattr(config, 'oauth_token_secret'): oauth_client.token = oauth.Token( key=config.oauth_token_key, secret=config.oauth_token_secret) else: webbrowser.open(oauth_client.get_signin_url()) oauth_client.set_oauth_verifier(raw_input('Enter OAuth verifier: ')) write_config_file(oauth_client.token) etsy_api = Etsy(etsy_oauth_client=oauth_client, etsy_env=etsy_env, log=my_log) # print 'oauth access token: (key=%r; secret=%r)' % (oauth_client.token.key, oauth_client.token.secret) print('findAllShopListingsActive => %r' % etsy_api.findAllShopListingsActive(shop_id=config.shop_id, sort_on='created', limit=1))
from etsy import Etsy import pandas as pd import matplotlib.pyplot as plt plt.rcParams['axes.labelsize'] = 14 plt.rcParams['xtick.labelsize'] = 12 plt.rcParams['ytick.labelsize'] = 12 api = Etsy(key_file='./.env') shops = [] for x in range(0,2): shops.append(api.findAllShops(shop_name='photography', limit=1)) shops shops_data = pd.DataFrame.from_records(shops) shops_data = shops_data.set_index('shop_name') shops_data.info() shops_data.head(3) // This is what we are trying to learn shops_data["num_favorers"] # In[ ] shops_data.plot(kind='scatter', x='listing_active_count', y='num_favorers', figsize=(5,3)) plt.show()
from etsy import Etsy import json import pprint e = Etsy('w31e04vuvggcsv6iods79ol7', 'dgicdc7qts') # gotten from signing up at etsy.com/developers #magenta_listings = e.show_listings(color='#FF00FF') -- this works wedding = e.findBrowseSegmentListings(keywords='wedding') # pprint.pprint(magenta_listings) #method_table = e.getMethodTable() print wedding
from etsy import Etsy e = Etsy("YOUR API KEY HERE") # get my User object: me = e.getUserDetails('muffinshop') print "people who favor %s" % me.user_name print #iterate through people that favorite me: for f in me.getFavorers(): if f.status != 'private': print f.user_name print print "%s's listings" % me.user_name print #get my shop s = me.getShopDetails() #iterate through my listings for l in s.getListings(): print l.title #Now, let's get all the mike's on etsy mikes = etsy.getAll(e.getUsersByName, search_name='mike') print "We found %d Mikes" % len(mikes)
from etsy import Etsy, getAll from os import environ e = Etsy(environ.get("ETSY_API_KEY", "YOUR API KEY HERE")) # get my Shop s = e.getShopDetails('mck254') print "people who favor the shop %s" % s.user_name print #iterate through people that favorite me: for f in s.getFavorers(): if f.status != 'private': print f.user_name print print "%s's listings" % s.user_name print #iterate through my listings for l in s.getListings(): print l.title #Now, let's get all the mike's on etsy mikes = getAll(e.getUsersByName, search_name='mike') print "We found %d Mikes" % len(mikes)