MyKubo API

Base URI

https://api.mykubo.com/v0.1
Headers
token
string required
Applied to all methods

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd
Responses
404 Color not Found
404 Content not Found
Delete Size
404 Order not Found
400 Invalid or missing arguments
401 Unauthorized
Documentation
Authentication

To use this API, the client must authenticate itself with the /login method. This method will retrieve a token that must be submited as a header with all the remaining requests.

Images URLs

The url parameter when submmiting a product image, must be the urls returned by the Upload Image method (/products/upload/images).

C Sharp Example

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Web; using System.IO; using System.Runtime.Serialization.Json; using System.Web.Script.Serialization;

namespace Mykubo.API.Test { class Program { static void Main(string[] args) { //Login into API Login response = Deserialize<Login>(Auth("email1@gmail.com", "test")); string token = response.token;

//Get Brands allowed by the login BrandsObj brands = Deserialize<BrandsObj>(ListBrands(token));

//Get all products for the first returned brand ProductsObj products = Deserialize<ProductsObj>(GetProducts(token,brands.brands.First().brand_id));

}

static string Auth(string email, string pass) { return HttpPost("http://api.mykubo.dev/v0.1/login", new string[] { "email", "password" }, new string[] {email,pass}, null); }

static string ListBrands(string token) { return HttpGet("http://api.mykubo.dev/v0.1/brands", token); }

static string GetProducts(string token, string brandId) { return HttpGet("http://api.mykubo.dev/v0.1/brands/"+brandId +"/products/", token); }

static string HttpPost(string url, string[] paramName, string[] paramVal, string token) { HttpWebRequest req = WebRequest.Create(new Uri(url)) as HttpWebRequest;

req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded";

//The authentication token has to be sent in the HTTP HEADER of the request if (!String.IsNullOrEmpty(token)) { req.Headers.Add("token", ""); }

// Build a string with all the params, properly encoded. // We assume that the arrays paramName and paramVal are // of equal length: StringBuilder paramz = new StringBuilder(); for (int i = 0; i < paramName.Length; i++) { paramz.Append(paramName[i]); paramz.Append("="); paramz.Append(HttpUtility.UrlEncode(paramVal[i])); paramz.Append("&"); }

// Encode the parameters as form data: byte[] formData = UTF8Encoding.UTF8.GetBytes(paramz.ToString()); req.ContentLength = formData.Length;

// Send the request: using (Stream post = req.GetRequestStream()) { post.Write(formData, 0, formData.Length); }

// Pick up the response: string result = null; using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse) { StreamReader reader = new StreamReader(resp.GetResponseStream()); result = reader.ReadToEnd(); }

return result; }

static string HttpGet(string url, string token) { HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;

//The authentication token has to be sent in the HTTP HEADER of the request if (!String.IsNullOrEmpty(token)) { req.Headers.Add("token", token); } string result = null; using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse) { StreamReader reader = new StreamReader(resp.GetResponseStream()); result = reader.ReadToEnd(); } return result; }

public static string Serialize<T>(T obj) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType()); MemoryStream ms = new MemoryStream(); serializer.WriteObject(ms, obj); string retVal = Encoding.UTF8.GetString(ms.ToArray()); return retVal; }

public static T Deserialize<T>(string json) { T obj = Activator.CreateInstance<T>(); MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json)); DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType()); obj = (T)serializer.ReadObject(ms); ms.Close(); return obj; } }

public class Login { public bool OK { get; set; } public string token { get; set; } }

public class BrandsObj { public bool OK { get; set; }

public List<Brands> brands { get; set; } }

public class Brands { public string brand_id { get; set; }

public string name { get; set; } }

public class ProductsObj { public bool OK { get; set; }

public List<Product> products { get; set; } }

public class Category { public string category_id { get; set; }

public string name { get; set; } }

public class Product { public string product_id { get; set; }

public string reference { get; set; }

public string name { get; set; }

public Category category { get; set; }

public decimal price { get; set; }

public List<string> tags { get; set; } }

}

API Methods
Authentication
POST /login
POST /logout
Login
POST /login

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
email
string
Example:
brand@brandsite.com
password
string
Example:
password

Responses

200 OK
Body
Object
token
string
Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd
401 Invalid Credentials
400 Invalid or missing arguments
401 Unauthorized
Logout
POST /logout

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
400 Invalid or missing arguments
401 Unauthorized
Enumerators
GET /products/categories
GET /orders/status
Get Product Categories
GET /products/categories

Returns all the possible product categories and with the associated category_id

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
Body
Object
categories
Object
category_id
number
Example:
10
name
string
Example:
string
400 Invalid or missing arguments
401 Unauthorized
Get Orders Status
GET /orders/status

Returns the meaning of all possible order status codes

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
Body
Object
status
Object
status_id
number
Example:
10
status_name
string
Example:
string
400 Invalid or missing arguments
401 Unauthorized
Brands
GET /brands
Brands List
GET /brands

