App reviews, troubleshooting, and recommendations
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello guys,
is there a problem, when I didn't use the Shopify Api like this:
First create a new application in either the partners admin or your store admin. For a private App you’ll need the API_KEY and the PASSWORD otherwise you’ll need the API_KEY and SHARED_SECRET.
For a private App you just need to set the base site url as follows:
python shop_url = "https://%s:%s@SHOP_NAME.myshopify.com/admin" % (API_KEY, PASSWORD) shopify.ShopifyResource.set_site(shop_url)
That’s it you’re done, skip to step 6 and start using the API! For a partner App you will need to supply two parameters to the Session class before you instantiate it:
python shopify.Session.setup(api_key=API_KEY, secret=SHARED_SECRET)
Now you’re ready to make authorized API requests to your shop! Data is returned as ActiveResource instances:
python shop = shopify.Shop.current # Get a specific product product = shopify.Product.find(179761209) # Create a new product new_product = shopify.Product() new_product.title = "Burton Custom Freestyle 151" new_product.product_type = "Snowboard" new_product.vendor = "Burton" success = new_product.save() #returns false if the record is invalid # or if new_product.errors: #something went wrong, see new_product.errors.full_messages() for example # Update a product product.handle = "burton-snowboard" product.save()
Alternatively, you can use temp to initialize a Session and execute a command which also handles temporarily setting ActiveResource::Base.site:
python with shopify.Session.temp("SHOP_NAME.myshopify.com", token): product = shopify.Product.find()
like they write it in the doc?
Now I use the API KEY with requests, like this: