Badgezilla

Flex Theme Sections

Checkout Toolbox

Linear Shopping Experiences

Brand-It! Calendar

How to Bulk Create Shopify Collections using the API

Ever want to create collections for your Shopify store in bulk?  Well you can without an app.  It can be done through the Shopify API.  It's a bit technical, so this video is a primer on how to get it setup. 

Links

Transcript

Hey, Scott Austin here from Jade Puma. And in this space audio, I'm going to document the process that I figured out for bulk creating collections into your Shopify store using the API. So the scenario that I had was I needed to make like 160 something collections for a store that was all rules-based. And it's this store here that I'm still working on. Nice. And you should consider here, here's my collection names, which, you know, this is a B2B site. So this actually means something to, to the, the store owner and their customers, but it was kind of Greek for me and the rules for each one of them is let's just edit one of these collections here. And there's a rule is based on the product titles, having a similar long string also. So the concept of typing that out accurately 166 times was enough for me to say, there must be an easier way.

And I knew that I could do it in batch or in bulk through the API, but they didn't know how. And I had never done that before, and I couldn't find any good documentation on that. So I spent an evening figuring that out, and I wanted to document that for any of you that are trying to do the same thing. Hopefully my progress will get you moving forward. I am by no means an expert in this. This is probably the video that I'm going to make, that I know the least about the topic, but what I'm hoping to do in this video is point you in the right directions. So if you want to do bulk upload processes through the API, you'll learn enough from my video to get you started. So that's my goal here. Let's hope. Let's hope I can fulfill that, that vision.

So the way that you do it, the way I found you in API is with postman. So postman is a, and I'm using a windows PC. I assume postman is available on other platforms. It's an application, but I, I figured out to use postman's if you go to, you know, post-match search for postmen and you'll, you'll find them, you can download the product and all that good stuff. And it's a testing tool that devs use when they're building out API. So I don't know if it's the perfect tool for bulk uploading collections, but I got it to work and work quite well. So I was really happy with it. So the first thing you do when you download and install postmen. And so here's my Postman installation is what I figured out is if you go to and I searched for post-match Shopify, and you'll see this Shopify dash postmen, these documenter dot get postmen.com, we go view that website, right?

I already had it open there. There's all this documentation about the Shopify API and different ways to do all these different commands from within postman. And the beautiful thing is right. So what I wanted to do is create a collection of custom. And so that's a post thing. So this year documents for me, how the API with Shopify works. But the beautiful thing is if you click on, let me go to the top here. If you click on this button over here, run in postman, it adds all this documentation for you inside of your postmen app. So one click of a button it's all there. So let me show you Postman again. So over here, I have this Shopify from postman that I can expand and all that same documentation. Remember I was on products and then posts, and then there's all these different ways to, you know, post.

So what this is, is templates, right? So you can start looking at these and figuring out which one is closest to what you need for what you're trying to do. So I found one that was let me see. It was, I think it was this one here. Yeah. This one here or no, it was, it was that one. So I found the starting point. So it took that starting point and then I added it to my own implementation. So this collection here was Shopify from postman. I created another collection for Zeiss us, the store that I'm working on, copied it from there. And then I got this bulk Curry collection for lenses that I had now, it didn't have this collection name up here. It just said it was like in text or something collection name or in quotes. It would say collection names.

So you could type in anything you wanted for the collection name, but this gave me the starting point to work from, which was really, really valuable. So then the next thing you do is you go to your environments and you set some global settings. There's only one global setting that I, that I used, and that was the API version. So this is the Shopify current API. And right now, as I record, this is the current API version of Shopify is on, is 20 21 0 4. Now, if we go back to our Zeiss us oh, Nope. Not that Zeiss S my collection of [inaudible] bulk create what you'll see. Right? So this, this string here is the string that they're using. That postman is going to send to the Shopify servers as the API, you know, post to create the collection. And you see here, the API key right.

