We love to print
Skip navigation
European store – switch to MOO's USA storeWelcome to the MOO API. This page will help you create applications that utilise our API. We've tried to make things as simple as possible so people with little or no programming experience can use it.
It's a simple 4 stage process:
So, let's have a look at the 4 stages in a little more depth
An XML document is specifies the pack you'd like to create. The level of detail that you add to the document determines where you the user is placed in the process. For example, if you define a list of images that you want the user to select from to make a pack of cards, then they will be forwarded to the 'chooser' page. If you specify a list of images that you want them to actually use, and the 'crop' data associated with them then the user will be sent to the part of the process where they design the back of the cards. Now, we can do this the hard way or the easy way. I prefer easy, so let's look at an example of a simple request:
<?xml version="1.0" encoding="UTF-8"?>
<moo xsi:noNamespaceSchemaLocation="http://uk.moo.com/en/xsd/api_0.7.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<request>
<version>0.7</version>
<api_key>3ddbe3c0-17ac-c0a802d2-47bafd19-2473</api_key>
<call>build</call>
<return_to>http://www.google.co.uk</return_to>
<fail_to>http://www.google.co.uk</fail_to>
</request>
<payload>
<chooser>
<product_type>minicard</product_type>
<images>
<url>http://farm3.static.flickr.com/2300/2179038972_23d2a1ff40_o.jpg</url>
</images>
<images>
<url>http://farm3.static.flickr.com/2266/2178246585_14139d6905_o.jpg</url>
</images>
<images>
<url>http://farm3.static.flickr.com/2290/2178246751_a5124fdbc7_o.jpg</url>
</images>
</chooser>
</payload>
</moo>
The above example shows how to populate the list of images that a user can choose from to make a Minicard pack with. Let's have a look at the elements that we have there. First, there's the request header:
Next we have the payload of the actual request. As you can see, this is a chooser operation. This will place the images specified below into a window that the user can drag from to select which images they would like in their pack. You can specify more images than you would actually be able to fit into your chosen product here, upto 200 images. Let's look at what needs to be defined for the chooser:
And that as they say is that... For that type of request at least. Next, we'll go on to look at requests where we pre-select images for the user and also supply cropping data for them. But, before we do, there's something you should know about image URLs...
Image URL notes: In order to avoid importing the same file over and over again every time you run your XML against this system, we store the URL that we picked the image up from, so if we see it again, we don't bother downloading it again. Can you see where this is going? Yup, if you change the image but use the same URL as a previous one that you've submitted to us, we won't pick up the new one, so remember to keep those URLs unique! You might also want to know that we currently only accept gifs, pngs and jpegs.
Image notes: Currently we support GIF, JPEG and PNG images at a minimum resolution of 300px x 300px.
<?xml version="1.0" encoding="UTF-8"?>
<moo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://uk.moo.com/en/xsd/api_0.7.xsd">
<request>
<version>0.7</version>
<api_key>3ddbe3c0-17ac-c0a802d2-47bafd19-2473</api_key>
<call>build</call>
</request>
<payload>
<products>
<product>
<product_type>sticker</product_type>
<designs>
<design>
<image>
<url>http://farm3.static.flickr.com/2300/2179038972_23d2a1ff40_o.jpg</url>
<type>variable</type>
</image>
</design>
<design>
<image>
<url>http://farm3.static.flickr.com/2266/2178246585_14139d6905_o.jpg</url>
<type>variable</type>
</image>
</design>
<design>
<image>
<url>http://farm3.static.flickr.com/2290/2178246751_a5124fdbc7_o.jpg</url>
<type>variable</type>
</image>
</design>
</designs>
</product>
</products>
</payload>
</moo>
Don't want to give the user some choice? Just want to get them on in there? Then you should have a look at the XML above. It allows you to drop a load of images directly into the making process for your given product type (in the example above it is stickers). The user will then be taken directly to the cropper page when they will be able to trim the image as they see fit. The request header is the same in this example (except we're not defining the return_to and fail_to elements so this will use the defaults). What has changed is the contents of the payload. Here, we've defined one product (all that is currently allowed) and in it we have:
<?xml version="1.0" encoding="UTF-8"?>
<moo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://uk.moo.com/en/xsd/api_0.7.xsd">
<request>
<version>0.7</version>
<api_key>3ddbe3c0-17ac-c0a802d2-47bafd19-2473</api_key>
<call>build</call>
</request>
<payload>
<products>
<product>
<product_type>sticker</product_type>
<designs>
<design>
<image>
<url>http://farm3.static.flickr.com/2290/2178246751_a5124fdbc7_o.jpg</url>
<type>variable</type>
<crop>
<auto>true</auto>
</crop>
</image>
</design>
<design>
<image>
<url>http://farm3.static.flickr.com/2300/2179038972_23d2a1ff40_o.jpg</url>
<type>variable</type>
<crop>
<manual>
<x>161</x>
<y>203</y>
<width>572</width>
<height>572</height>
</manual>
</crop>
</image>
</design>
<design>
<image>
<url>http://farm3.static.flickr.com/2266/2178246585_14139d6905_o.jpg</url>
<type>variable</type>
<crop>
<manual>
<x>263</x>
<y>139</y>
<width>495</width>
<height>495</height>
</manual>
</crop>
</image>
</design>
</designs>
</product>
</products>
</payload>
</moo>
Things start to get a little bit more complex here. The above XML shows two different ways in which you can add cropping data to your images. You can mix and match these methods if you like, but you must either add cropping instructions for all images or none of them. We'll start with the easy one. By adding crop -> auto -> true to the image definition we will automatically add in the crop information for you based on the largest possible area that we can fit in the shape of the product that you want to make.
You can also specify your own crop data. For this you need to use the manual element:
Cropping rules: You'll need to make sure that the cropping area you specify obeys the following rules:



