PHP Sample Scripts for Design Upload, Product Creation and Basket Handling Available

Today, I added three useful PHP sample scripts to our SourceForge repository that show you how to upload designs, create products and create and modify baskets, render article listings, render design listings using Spreadshirt API v1.

In case you need more background information on how our design, product and basket models work, read design model, product model and basket model and have a look at the tutorials for product creation and design upload.

Cheers,
Martin

Searching on Spreadshirt’s Design Marketplace using Spreadshirt API v1 (API Tutorial #3)

Since a couple of weeks, Spreadshirt API v1 allows you to search for designs on our design marketplace. In this blog post, I am going to tell you

  • how our search interface for searching for marketplace designs looks like,
  • how our search syntax works and
  • how our search result payload looks like.

Search Interface

Our search interface for searching on our design marketplace is quite simple. As explained in Speadshirt API v1 Explained, we provide in general a REST interface that gives you access to most of the data you need for creating custom shops, masss-customization applications or widgets in context of customized apparel, like designs, product types or print types.
Looking at designs in special, you can retrieve marketplace design listings without using the search by using either the URL http://api.spreadshirt.net/api/v1/shops/205909/designs or http://api.spreadshirt.com/api/v1/shops/93439/designs, depending on whether you want to access the designs on the eu or na platform (eu is shop 205909 and na 93439).
Searching for designs is as easy as retrieving design listings: You simply add the query parameter query to the URL and add your search terms as values, e.g. http://api.spreadshirt.net/api/v1/shops/205909/designs?query=herz mit pfeil (herz mit pfeil is german and means “heart with arrow”).

Besides stating in the query parameter what you are looking for, you can also provide query parameters for sorting the result, for searching on the marketplace in a specific language, for returning search facets, for conducting a spellcheck in case of typos in the search query or for paging through the search result. A sample query using all possible parameters and thus the full search interface would look like that:

http://api.spreadshirt.net/api/v1/shops/205909/designs?query=herz mit pfeil&showFacets=true&spellcheck=true&sortField=price&sortOrder=desc&locale=de_DE&offset=10&limit=10&fullData=true

Continue reading “Searching on Spreadshirt’s Design Marketplace using Spreadshirt API v1 (API Tutorial #3)”

Creating Products on Spreadshirt using Spreadshirt API v1 (API Tutorial #2)

In this tutorial, I will show you how you can use Spreadshirt API v1 to create products with uploaded designs. I will first tell you about the preliminaries that need to be met in order to be able to create new products or upload designs. I will then tell you about the steps that need to be conducted to create a product with an uploaded design. And finally, I will show you in detail on code samples what exactly you need to do. Please note that I already described in general how to upload designs in “Uploading Designs to Spreadshirt using Spreadshirt API v1“.

Preliminaries

In order to be able to create products and upload designs, the following preconditions need to be met:

  1. You need to own an API key.
  2. The API key needs to be configured for design upload usage and product creation.
  3. You have pixel designs to upload (pngs with transparency set).
  4. You want to create a product using that uploaded design (using shop designs or marketplace designs is also possible).

Steps

To create a product with an uploaded design, you need to conduct the following steps in general:

  1. Create the design data by sending a design XML file to the data API.
  2. Fetch the XML data from the API to retrieve the upload URL for the image API.
  3. Extract the upload URL from the XML data.
  4. Upload the pixel design (png) to the image API using the upload URL.
  5. Create the product by sending the product XML file with the upload design id to the data API.

Make sure that you sign the API calls correctly with your API key and secret, when creating the design data, uploading the design or creating the product (see design resource documentationproduct resource documentationsecurity documentation).

Continue reading “Creating Products on Spreadshirt using Spreadshirt API v1 (API Tutorial #2)”

Uploading Pixel Designs to Spreadshirt Using Spreadshirt API v1 (API Tutorial #1)

In this tutorial, I will tell you how you can use Spreadshirt API v1 to upload designs. You can later use these designs to create new products. I will first tell you about the preliminaries that need to be met in order to be able to upload designs. I will then tell you about the steps that need to be conducted to upload the designs. And finally, I will show you in detail on code samples what exactly you need to do.

Preliminaries

In order to be able to upload designs, the following preconditions need to be met:

  1. You need to own an API key.
  2. The API key needs to be configured for design upload usage.
  3. You have pixel designs to upload (pngs with transparency set).

Steps

To upload a design, you need to conduct four steps in general:

  1. Create the design data by sending a design XML file to the data API.
  2. Fetch the XML data from the API to retrieve the upload URL for the image API.
  3. Extract the upload URL from the XML data.
  4. Upload the pixel design (png) to the image API using the upload URL.

Make sure that you sign the API calls correctly with your API key and secret, when creating the design data and uploading the design (see design resource documentation, security documentation).

Continue reading “Uploading Pixel Designs to Spreadshirt Using Spreadshirt API v1 (API Tutorial #1)”