In, in brackets. So that just means it's a field. So my API key is stored in my global environments, right? Then I created a set of environments for my Shopify instance in this case, my [inaudible] and that was API key API password and store name. So what I did is I went into my Shopify admin for that store, went to apps, went to manage private apps and created a private app. I think it's this one right here for that instance. And that's where I got the, the key and password and added those in to postman. So you got to create a private app and the private app that I created, right. I had to give it the right permissions. So this private app, I gave permissions for products, which also gives permissions for creating of collection. So as this comes up here in a second, it's still loading, you'll see here admin API per permissions for product listings, which allows collections also and product, I wasn't sure which one was going to give me what I needed.

So I gave this private app, both of those permissions. So if we go back to postman, I set the Zeiss us variables for API key API password in store name. So the key in password complete private app and the store name is the the preface before they.my shopify.com. Right? So in this case here, it was, you know, this is ICU S right here before the, my shopify.com and those parameters, API key API password store name. If we go back to our collections and look at our post for the creating the collections in bulk bulk, create collections for lenses right up here, you see API password as a field store name as a field API version. So now I have defined at the environment level four of the parameters that you see up here in the post command. Now, the original template that I had started from, let me actually show that to you again, Shopify from post man products, custom collection post, I think it was this one here. You can see here that it didn't have, lets me check a couple of these other ones.

Yeah. And these, it didn't have the field at the end. I had to figure out how to do them. Now, this one here says, you know, custom collections dot Jason, and the one that I'm working on

It says smart collection stop Jason. And I don't remember exactly how I figured that out. Let me see if I can actually see it here.

So I don't know how I figured that one out that it was smart collections, not custom collections. I probably had to read some documentation to figure that out, but here we could go back to that. I had to add this other variable, which is the collection name. Now, if we look at the parameters of this, I defined a parameter called collection name, right. And I can put that in there anywhere at any place that I want to when we're editing that right here. If I wanted to, I could create a collection right now by just putting quote, collection name, quote, whatever. I want the collection name to be like my test collection or whatever. And it would do that. But I wanted to do some bulk, right, with 160 some collections. So that's why it's a variable instead of a name. And also what I have here under the body is the rule for the collection.

So the collection will be the collection name is going to be a value that I'm going to give it. And then the rules I sold also going to say that the title of the product in this smart collection must start with that same string. Now that could have been a separate string. Right. And if it was, then I would have to add two values under my parameters. But I could use one and it, it met my needs. Right. But you could have more than, you know, so these two different fields here, you could have two different, you know, have them be different instead of the same, if you want, you know, let's say the, the rule was any product whose title starts with aluminum would be in this collection. Then you could, you know, have a second value called, you know, product name or whatever you want it to be.

Would you have to define your parameters that you're going to use? So, you know, you're defining that parameter here at the global level, this one at the server environment level or the Shopify instance, you know, and then you see those are orange, cause they're defined in the environment. And then this red one here is defined within this definition that I making whatever they call this in postman. Which is complex thing. Like I said, I don't understand at all. So I got to work and I was super happy with that. Now, how do we do this in bulk though? Right. So what happens is what I at first thought was maybe I could make this text string and just repeat it 160 times, right. I could, you know, come with a little script that wrote that off of me 160 times. And then it, and then I input it and it did not work, right?

So this only ran, you know, this one line, what it's doing running this one line one time. So the way you, you don't have it, repeat from what I have found by adding more of these rows inside the body instead. And it's really not intuitive at all. If you look down here, there's this little icon that says Brunner. So what you do is you bring up honor and I'm going to add this other instance of runner. And what I did is you click your, whatever. We call this post ban definition for the API, right? This post thing, I click and drag that into runner. And I want to bring it in both.