<?xml version="1.0" encoding="UTF-8"?>
<moo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://uk.moo.com/en/xsd/api_0.7.xsd">
<request>
<version>0.7</version>
<api_key>3ddbe3c0-17ac-c0a802d2-47bafd19-2473</api_key>
<call>build</call>
</request>
<payload>
<products>
<product>
<product_type>minicard</product_type>
<designs>
<design>
<image>
<url>
http://farm3.static.flickr.com/2290/2178246751_a5124fdbc7_o.jpg
</url>
<type>variable</type>
<crop>
<auto>true</auto>
</crop>
</image>
<text_collection>
<minicard>
<text_line>
<id>1</id>
<string>This is line 1</string>
<bold>true</bold>
<align>left</align>
<font>modern</font>
<colour>#ff0000</colour>
</text_line>
<text_line>
<id>2</id>
<string>This is line 2</string>
</text_line>
<text_line>
<id>3</id>
<string>This is line 3</string>
</text_line>
<text_line>
<id>4</id>
<string>This is line 4</string>
</text_line>
<text_line>
<id>5</id>
<string>This is line 5</string>
</text_line>
<text_line>
<id>6</id>
<string>This is line 6</string>
</text_line>
</minicard>
</text_collection>
</design>
</designs>
</product>
</products>
</payload>
</moo>
The XML above shows a simple definition of the text for the back of a minicard. The important thing to note is that in addition to the image definition in the design element there is also a text_collection element. This does not have be defined. Obviously, leaving it blank will mean that you don't want any text on the back of this particular card. If text is required, you then need to specify the type of text it is. Here, because we're making a minicard, we have added the minicard container. (The container element should always be the same as the content_type element or you'll get an error. Then, we define each text_line as show below
Below are some example XML documents and PDF files of the text that they produce. It'll help you understand how the id relates to the position of the text for each product that we have text for.
Once you've created your XML document, you should test it out to make sure that it's okay. We've made a little tool to help you with this. Simply drop the XML into the text box, check the 'is dev' check box and submit the XML. We'll have a peek at it and tell you if there's anything wrong with it. Simple!
You can also test out what would actually happen for the user by unchecking the 'is dev' box. This will parse the XML and then drop you into the design process as if you were a user. Doing this before you put the XML on your site has the added bonus of caching all the images that you wish to use in our system.
There are two methods you can use to now use the XML that you have created. They are the direct and browser methods. Both require you to post your document to http://uk.moo.com/en/api/api.php.
The browser method: This method uses the browser to do all the work and does not require server side scripting to communicate with our server. For this, all you need to do is to get the user to POST the XML to us. To do this you need to wrap the XML in a POST FORM. See below for an example
<form method="POST" action="http://uk.moo.com/en/api/api.php">
<input type="hidden" name="xml" value="
<?xml version="1.0" encoding="UTF-8"?>
<moo xsi:noNamespaceSchemaLocation="http://uk.moo.com/en/xsd/api_0.7.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<request>
<version>0.7</version>
<api_key>3ddbe3c0-17ac-c0a802d2-47bafd19-2473</api_key>
<call>build</call>
<return_to>http://www.google.co.uk</return_to>
<fail_to>http://www.google.co.uk</fail_to>
</request>
<payload>
<chooser>
<product_type>minicard</product_type>
<images>
<url>http://farm3.static.flickr.com/2300/2179038972_23d2a1ff40_o.jpg</url>
</images>
<images>
<url>http://farm3.static.flickr.com/2266/2178246585_14139d6905_o.jpg</url>
</images>
<images>
<url>http://farm3.static.flickr.com/2290/2178246751_a5124fdbc7_o.jpg</url>
</images>
</chooser>
</payload>
</moo>
">
<input type="submit" name="submit" value="GO"/>
</form>
You may have spotted that all " characters have been encoded to " inside the hidden form element's value attribute. This is to keep the HTML legal. It's a bit of a pain, so we've written a little tool to escape the XML and drop the correct form element in around it.
The direct method: This method requires a little more effort on your part, but will be a little more familiar in operation to traditional APIs where you would send the request to our server yourself, receive a message back and then do what you need to for the user. In this case, either display an error or forward the user on to the correct page.
The XML that you send is exactly the same, this time, when you send POST data yourself, as well as specifying the xml with xml=bla you will also need to specify method=direct. By doing this, we know that you're talking to us, not a user's browser. All data returned will now come back as XML documents. There are two types that come back at the moment: An error or a success. We'll look at them now.
<?xml version="1.0" encoding="UTF-8"?>
<moo>
<response>
<call>build</call>
<api_key/>
<error>true</error>
</response>
<payload>
<error_code>1</error_code>
<error_string>Error importing XML document</error_string>
</payload>
</moo>
Above we see the error you would see if you sent malformed XML. The thing that let's us know that it's an error document is the <error>true</error> in the response header. It's all pretty self-explanatory. A success document is a little more fun.
<?xml version="1.0" encoding="UTF-8"?>
<moo>
<response>
<call>build</call>
<api_key>3ddbe3c0-17ac-c0a802d2-47bafd19-2473</api_key>
</response>
<payload>
<session_id>d4c7a6d179fca910d67221a57a1bf966</session_id>
<start_url>http://www.moo.com/make/designback.php?bid=1&pid=115&SID=d4c7a6d179fca910d67221a57a1bf966</start_url>
</payload>
</moo>
Again, it's not rocket science. We've set up a session for the caller to pick up from. All you have to do is redirect then to the start_url and they're in business!
No, really, that's it.