Get all acessible brands

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
Body
Object
brands
Object
brand_id
number
Example:
10
name
string
Example:
string
400 Invalid or missing arguments
401 Unauthorized
Products
GET /brands/{brand_id}/products/
POST /products/upload/images
PUT /brands/{brand_id}/products/
PUT /products/{product_id}/color
PUT /products/{product_id}/color/{color_ref}/size
PUT /products/{product_id}/color/{color_ref}/image
DELETE /products/{product_id}
DELETE /products/{product_id}/color/{color_ref}
DELETE /products/{product_id}/color/{color_ref}/image/{image_id}
DELETE /products/{product_id}/contents/{content_id}/
POST /products/{product_id}/name
POST /products/{product_id}/price
POST /products/{product_id}/category
POST /products/{product_id}/description
POST /products/{product_id}/tags
POST /products/{product_id}/reference
POST /products/{product_id}/content/{content_id}/stock
POST /products/{product_id}/color/{color_ref}/color_hex
POST /products/{product_id}/color/{color_ref}/color_ref
POST /products/{product_id}/color/{color_ref}/set_default
POST /products/{product_id}/color/{color}/image/{image_id}/set_default
List all products of a brand
GET /brands/{brand_id}/products/

Lists all products from a brand

Path variables

brand_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
Body
Object
products
Object
product_id
string
Example:
int
reference
string
Example:
string
name
string
Example:
string
category
Object
category_id
string
Example:
int
name
string
Example:
string
price
number
Example:
1
description
string
Example:
string
tags
string
Example:
string
views
string
Example:
int
is_default_color
string
Example:
bool
contents
Object
color
string

F0F0F0

Example:
string
color_ref
string

red

sizes
Object
content_id
string
Example:
int
size
string
Example:
string
initial_stock
string
Example:
int
current_stock
string
Example:
int
images
Object
image_id
string
Example:
int
url
string
Example:
string
is_default
string
Example:
bool
400 Invalid or missing arguments
401 Unauthorized
Upload Image
POST /products/upload/images

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd
Content-Type
string required

multipart/form-data

Request body

images : array of files submitted as multipart/form-data

Object
string

Responses

200 OK
Body
Object
images
Object
url
string
Example:
string
400 Invalid or missing arguments
401 Unauthorized
New Product
PUT /brands/{brand_id}/products/

Add new product to the brand

Path variables

brand_id
string required

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
name
string
Example:
string
reference
string
Example:
REF1234
price
number
Example:
10.5
category_id
number
Example:
3
description
string
Example:
This describes the product
tags
string
Example:
tag1
colors
Object
color_ref
string
Example:
red
color_hex
string
Example:
FFFFFF
is_default_color
boolean
Example:
false
sizes
Object
size
string
Example:
XL
initial_stock
number
Example:
99
images
Object
url
string
Example:
http://static.v2.mykubo/uploads/272520bcf6de77767b197d89fa6945e0532814f6_s153cd38a472fb1_m.jpg
is_default_color
boolean
Example:
false

Responses

200 OK
Body
Object
product_id
number
Example:
1
400 Bad Request

Some fields cannot be validated

400 Invalid or missing arguments
401 Unauthorized
New Color
PUT /products/{product_id}/color

Path variables

product_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
color_ref
string
Example:
red
color_hex
string
Example:
FFFFFF
is_default_color
boolean
Example:
false
sizes
Object
size
string
Example:
M
initial_stock
number
Example:
10
images
Object
url
string
Example:
string
is_default_color
boolean
Example:
false

Responses

200 OK
404 Product not Found
400 Invalid or missing arguments
401 Unauthorized
New Size
PUT /products/{product_id}/color/{color_ref}/size

Path variables

product_id
number required
Example:
1
color_ref
string required
Example:
red

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
size
string
Example:
S
initial_stock
number
Example:
10

Responses

200 OK
Body
Object
content_id
number
Example:
12
400 Invalid or missing arguments
401 Unauthorized
New Image
PUT /products/{product_id}/color/{color_ref}/image

Path variables

product_id
string required
color_ref
string required

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
product_images
Object
url
string
Example:
string
is_default
string
Example:
bool

Responses

200 OK
400 Invalid or missing arguments
401 Unauthorized
Delete Product
DELETE /products/{product_id}

Path variables

product_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
404 Product not found
400 Invalid or missing arguments
401 Unauthorized
Delete color
DELETE /products/{product_id}/color/{color_ref}

Path variables

product_id
number required
Example:
1
color_ref
string required
Example:
red

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
404 Product not Found
404 Color not Found
400 Invalid or missing arguments
401 Unauthorized
Delete image
DELETE /products/{product_id}/color/{color_ref}/image/{image_id}

Path variables

product_id
number required
Example:
1
color_ref
string required
Example:
red
image_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
404 Product not Found
404 Color not Found
404 Image not Found
400 Invalid or missing arguments
401 Unauthorized
Delete Size
DELETE /products/{product_id}/contents/{content_id}/

Path variables

product_id
string required
content_id
string required

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
404 Product not Found
404 Content not Found
400 Invalid or missing arguments
401 Unauthorized
Edit name
POST /products/{product_id}/name

