Brandly API
Brandly API
 
 
Introduction
The Brandly API is intended for use by websites which are not based on platforms we directly integrate with (Shopify, Wix, WooCommerce, Etsy, Ebay, BigCommerce).
If your website is based on one of the mentioned platforms, you don't need to use the API. Currently, the API can only be used for searching our catalogue.
Requests can be be made either via REST over HTTPS, or by using our helper libraries (recommended). Currently only the PHP library is available, and we will provide ready to use code samples.
All responses are in JSON format.
Prerequisite
You need to pass an authorization token to each API request.
If you don't have one, please use the generator below to create one. It will ask your Brandly credentials to generate the token.
Token Generator
Your email or username
Your password
 
 
Categories
This request will return our whole category tree in JSON format.
PHP example
		include __DIR__ . "/BrandlyCoZaResellerApi.php"; // include API library
		define("MY_API_TOKEN","MySecretToken123");
		
		$api = new \BrandlyCoZaResellerApi(MY_API_TOKEN); // instantiate Api object with my token
		$categories = $api->getCategories();
		var_dump($categories);
		
REST example
		GET /wp-json/brandly-api/v1/categories HTTP/1.1
		Host: brandly.co.za
		Authorization: Bearer MySecretToken123
		Content-Type: application/json
		Content-Length: 0
		
		
Searching products
It is possible to search our products by either product ID, a list of product IDs, or a combination of keywords, category and SKU.
If you are not searching by ID(s), it is mandatory to specify at least the category or the SKU in the search filters. Keywords are optional.
Pagination is supported (optional, but encouraged): add the "offset" and "limit" parameters to limit the results and seek through the pages. For performance reasons, please fetch no more than 20 results at a time (pass a "limit" value not greater than 20).
Parameters
sku
This can be either a full SKU, or just the initial part of it. The latter is useful if you want to search products with a SKU beginning with a certain sequence of characters. In any case, SKU must be at least 3 characters (otherwise, do not use the the SKU filter).
categoryId
The numerical ID of the category, as returned by the /categories request described before.
s
This is the search term to match with the product name. E.g. "white shirt".
idIn
The comma separated list of product IDs you want to fetch. E.g. "123" , or "100,123,45".
PHP example
		include __DIR__ . "/BrandlyCoZaResellerApi.php"; // include API library
		define("MY_API_TOKEN","MySecretToken123");
		$api = new \BrandlyCoZaResellerApi(MY_API_TOKEN); // instantiate Api object with my token

			// Do a search by category, sku and name
		$search = $api->createProductSearch(); // create search object, to which we will add filters
		$api->productSearchAddSku($search,"BAR-TST"); // add (partial) SKU
		$api->productSearchAddCategoryId($search,8202); // add category Id
		$api->productSearchAddTerms($search,"shirt"); // search product with "shirt" in the name
		$api->productSearchOffset($search,0);
		$api->productSearchLimit($search,10);
		$searchResults = $api->getProducts($search);
		var_dump($searchResults); // dump product results

			// Now try a search by product Id(s)
		$search = $api->createProductSearch(); // start another search
		$api->productSearchAddId($search,180601); // add exact product id
		$api->productSearchAddId($search,208921); // add another product id
		$searchResults = $api->getProducts($search); // expecting the 2 products to be returned
		var_dump($searchResults);	
		
REST example 1
		GET /wp-json/brandly-api/v1/search?sku=BAR-TST&categoryId=8202&s=shirt&offset=0&limit=10 HTTP/1.1
		Host: brandly.co.za
		Authorization: Bearer MySecretToken123
		Content-Type: application/json
		Content-Length: 0
		
REST example 2
		GET /wp-json/brandly-api/v1/search?idIn=180601,208921 HTTP/1.1
		Host: brandly.co.za
		Authorization: Bearer MySecretToken123
		Content-Type: application/json
		Content-Length: 0