Introduction
|
|||||||||||||||||
Development and Production: Access and Security |
|||||||||||||||||
API Requests and Responses
|
|||||||||||||||||
Integration
|
|||||||||||||||||
FAQ
|
Template listings
Display available TemplateCloud templates on your own website
Template editor
Present an editor where your customers customize and buy their chosen designs; and
PDF rendering
When they have checked out from your website, you ask TemplateCloud for the PDF.
Here's a wireframe sketch of a typical API-using website. This page chooses a template:
Here you may:
Before you can use the TemplateCloud API, you'll need:
You can then find your API credentials at https://developer.templatecloud.com/admin/access_details
Our conventions for formatting our API documentation can have the following elements:
Code or data files are boxes and labelled with their type, e.g.
GET http://api.templatecloud.com/sandbox/tag_types/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
{
"tag_types": [
{
"id": "1",
"name": "Industry Types"
},
{
"id": "2",
"name": "Client"
},
etc...
]
}
Aside from standard code highlighting, we style as follows:
You'll need to replicate some data structures on your website, which correspond with some of those in the TCAPI. At the very least, you'll be storing id fields from TemplateCloud, and temporarily holding lists of objects when processing the results of queries.
We have provided a developers' sandbox, to help you avoid incurring charges and writing to live data while you're testing.
Environment | API server URL |
---|---|
Development | http://api.templatecloud.com/sandbox/... |
Production | https://api.templatecloud.com/v1/... |
It is important that you take reasonable measures to ensure that you do not publish your API Key:
Use SSL for API calls — https:// instead of http://
If you experience problems due to unauthorised sharing of your API Key, then request a new API Key, close the security hole, and update your services to use your new API Key.
Do not hard-code your API Key in every request call; instead use a variable containing the key.
Specify your API Key once, in a file on a private part of your server, and include it (by reference) in your framework or page code.
Do not allow your web server to show code that might display the API Key.
Do not use debug code in the production environment, which might reveal the contents of variables that contain the API Key.
Handle errors correctly, so they do not reveal the code that caused the error. If you want traceability, then handle and privately log the error, and optionally inform the user there was a problem along with a reference number that can be used for support.
Try to use syntax checkers and syntax-highlighting code editors, and separate the processing code from the presentation code. This helps to avoid serving code into your HTML pages.
Do not serve scripts or web pages that contain the API Key, i.e. do not design your systems so that your clients' web browsers are making TCAPI requests directly. Instead, your servers should take minimal requests from your client's pages, and then your servers issue the TCAPI requests to the TemplateCloud API on your clients' behalf.
Do not inject unprocessed user-supplied strings into expressions, e.g. do not use something like
$thatWorked = 'Insecure handy calculator: ' . eval( $userInput );
At https://developer.templatecloud.com/docs, we provide live documentation for each of the the API requests, along with convenient entry forms where you can specify values for parameters to test your queries.
Use standard HTTP requests to communicate with the API.
GET requests are used to read data from TemplateCloud using the API;
PUT and POST requests try to write information to TemplateCloud using the API.
The following example is a request to the API’s sandbox handler, which returns a list of tag types:
GET http://api.templatecloud.com/sandbox/tag_types/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
You have the option of specifying the response format using the format parameter. Allowed values are json or xml, the default being xml.
You’ll need your own user_key (see Getting your App Approved).
{ "status": "error", "message": "Template not found" }
Where one record is returned, it is presented as a lone object, e.g.
GET http://api.templatecloud.com/sandbox/tag_types/1?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
{ "tag_type": { "id": "1", "name": "Industry Types" } }
Where more than one record is returned, the top-level object is an array (having a plural name tag_types), containing child tag type objects.
e.g. here are the requests and responses for tag types:
GET http://api.templatecloud.com/sandbox/tag_types/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
{
"tag_types": [
{
"id": "1",
"name": "Industry Types"
},
{
"id": "2",
"name": "Client"
},
etc...
]
}
The XML version is below. Note that the above JSON does not encapsulate the array's items as named objects, but the XML necessarily does:
GET http://api.templatecloud.com/sandbox/tag_types/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=xml
<response status="ok"> <tag_types> <tag_type> <id>1</id> <name>Industry Types</name> </tag_type> <tag_type> <id>2</id> <name>Client</name> </tag_type> etc... </tag_types> </response>
Retrieves a tag type, or lists tag types.
Parameter | Description |
---|---|
user_key | Your application’s key, from developer.templatecloud.com |
format | json or xml |
/tag_types/<tagtype_id>/
After tag_types/, specify the id of the tag type like this:
GET http://api.templatecloud.com/sandbox/tag_types/2/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
/tag_types/
Retrieves all tag types:
GET http://api.templatecloud.com/sandbox/tag_types/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
{
"tag_types": [
{
"id": "1",
"name": "Industry Types"
},
{
"id": "2",
"name": "Client"
},
etc...
]
}
If one result is returned,
{ "tag_type": { "id": "1", "name": "Industry Types" } }
Retrieves a tag group, or lists tag groups.
/tag_groups/<taggroup_id>/
Retrieves a tag group.
Parameter | Description |
---|---|
user_key | Your application’s key, from developer.templatecloud.com |
format | json or xml |
include | List more data containers. Possible value: tag_type. |
After /tag_groups/, specify the id of the tag group like this:
GET http://api.templatecloud.com/sandbox/tag_groups/2/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
{ "tag_group": { "id": "2", "name": "Easter", "tagtype_id": "8", } }
/tag_groups/
Retrieves all tag groups, using optional filters.
Parameter | Description |
---|---|
user_key | Your application’s key, from developer.templatecloud.com |
format | json or xml |
type_id | One tag type id (optional) |
include | List more data containers. Possible value: tag_type. |
GET http://api.templatecloud.com/sandbox/tag_groups/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
{
"tag_groups": [
{
"id": "1",
"name": "Other Events",
"tagtype_id": "8"
},
{
"id": "2",
"name": "Easter",
"tagtype_id": "8"
},
...
}
Use tag_type.id to find tag groups having that tag type:
/tag_groups/...?type_id=<tagtype_id>
Use template.tag.taggroup_id to get a tag group from a template:
/tag_groups/<taggroup_id>/
Use tag_group.id to find templates having tags belonging to that tag group:
/templates/?…filter_options=0&type_id=<tagtype_id>
Use tag_group.id to find template filters for templates having tags in that tag group:
/templates/?…filter_options=1&type_id=<tagtype_id>
Use tag_group.tagtype_id to get a single tag type:
/tag_types/<tagtype_id>/
Use tag_group.id to get a single tag group:
/tag_groups/<taggroup_id>/
Use tag_group.tagtype_id to find tag groups having that tag type:
/tag_groups/?type_id=<taggroup_id>
Use template.tag.taggroup_id to find all templates having that tag group:
/templates/?group_id=<taggroup_id>
/template_sizes/<templatesize_id>/
Retrieves a template size. Note that we do not publish these IDs in the API, so this is of limited use. Instead, just retrieve all template sizes.
/template_sizes/
Retrieves all available template sizes.
Parameter | Description |
---|---|
user_key | Your application’s key, from developer.templatecloud.com |
format | json or xml |
templatesize_id | One template size id (optional; deprecated) |
units | imperial or metric (optional). |
GET http://api.templatecloud.com/sandbox/template_sizes/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
{
"template_sizes" : [
{
"code" : "A4",
"name" : "A4",
"width" : "210.0000",
"height" : "297.0000",
"bleed" : "1.5000",
"units" : "mm"
}, {
"code" : "A5",
"name" : "A5",
"width" : "148.0000",
"height" : "210.0000",
"bleed" : "1.5000",
"units" : "mm"
},
...
]
}
Use template.size.code to find templates having that template size, when include contains size.
/templates/?...include=size
Hidden: The unpublished template_size.id can be used as a template size argument in the API call, to retrieve a single template size:
/template_sizes/<templatesize_id>/
Récupère un template, ou récupère les filtres pour cette demande.
/templates/<template_id>/
Récupérer un template.
GET http://api.templatecloud.com/sandbox/templates/12345/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
/templates/
Récupérer tous les templates disponibles en utilisant plusieurs filtres d'options.
If more than one template is returned, then the response is a templates object containing many template items.
You can include your own templates using include_my_templates=true or only_my_templates=true and refine that list using workgroup, category and customer filters.
If filter_options=0, the response contains templates that match the specified criteria.
If filter_options=1, the response contains the allowed values of filter criteria, i.e. valid tags or other parameter values (see below).
Where filter criteria are not specified, those aspects are disregarded in the search.
Parameter | Description |
---|---|
user_key | Your application’s key, from developer.templatecloud.com |
format | json or xml |
Search Criteria | |
template_id | One template ID. Optional; omit to show all available templates. |
include_my_templates |
When true, 'private' templates assigned to your workgroup, category, or customer, are added to the public templates. If you specify more than one parameter (of workgroup, category, customer), results are merged. Default: false. Adding workgroup=TEMP&category=AAC&customer=TCINST filters only the private templates. Filters are optional. |
only_my_templates |
When true, only 'private' templates assigned to your workgroup, category, or customer, are returned. If you specify more than one parameter (of workgroup, category, customer), results are merged. Default: false. Optional filters: workgroup=TEMP&category=AAC&customer=TCINST. |
keywords | Matches to tag.name. Optional. |
keywords | Matches to tag.name. Optional. |
collection_id |
Matches to a collection. Optional. Equivalent to searching for a tag of tag type 7 ('collections'). |
tag_groups | tag group IDs (optional). Multiple items allowed, comma-separated. |
pages |
If required, a value to match template.colour.pages (the number of ‘sides’ or ‘PDF pages’ in a document). Typical values: 1 or 2. |
sizes | If specified, return only templates having matching template.size.code or template.size.id. Multiple items allowed, comma-separated. |
colour | If specified, return only templates having colour tag of matching colour, i.e. colour = template.tag.colour (hexadecimal colour). Specify the colour as 3-byte hexadecimal, RGB ordering, e.g. 0568b4. |
designer_id | If specified, return only templates designed by this designer. |
exclusive_tag_types |
0 or 1. Default value 0: will only list template results that have a match on ALL tag groups you’ve search for. Override value 1: will list ANY template result that matches at least one of the tag groups you’ve searched for. |
Paging and ordering of template results | |
limit |
For a paged response, specify this as the number of results to return per page. Optional. Allowed range: 1-100. |
page |
Set the page index of results to return, starting with page = 0. Optional; Default values: &limit=20&page=0. |
sort_key |
Allowed values: rank, price, or date. Default: rank. |
sort_order |
Allowed values: desc or asc. Defaults: |
Inclusion of metadata | |
include |
Additional element metadata items to include in each template object. Multiple items allowed, comma-separated. See below. All options: tags,size,colour,tag_group,images |
filter_options | 0 or 1. When 1, the response inludes filters rather than templates. See filteroptions=0, below. |
When (comma-separated) arguments are supplied for the include parameter, extra items are included in the response for each template item. Below is an example of each extra item.
include=size
"size": { "code": "BC", "name": "Business Card", "width": "85.0000", "height": "55.0000", "bleed": "1.5000", "units": "mm" }
include=colour
"colour": { "coloursfront": 4, "coloursreverse": 4, "pages": 2 }
include=tags
"tags": [
{
"id": "214",
"name": "Business Cards",
"sales": "16491",
"taggroup_id": "60",
"tagtype_id": "3"
},
/* more tags */
...
]
include=tag_group
"tags": [
{
...
"tag_group": {
"id": "60",
"name": "Business Cards",
"tagtype_id": "3"
}
},
/* more tags */
...
]
include=images
"images": [ { "0": "http://www.templatecloud.com/api/...", "1": "http://www.templatecloud.com/api/...", "_attrs": { "name": "small" "size_code": "S" } }, /* more images */ ... ]
The request returns the matching templates.
GET http://api.templatecloud.com/sandbox/templates/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json&include=tags%2Csize%2Ccolour%2Ctags%2Ctag_group%2Cimages&filter_options=0 &tag_groups=2
{ "templates": { "0": { "id": "5924", "name": "Crunchy Cabbages Business Card ", "views": "102", "date_added": "2011-10-04 15:48:18", "designrank": "110", "allow_fotolia_library": true, "allow_object_deletion": true, "designed_by": "Norma Liza", "designer_id": "693971", "price": "20.00", "cost_price": "19.00", "click_charge": "0.00", "price_currency": "USD", "tags": [ /* tag items */ ], "size": { "code": "BC", "name": "Business Card", "width": "85.0000", "height": "55.0000", "bleed": "1.5000", "units": "mm" }, "images": [ /* image items */ ], "colour": { "coloursfront": 4, "coloursreverse": 4, "pages": 2 } }, /* more template items */ ... }
The request returns all of the filters (parameters and their values) available for the given search criteria. Note that this may not be used in combination with a template_id.
For keywords that were converted to tags, tags[].inferred=true. The remaining keywords are shown in keywords.refined[].
GET http://api.templatecloud.com/sandbox/templates/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json&filter_options=1 &tag_groups=2
{ "colours" : [ { "colour" : "86200e", "name" : "Maroon" }, ... ], "sizes" : [ { "name" : "US Business Card (2x3in)", "code" : "USABC", "count" : "572", "selected" : false, "area" : 7 }, ... ], "tags" : [ { "title" : "Product Types", "types" : "PRODUCT", "tags" : [ { "name" : "Appointment Cards", "code" : "194", "count" : "42", "selected" : false, "inferred" : false }, ... ] }, { "title" : "Industry Types", "types" : "INDUSTRY", "tags" : [ { "name" : "Arts & Music", "code" : "15", "count" : "688", "selected" : false, "inferred" : true }, ... ] }, { "title" : "Styles", "types" : "STYLE", "tags" : [ { "name" : "Abstract & Illustrative", "code" : "39", "count" : "2406", "selected" : false, "inferred" : false }, ... ] }, ... ] "keywords" : { "refined" : [ "test" ], } }
Use template.tag.tagtype_id to get a tag type:
/tag_types/<tagtype_id>/
Use template.tag.taggroup_id to get a tag group
/tag_groups/<taggroup_id>/
Use template.tag.tag_group.tagtype_id to get a tag type
/tag_types/<tagtype_id>/
Use template.size.name to get a template size
/template_sizes/<template_size.name>/
Use template.id to get the single template
/templates/<template_id>/
Use template.tag.taggroup_id to get all templates having that tag group
/templates/?group_id=<taggroup_id>
Use template.designer_id to get all templates by that designer
/templates/?designer_id=<designer_id>
/templates/<template_id>/buyIndesignFile
Buys the InDesign file. This might incur a charge.
/templates/<template_id>/indesignFile
Fetches the template’s InDesign file, and returns it as an attachment.
/templates/<template_id>/edit
Creates a template instance from a template.id. This instance can be edited by further API calls — see below.
Parameter | Description |
---|---|
user_key | Your application’s key, from developer.templatecloud.com |
format | json or xml |
template_id | One template id (required) |
GET http://api.templatecloud.com/sandbox/templates/5277/edit?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
{ "instance_id": "436935" }
/instances/<instance_id>/makePDF
Initiates the creation of a PDF file, and charges your account.
Parameter | Description |
---|---|
user_key | Your application’s key, from developer.templatecloud.com |
format | json or xml |
queue | 0 = generate and wait (synchronous) 1 = queue for later retrieval (asynchronous) – recommended! |
skip_buy | Some API consumers have a special permission enabled, to bypass the fees, which can be exercised using skip_buy=1. This option is disabled for the majority of API keys. |
PUT http://api.templatecloud.com/sandbox/instances/50010/makePDF?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
{ "status": "ok", "message": "PDF generation in progress", "job": "2152428" }
No further edits of a template instance are possible after a call to makePDF; further edits must be made to a new template instance which may be created using call to /templates/<template_id>/edit
/instances/<instance_id>/pdf
If the PDF is ready to download, the response to a GET request is a URL to the PDF file; otherwise it is an error notification.
It is advised that you poll /pdf with a HEAD request until the 200 response is returned; feed back the latest result to your web page via AJAX.
HEAD http://api.templatecloud.com/sandbox/instances/50010/pdf?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
{ "status": "error", "message": "PDF generation in progress." }
{ "status": "error", "message": "PDF generation failed." }
{ "status": "error", "message": "PDF not created (probably instance not found, or some unknown error)." }
{ "status": "ok", "message": "PDF ready." }
After receiving a 200 response, the file can be retrieved using the equivalent GET request:
GET http://api.templatecloud.com/sandbox/instances/50010/pdf?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
If the file is still available, the 200 response will contain a binary stream. If the file is not available, the response will be an XML/JSON notification of the error (as above).
TCAPI is platform-neutral because all communications with TemplateCloud are handled using simple requests and JSON/XML responses. You can develop your website using any competent framework.
Typically, your business will need a website that:
Presents and allows choice of a template, perhaps with a product in mind;
Presents the editor to work on an instance of the template;
Buys and downloads the customized PDF from TemplateCloud.
And of course
Handles the relationship with your customer: securely processes payments, shows progress, generates correspondence;
Controls manufacturing and logistics for your goods.
In this guide, we show how to choose a template and customize it using the editor.
This article explains how to embed the TemplateCloud editor on your website using some simple HTML & Javascript call.
You will also need to create an editor session to tell the editor which template or instance should be modified using an API call.
Note: this is a new simplified approach to opening the editor that means integrators no longer need to use the Create Instance API call.
Once you've got an sdsid, you can use this in your editor
To load the editor add this HTML
<html>
<head>
<title>Editor</title>
</head>
<body>
<script src="https://dev.editor.w3p.com/js/editor.js"></script>
<script type="text/javascript">
TemplateEditor = new TemplateEditor({
options: {
src: 'https://dev.editor.w3p.com',
height: '400px',
width: '600px'
},
params: {
sdsession: '<your sdsid>',
continue_url: '<your continue url>',
exit_url: '<your exit url>'
}
});
TemplateEditor.init();
</script>
</body>
</html>
Options | Description | Required? |
---|---|---|
src |
The url of the editor. |
Yes |
width | Width of the editor Eg 800px |
No |
height | Height of the editor Eg 400px |
No |
fullscreen | either "true" or "false" If "true" we'll load the editor fullscreen |
No |
Params | Description | Required? |
---|---|---|
sdsession | Get this from the POST /sessions/create API call See below for more details |
Yes |
continue_url | The url to send people to after they press Next step in the editor | Yes |
exit_url | The url to send people to after they press Quit & cancel in the editor | Yes |
locale |
The language to open the editor in. tc_US for US. |
No |
/sessions/create
Creates an editor session to open the editor.
Works with both GET and POST API calls
POST only returns in XML, but requires no user_key
Parameter | Description |
---|---|
format | json or xml |
Required option | |
template_id |
One template ID. Use this to get a SDSession to use when you open the editor. |
instance_id |
One instance ID. Use this to get a SDSession to use when you open the editor. |
http://api.templatecloud.com/sandbox/sessions/create/?template_id=31081
<?xml version="1.0" encoding="UTF-8"?> <response status="ok"> <message>SDSession created.</message> <sdsid>9cfcd1e8f11a5659752074ff33e17b9af869a34f</sdsid> <instance_id>2196719</instance_id> <template_id>31081</template_id> </response>
http://api.templatecloud.com/sandbox/sessions/create?instance_id=2196517
<?xml version="1.0" encoding="UTF-8"?> <response status="ok"> <message>SDSession created.</message> <sdsid>4cbde1cb9d1a81e397937a0576d654f03f824103</sdsid> <instance_id>2196517</instance_id> <template_id>31081</template_id> </response>
TemplateCloud templates are designed for an item of known size. It is expected that you have a list of products, each product having a size that can be matched to the templates in TemplateCloud.
So that you can present appropriate templates to your customers, you should select only the /template_sizes/ that have sizes corresponding to your products, i.e. matching template_size.width, template_size.height, and template_size.bleed.
TemplateCloud contains templates in landscape and portrait orientations, so there might be additional matches when height and width are swapped, or compare [min(h,w), max(h,w)] of template size and your product.
One approach would be to create a table defined like this:
Column | Description |
---|---|
template_size_id | ID from /template_sizes/, also used in template.size. |
myProduct | Your own product code. |
With example data like this:
template_size_id | myProduct |
---|---|
A4 | StatPremA4 |
13rd | StatPremCompl |
A4 | DistroLeafA4 |
Query your table to retrieve all template_size_id values, and feed them into the sizes parameter of the /templates/ API call.
The purpose of your website is to select a template and buy a PDF for your customer. Often your customer will not know which template they want, so your site will need to present some templates, to eventually reduce the selection to the one that the customer wants.
There are many approaches to achieving the objective of reducing your customer’s options to one.
Start with everything (possibly matching a user-initiated text search), and present filters to help narrow down the options.
Start with a few filters enabled, to restrict your users to a subset of the total TemplateCloud library. Do this if:
Your site is ‘special interest’ or is dedicated to a business category, or you have a limited set of templates you want to sell (without the ability to remove those filters);
You want to inspire your users on a particular theme (where you make the filters available to switch back to the full collection).
Start with a suggestion of one template. Feature a design, or randomly choose from a small pool of designs, showing only one of them at a time. Your user then has the one template needed to (customise and) progress the order.
TemplateCloud contains thousands of templates, tagged to enable their discovery. Each criterion (size, colour, industry type, number of pages, etc) is a tag type having several possible tags within that type.
If presented with an untargeted list of thousands of templates, it’s unlikely that your customer will find the template that they want, so you should ask TemplateCloud which tag types are available, and publish these tags as search options on your website, under tag type headings. It is conventional to add these as checkboxes alongside your search results.
You’ll probably want a page of initial search results, especially if you used a text search as a starting point. It’s also advisable to cache the results and present them to the client a page at a time.
Call the template method, with filter_options=1, which returns the tags that are present in the templates that would be returned when filter_options=0. In other words, this gets a list of tags.
GET http://api.templatecloud.com/sandbox/templates/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json
The response looks like this:
{ "colours" : [ { "colour" : "86200e", "name" : "Maroon" }, more colours ... ], "sizes" : [ { "name" : "US Business Card (2x3in)", "code" : "USABC", "count" : "572", "selected" : false, "area" : 7 }, more sizes ... ], "tags" : [ { "title" : "Product Types", "types" : "PRODUCT", "tags" : [ { "name" : "Appointment Cards", "code" : "194", "count" : "42", "selected" : false }, more tags of type 'product'... ] }, more tag types... ] }
You can parse this response into an array, and present the options on your pages.
When your customer ticks the filter options, you should initiate a refined search using an API call having filter_options=0 and the ticked tags encoded into parameters. Note that when a tag is specified, then it excludes all templates that do not have that tag within the tag type.
To ask for extra information about the templates, you use the &include parameter to ask for a list of properties. e.g. here we want to know about sizes, colours, tags, tag groups, and images.
GET http://api.templatecloud.com/sandbox/templates/?user_key=ba386e729c5f6870cea89f38e92d7a5c&format=json&include=tags%2Csize%2Ccolour%2Ctags%2Ctag_group%2Cimages
%2C is a comma, encoded as URL-compatible text.
This information is based on content from our developer website.
To embed the Flash editor on your site simple copy-paste the code below and fill all “{}” blocks accordingly. [download jquery.flash.js]
<!-- Start Editor --> <script type="text/javascript" src="/js/jquery.flash.js"></script> <script type="text/javascript"> $(document) .ready(function () { $('#example') .flash({ src: 'http://www.templatecloud.com/templates_frontend/PDCRobot.swf?1325859802', id: 'PDCRobot', width: 940, height: 800, quality: 'high', bgcolor: '#0000ff', allowscriptaccess: 'always', allownetworking: 'all', allowfullscreen: 'true', wmode: 'transparent', base: 'templates_frontend', flashvars: { autoParams: 'friendlynames=true', baseURL: 'http://www.templatecloud.com/api/', continueURL: '{your_continue_url}', cancelURL: '{your_cancel_url}', redirectURL: '{your_redirect_url}', templateid: '{template_id}', instanceid: '{instance_id}', customerid: '{your_customer_id}', locale: 'tc_GB', bleed: '1.5000', extraParam: '&asset_key=*******', activeButtonColor1: '0xc8d756', activeButtonColor2: '0xc8d756', fotoliaSearchTerm: 'business' } }, { version: 8 }); }); </script> <div id="example"></div> <!-- EOF Editor -->
flashvars{ Parameter } | Value, Description | |
---|---|---|
Required | ||
autoParams |
'friendlynames=true' When true, we show friendly names like "Your Business Name" instead of our active field placeholders like {{business_name}} |
|
baseURL |
The API server address.
|
|
continueURL
cancelURL
redirectURL
|
Where the website sends users after they leave the editor:
|
|
templateid | The ID of the template that is being loaded into the editor. | |
instanceid | The ID of the template instance that is being loaded into the editor. | |
customerid | Your own customer ID, assigned to you by the TemplateCloud team. (not an ID for your customer) | |
locale |
Selects a language for notifications and display. Allowed values: 'en', 'fr', 'nl', 'de', 'pt', 'it', 'es', 'se' |
|
bleed | Templates for our production have 1.5 bleed; your SupplieReady products might have a different value. | |
extraParam: asset_key | = hex(SHA1(concat( <your editor_key>, <instanceid> ))) | |
activeButtonColor1 |
Primary button colour (for the most important actions)
RGB hex (C format), e.g. '0xc8d756' |
|
activeButtonColor2 |
Secondary button colour. RGB hex (C format), e.g. '0xa88080' |
|
allowFotoliaImages | When false, the editor does not offer library images to replace existing images. (JS Boolean, default: true) | |
fotoliaSearchTerm | The term searched for when the Fotolia editor appears. | |
Image chooser - paging | ||
userImagesPagingRequired | 'true' | These help preserve client-side memory by loading user images in groups as required. E.g. If the first item is set to 'true', then the editor will load 10 images initially and load images in blocks of 5, as the user scrolls. |
defaultNumberOfImages | 10 | |
numberOfImagesToAdd | 5 |
For development purposes please use the following values for variables:
src |
'http://dev.templatecloud.com/templates_frontend/PDCRobot.swf?1325859802' |
baseURL |
'http://dev.templatecloud.com/api/' |
templateid |
10014 Please use this ID for testing purposes; only a limited number are activated on the DEV server. |
instanceid |
436738 This is generated using the method "Create Instance", see https://developer.templatecloud.com/docs#/instances |
customerid |
'TCDEMO' |
asset_key | Hexadedimal representation of SHA1 hash of concat('bf6b7bb900dcb665497362cbce0a9e90', instanceid). |
It’s worth explaining how to obtain a value for asset_key, in more detail.
First join the instanceid to the API key,
e.g. if instanceid=356 and the API key is ba386e729c5f6870cea89f38e92d7a5c,
then the concatenated string will be ba386e729c5f6870cea89f38e92d7a5c356.
then obtain the SHA1 hash of the result
and then convert that hash to a hexadecimal string.
A PDF is bought when you call /makePDF/; a charge is made to your account.
You should endeavour to protect your cashflow by ensuring that whenever you are charged the small fee by TemplateCloud, you are charging your customer enough margin to cover the fee.
It might help to design your workflow so that it does not allow tight editing cycles.
Also remember to use the sandbox when developing and testing.
Avoiding PDF exploitation
If further edits are needed after makePDF, you’ll need to generate a new template instance from a template, which carries a further charge because that uses makePDF. As with the “protecting your cashflow” warning, you’ll want to avoid creating lots of instances for the same chargeable item on your site. For example, you’ll need to take payment before offering PDFs or derived works to your customer.
The Pest interface (https://github.com/educoder/pest) can simplify API calls. Here’s an code snippet that gets and displays TemplateCloud data in PHP:
// Load the library (Pest folder must be in PHP's include path) require_once 'Pest/PestJSON.php'; include '../data/tcapi_key.php'; // e.g. contains: $tcapi_key = '01234567890abcdef'; // Initialise the library (put in your TC credentials here; username not needed for dev/sandbox) $apiClient = new PestJSON( 'https://api.templatecloud.com/v1' ); $apiClient->setupAuth( 'username', 'password' ); // Make a simple get call (this returns tag types in JSON format) try { $result = $apiClient->get('/tag_types/?format=json&user_key='.$tcapi_key ); } catch (Exception $e) { // Handle error. In practice there are several exception types, // which you can use to differentiate between different error conditions die( $e->getMessage() ); } // Examine successful result // This just outputs to the page; you'll want to present it nicely. echo ''; print_r( $result ); echo '';
To use the sandbox, the above example is modified slightly:
Change the API access point to
$apiClient = new PestJSON( 'https://api.templatecloud.com/sandbox' );
You don’t need to supply (username, password) at the authentication step.
When your production account is set up, we’ll give you the (username, password) for the authentication step.
It’s likely you’ll want to get a list of templates that meet your criteria. Here’s an example where we look for templates suitable for two-sided A6. It also returns their meta-data (tags, colours, etc) which you can omit by removing them from the include parameter.
... $result = $apiClient->get( '/templates/?format=json' . '&user_key=' . $tcapi_key . '&include=tags%2Csize%2Ccolour%2Ctags%2Ctag_group%2Cimages' . '&pages=2&sizes=A6' ); ...
1. Is there some technical documentation where my engaged developer can learn how it works, and assess how easy it would be to integrate?
Besides this document, go to https://developer.templatecloud.com/ and request an API key.
The API is simple to integrate, and most of your time will usually be spent getting your database and website into the right ‘shape’.
2. Listing Templates: Is it possible for me to pre-set and exclude some of the Filter? Can I hide the options?
The beauty of the TemplateCloud API is that it is totally customisable. If you only wanted to sell Business Cards, or blue coloured designs, or leaflets for beauty spas, you only request those thumbnails. You can filter out any designs you don't want to display by price, product type, size, colour type or just about any attribute you can think of.
3. Can a customer edit an old order?
Yes, it is possible to create a new instance as a reorder of a previous design. The original stays ‘intact’, but the copy can be pre filled with same text/images so that they can start from a previous design. Each time you request a new PDF, we charge a design fee.
4. I’m making a Business Card website where customers order for many employees...?
Since you are controlling the shopping cart/checkout process, you can treat this as a single order from the client's perspective.
Using the API you would just create (say) 5 instances, and include them all in same basket on your site.
Regardless of whether you're ordering them separately or all together, each card consumes the same service/server load and we pay the same royalties to the designer, we would charge for 5 PDFs.
5. Do the templates have Spot UV layer?
We support spot UV, die-cut shapes, embossing and foil blocking.
However, we [at the time of writing] don't have any designs in the TemplateCloud library which currently have any of those finishes. If you were adding content to the TemplateCloud library, we can teach you how to set these up – it’s simple.
6. Do I keep my existing checkout and banking process?
Yes. TemplateCloud API provides the three services that help your customer select a template, edit the design, and for you to request a PDF of the customised design. Your website charges your customers.
7. When do I incur transactional charges?
Only when you call /instances/<instance_id>/makePDF.
8. Where do I find template prices?
The /templates/<template_id> API call gives you the pricing of each template:
template.price = the price we advise you to sell to your customer (the “retail price”);
template.click_price will always be 0,00 for you and is thus redundant;
template.cost_price = the price we will charge you for generating the PDF.
9. What is the URL for the live TemplateCloud API?
We do not publish the address of the live TemplateCloud API to prospective developers, until we have assessed their release candidate.
10. Template editing fails. How do I build the hashed ‘instance ID’?
We describe how to build extraParams: asset_key in detail, in Populating or Customizing a Template.
See also
|
|||
Jump to contents page of
|