Path variables

product_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
name
string
Example:
string
Examples
""

Responses

200 OK
404 Product not Found
400 Invalid or missing arguments
401 Unauthorized
Edit price
POST /products/{product_id}/price

Path variables

product_id
string required

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
price
number
Example:
10

Responses

200 OK
400 Invalid or missing arguments
401 Unauthorized
Edit Category
POST /products/{product_id}/category

Path variables

product_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
category_id
number
Example:
1

Responses

200 OK
400 Invalid or missing arguments
401 Unauthorized
Edit description
POST /products/{product_id}/description

Path variables

product_id
string required

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
description
string
Example:
string

Responses

200 OK
400 Invalid or missing arguments
401 Unauthorized
Edit tags
POST /products/{product_id}/tags

Path variables

product_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
tags
string
Example:
string

Responses

200 OK
400 Invalid or missing arguments
401 Unauthorized
Edit Reference
POST /products/{product_id}/reference

Path variables

product_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
reference
string
Example:
string

Responses

200 OK
400 Invalid or missing arguments
401 Unauthorized
Edit stock
POST /products/{product_id}/content/{content_id}/stock

Path variables

product_id
number required
Example:
1
content_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
stock
number
Example:
10

Responses

200 OK
400 Invalid or missing arguments
401 Unauthorized
Edit Color Hex
POST /products/{product_id}/color/{color_ref}/color_hex

Path variables

product_id
number required
Example:
1
color_ref
string required

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
color_hex
string
Example:
FFFFFF

Responses

200 OK
400 Invalid or missing arguments
401 Unauthorized
Edit Color Ref
POST /products/{product_id}/color/{color_ref}/color_ref

Path variables

product_id
number required
Example:
1
color_ref
string required
Example:
red

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
color_ref
string
Example:
blue

Responses

200 OK
404 Product not Found
404 Color not Found
400 Invalid or missing arguments
401 Unauthorized
Edit default color
POST /products/{product_id}/color/{color_ref}/set_default

Path variables

product_id
number required
Example:
1
color_ref
string required
Example:
red

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
default_color
string
Example:
FFFFFF

Responses

200 OK
400 Invalid or missing arguments
401 Unauthorized
Edit default image
POST /products/{product_id}/color/{color}/image/{image_id}/set_default

Path variables

product_id
number required
Example:
1
color
string required
image_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object

Responses

200 OK
404 Product not Found
404 Color not Found
404 Image not Found
400 Invalid or missing arguments
401 Unauthorized
Orders
GET /brands/{brand_id}/orders
POST /orders/{order_id}/confirm
POST /orders/{order_id}/reject
POST /orders/{order_id}/sent
POST /orders/{order_id}/finish
List all orders
GET /brands/{brand_id}/orders

Path variables

brand_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
Body
Object
orders
Object
order_id
number
Example:
10
buyer_id
number
Example:
1
buyer_name
string
Example:
string
address_shipping_name
string
Example:
string
address_shipping_street
string
Example:
string
address_shipping_city
string
Example:
string
address_shipping_zip
string
Example:
string
address_shipping_country
string
Example:
PT
address_shipping_phone
string
Example:
string
address_billing_name
string
Example:
string
address_billing_street
string
Example:
string
address_billing_city
string
Example:
string
address_billing_zip
string
Example:
string
address_billing_country
string
Example:
PT
address_billing_phone
string
Example:
string
same_address
boolean
Example:
true
extra_notes
string
Example:
string
buyer_photo
string
Example:
string
status_id
number
Example:
1
shipping_price
number
Example:
5.5
total_price
number
Example:
543.33
tracking_num
string
products
Object
product_id
number
Example:
10
name
string
Example:
string
reference
string
Example:
string
color
string
Example:
FFFFFF
size
string
Example:
string
amount
number
Example:
5
price
number
Example:
10.5
total_price
number
Example:
52.5
400 Invalid or missing arguments
401 Unauthorized
Confirm order
POST /orders/{order_id}/confirm

Path variables

order_id
string required

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
403 Order was not in paid state
400 Invalid or missing arguments
401 Unauthorized
Reject Order
POST /orders/{order_id}/reject

Path variables

order_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
reason
string
Example:
string

Responses

200 OK
403 Order was not in paid state
400 Invalid or missing arguments
401 Unauthorized
Mark as Sent
POST /orders/{order_id}/sent

Path variables

order_id
number required
Example:
1

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Request body

Object
tracking_num
string
Example:
string

Responses

200 OK
403 Order was not confirmed
400 Invalid or missing arguments
401 Unauthorized
Finish order
POST /orders/{order_id}/finish

Path variables

order_id
string required

Request headers

token
string required

This header is required to all methods except the Login. This token in obtained by calling the Login Method

Example:
09ea6991e1b32a1946425281dd9ef6b0c90aaacd

Responses

200 OK
403 Order was not marked as sent
400 Invalid or missing arguments
401 Unauthorized
Data Reference
Products List object

List of all products from a brand

Properties

products
unknown