Okay. Maybe, maybe it uses both. Let me see if I click and drag that I don't know why it's bringing them both of them, but I don't want to run one of them. Right. So, so I'm going to do that in runner. And what runner's going to do is it's going to run this based on another file, which I'm going to show you here in a second. And that's where I'm going to list out the 166 different collections that I want to make by doing this API call 166 times. So what you do is you create an external file. So here I have collections I did this back on 13 may CSV, right? And this, this file here. So if you had multiple memorize talking before, you might have more than one parameter, if you had more than one parameter, you have more than one column here, but right now only have one parameter collection names. So this, this collection name is identical to the parameter that I defined inside the definition. And then here are all the different names that I want for the collections in the rule. That's going to be applied about the product title also. So I, I just do that simple list, right?

I'm gonna close that out, not save. And then I go back into the runner and I say, select file for where the data is going to come from. And then I just select that collections 13 may, that I just had open. I opened that up and you'll notice here on iterations right now. It says one when I opened that up in analysis, 166. So it's read in that file found that there was the header row with the collection name parameter in it, and 166 values below that. So now it is queued up and ready to run that bolt, create process. Remember, it's going to run this, this part here once here, but runner's going to run it 166 times. So that's how you get from creating one collection to creating a mass of collections. And just so you know, what I also did in this is I just defined in, in the creation of the collection.

I also define that the image will be the same for all of them, but that also could have been another parameter. I could have had a different collection image for each one of these collections and put that into my spreadsheet also. Or am I CSV? So then if I asked to run this right now and I've already got these collections in my store, so I'm not going to run it again. When I first started doing this, I would run it and it wasn't working for me. And it took me a while to figure out a solution and what it was is every, every single line it would run it. And it was waiting for a check that it had worked properly. And that's here in this test thing. And the test doesn't show up, like when I was showing you before the Preqin ones from, you know, post man, there's no test defined in those.

So if I go into one of these, there's no test. So it took me a little bit of work. And like I said, it's, this is one of those things. I don't know exactly how, what I did work, but it works right. If I go back to my instance, you know, I, I was able to figure out how tests were formatted and through some trial and error, I figured out it was looking for a 2 0 1 code. So once I had this end, I was off to the races and, and made all 166 collections really quickly. But it took me a while to figure out that I need to define the test. And it took me a while to figure out what the code was that it was, I don't even know what the 2 0 1 code stands for. It's you move out to figure out that it was looking for a 2 0 1.

But once I did that it works really well. So let me show you in shop over the Shopify store on this page here, all these collections, the 166 of them, remember I said, they all had the same image. They all have the same image here. And so these got created from this process that I just showed you. And it, once I got it set up and run and it took seconds to create them. And the whole process of figuring out how to do this was probably still quicker than me typing in manually 166 times and verifying that I got it right every single time, because that would put me to sleep. It, it was probably less time to figure out this whole process than to do it manually. But now what's fabulous is I have this tool that I can do bulk creation of collections for any of my clients now.

Right? So now in postman, let's go back to post man, I've got this bulk create collections for lenses to find, and I can change that. You know, so if I want it to have, you know, unique images, I can change that. If I want to change the rules, I can change that. And then my environments, all I have to do is create a new environment for a new client store, with those in create a private app and put the right API password store, name, and API or API key in there. And then I can just reuse this like I, whatever they call this in post man, this, this, this little creation that I made to now, I can easily bulk create collections for any one of my clients using this this man and Shopify API structure. Cause it's really re repeatable and really easily, right?

Because these parameters, you know, I'll have to do is change the environment. So I've added a new environment here for a new server. All I do is say, now let's use that environment and this command would run perfectly to that other Shopify instance. So I'm really impressed with how well this works and how I can use this now across all my stores. And I'm sure what's going to happen in a year's time. I'm going to have my own set of collections for tasks that I want to do, that I can just use and reuse across my different clients as needed by just changing out the environment. So I'm really happy to figure this out. Hopefully this video gives you enough knowledge to start implementing a structure like this for you, if you want it for your store or for your agency. Like I said, it doesn't have all the answers. I definitely don't know everything about this, but I'm just hoping it gives you enough to, to see the potential and go off and start implementing it on your, on your side. Thanks for watching.


JadePuma is a certified Shopify Expert. If you need any help with your Shopify store, we can help.


Search