Here is the collection of services for the basic, non-ML, Snaphack demo.
Base services provide the following functionality:
There is also the ability to select a company to use while interacting with the set of services. This allows for dynamic selection of a product catalog. There is also a default company assigned server-side in the event that the front-end client doesn’t send a value.
To allow for dynamic company selection, the following services exit:
To make the website demo function, there are additional services to provide:
The Postman Collection and Environment Data is also available.
These services provide the base functionality for the Snaphack demo.
The company to use can be configurated by sending an appropriate company “slug” in the company query parameter. If the value isn’t provided, or isn’t valid, a server-side configured default will be used.
This is a POST request to upload a new photo for color processing (and later other aesthetics).
The server expects the POST body to either be the raw bytes of the JPEG, or a JPEG encoded in a data URI.
The company to associate the photo upload request with is indicated by the company query parameter. This isn’t used by the actual photo processing code, but helps with later being able to display the most recently uploaded photo for a given company in the demo/debug web interface. Correct values can be retrieved from the companies endpoint.
Response documentation:
nonce - this is a value that can be used as an id of sorts for this upload. It is a dynamic value that changes on each upload, and is mainly used when polling the server for changes using the photo-last endpoint.company - this is the value of the company parameter that was actually used. If a valid company query parameter was provided in the request, then the values will match. Otherwise, this indicates which company was actually used when storing the photo information.uploaded_file - This is a full URL to the photo that was just uploaded. This is mainly stored/provided for debugging information and utilized by the demo website.image_width - the full width of the image that was uploaded, in pixels.image_height - the full height of the image that was uploaded, in pixels.colors - an array of color objects representing the top 6 colors in the uploaded image.palette_colors - an array of color objects representing the reduced-palette equivalents of the colors in the colors array.complementary_colors - an array of color objects representing the complementary color for each color in the colors array.The “color object” that is in each color array is simply an object with the key hex, whose value is a RGB hex value for the color proceeded by a # character. Originally, the API design called for additional properties in this object, but those were removed.
curl -X POST "https://api.snaphack.website/api/v1/photo?company=ashleyfurniturehomestore"
POST /api/v1/photo?company=ashleyfurniturehomestore HTTP/1.1
Host: api.snaphack.website
| Status | 200 |
|---|---|
| content-type | application/json |
| date | Tue, 05 Jun 2018 16:36:20 GMT |
| referrer-policy | no-referrer |
| server | nginx |
| status | 200 |
| strict-transport-security | max-age=31536000; includeSubdomains; preload |
| x-content-type-options | nosniff |
| x-frame-options | SAMEORIGIN |
| x-xss-protection | 1; mode=block |
| |
| Status | 200 |
|---|---|
| content-type | application/json |
| date | Tue, 05 Jun 2018 16:50:56 GMT |
| referrer-policy | no-referrer |
| server | nginx |
| status | 200 |
| strict-transport-security | max-age=31536000; includeSubdomains; preload |
| x-content-type-options | nosniff |
| x-frame-options | SAMEORIGIN |
| x-xss-protection | 1; mode=block |
| |
This is a GET request to fetch products from the catalog for the given company. One or more producttypes[] should be provided to indicate which product categories to use, and one or more colors[] should be provided to indicate which colors should be used for matching. Correct product types can be retrieved from the companies endpoint. The given colors (in hex format) can be from the full RGB range, and will be reduced to the reduced-color pallete.
The company to associate the photo upload request with is indicated by the company query parameter. This isn’t used by the actual photo processing code, but helps with later being able to display the most recently uploaded photo for a given company in the demo/debug web interface. Correct values can be retrieved from the companies endpoint.
Response documentation:
nonce - this is a value that can be used as an id of sorts for this request. It is a dynamic value that changes on each request, and is mainly used when polling the server for changes using the products-last endpoint.company - this is the value of the company parameter that was actually used. If a valid company query parameter was provided in the request, then the values will match. Otherwise, this indicates which company was actually used when storing the photo information.product_types - This is an array of the product types that were provided in the producttypes[] query parameter(s).products - This is an array of “product objects” for the matching products.The “product object” has the following properties:
title - the title of the productimage - a full URL for the thumbnail of the producturl - a full URL to the product page for the product on the company’s websiteprice - the price of the product (as a formatted string), but without the $ dollar sign.colors - array of color objects representing the top 6 colors in the product image.palette_colors - array of hex string representing the reduced-color palette value from the colors in the product image. I’m pretty sure this was a mistake that they aren’t the full color objects.The “color object” that is in each color array is simply an object with the key hex, whose value is a RGB hex value for the color proceeded by a # character. Originally, the API design called for additional properties in this object, but those were removed.
curl -X GET "https://api.snaphack.website/api/v1/products?company=ashleyfurniturehomestore&producttypes[]=Chair&producttypes[]=Pillow&colors[]=%23FF7777&colors[]=%23FFFF77"
GET /api/v1/products?company=ashleyfurniturehomestore&producttypes[]=Chair&producttypes[]=Pillow&colors[]=%23FF7777&colors[]=%23FFFF77 HTTP/1.1
Host: api.snaphack.website
| Status | 200 |
|---|---|
| content-type | application/json |
| date | Tue, 05 Jun 2018 16:52:22 GMT |
| referrer-policy | no-referrer |
| server | nginx |
| status | 200 |
| strict-transport-security | max-age=31536000; includeSubdomains; preload |
| x-content-type-options | nosniff |
| x-frame-options | SAMEORIGIN |
| x-xss-protection | 1; mode=block |
| |
| Status | 200 |
|---|---|
| content-type | application/json |
| date | Tue, 05 Jun 2018 16:55:59 GMT |
| referrer-policy | no-referrer |
| server | nginx |
| status | 200 |
| strict-transport-security | max-age=31536000; includeSubdomains; preload |
| x-content-type-options | nosniff |
| x-frame-options | SAMEORIGIN |
| x-xss-protection | 1; mode=block |
| |
These services allow for a multi-company experience. An app can pull down a list of available companies, with the intent of providing an interface for runtime selection.
The app can also pull down configuration data for a simply company, with the intent of providing a more “production-like” build that is tied to a single company, but with dynamic data.
This is a GET request to fetch the list of companies that are available to be used at this time, as well as some configuration data for company.
Response documentation:
data - an array of “company information” objects.The “company information object” has the following properties:
name - the name of the companyslug - the “URL slug” for the company. This is the value that should be sent in the company query parameter to the other endpoints.logo - a full URL for the logo of the companypush-notification - an object containing values to be used when displaying the local push notification after the user first navigates to a product page
text - the text to display in the push notificationurl - the URL to open after the user interacts with the push notificationproduct-types - array of “product type” objects representing the available product categories for this company.The “product type object” has the following properties:
name - the name of the product categoryslug - the “URL slug” for the product category. This is the value that should be sent in the producttypes[] query parameter to the products endpoint.image - a full URL for a representative image of the product categorycurl -X GET "https://api.snaphack.website/api/v1/companies"
GET /api/v1/companies HTTP/1.1
Host: api.snaphack.website
| Status | 200 |
|---|---|
| content-type | application/json |
| date | Tue, 05 Jun 2018 16:52:46 GMT |
| referrer-policy | no-referrer |
| server | nginx |
| status | 200 |
| strict-transport-security | max-age=31536000; includeSubdomains; preload |
| x-content-type-options | nosniff |
| x-frame-options | SAMEORIGIN |
| x-xss-protection | 1; mode=block |
| |
This is a GET request to fetch the configuration data for “Ashley Furniture”. The last “directory” in the URL request is the slug for the requested company, in this case ashleyfurniturehomestore.
Response documentation:
data - the “company information” object for the company.The “company information object” has the following properties:
name - the name of the companyslug - the “URL slug” for the company. This is the value that should be sent in the company query parameter to the other endpoints.logo - a full URL for the logo of the companypush-notification - an object containing values to be used when displaying the local push notification after the user first navigates to a product page
text - the text to display in the push notificationurl - the URL to open after the user interacts with the push notificationproduct-types - array of “product type” objects representing the available product categories for this company.The “product type object” has the following properties:
name - the name of the product categoryslug - the “URL slug” for the product category. This is the value that should be sent in the producttypes[] query parameter to the products endpoint.image - a full URL for a representative image of the product categorycurl -X GET "https://api.snaphack.website/api/v1/companies/ashleyfurniturehomestore"
GET /api/v1/companies/ashleyfurniturehomestore HTTP/1.1
Host: api.snaphack.website
| Status | 200 |
|---|---|
| content-type | application/json |
| date | Tue, 05 Jun 2018 16:53:00 GMT |
| referrer-policy | no-referrer |
| server | nginx |
| status | 200 |
| strict-transport-security | max-age=31536000; includeSubdomains; preload |
| x-content-type-options | nosniff |
| x-frame-options | SAMEORIGIN |
| x-xss-protection | 1; mode=block |
| |
This is a GET request to fetch the configuration data for a given company, based on a Postman environment variable. The last “directory” in the URL request is the slug for the requested company, in this case pulling from ashleyfurniturehomestore.
Response documentation:
data - the “company information” object for the company.The “company information object” has the following properties:
name - the name of the companyslug - the “URL slug” for the company. This is the value that should be sent in the company query parameter to the other endpoints.logo - a full URL for the logo of the companypush-notification - an object containing values to be used when displaying the local push notification after the user first navigates to a product page
text - the text to display in the push notificationurl - the URL to open after the user interacts with the push notificationproduct-types - array of “product type” objects representing the available product categories for this company.The “product type object” has the following properties:
name - the name of the product categoryslug - the “URL slug” for the product category. This is the value that should be sent in the producttypes[] query parameter to the products endpoint.image - a full URL for a representative image of the product categorycurl -X GET "https://api.snaphack.website/api/v1/companies/ashleyfurniturehomestore"
GET /api/v1/companies/ashleyfurniturehomestore HTTP/1.1
Host: api.snaphack.website
| Status | 200 |
|---|---|
| content-type | application/json |
| date | Tue, 05 Jun 2018 16:53:22 GMT |
| referrer-policy | no-referrer |
| server | nginx |
| status | 200 |
| strict-transport-security | max-age=31536000; includeSubdomains; preload |
| x-content-type-options | nosniff |
| x-frame-options | SAMEORIGIN |
| x-xss-protection | 1; mode=block |
| |
There is a demo/debugging website setup at https://api.snaphack.website that shows the last photo uploaded, and the last products returned.
If you add the query parameter dev to the URL, you can upload a new image by double-clicking on the thumbnail for the last uploaded photo. You can also click on the “Most Common Colors” to change the color selection, and click on the “Product Types” to change the product category selection. In dev mode, the reduced color palette is also displayed, which is used for product filtering. This allows you to determine why a product was returned.
These additional services were created to enable this experience and would not be needed in a production environment.
This is the last response returned from the photo endpoint for upload a new photo for color processing (and later other aesthetics).
The company to associate the photo upload request with is indicated by the company query parameter. This isn’t used by the actual photo processing code, but helps with later being able to display the most recently uploaded photo for a given company in the demo/debug web interface. Correct values can be retrieved from the companies endpoint.
Response documentation:
nonce - this is a value that can be used as an id of sorts for this upload. It is a dynamic value that changes on each upload, and is mainly used when polling the server for changes using the photo-last endpoint.company - this is the value of the company parameter that was actually used. If a valid company query parameter was provided in the request, then the values will match. Otherwise, this indicates which company was actually used when storing the photo information.uploaded_file - This is a full URL to the photo that was just uploaded. This is mainly stored/provided for debugging information and utilized by the demo website.image_width - the full width of the image that was uploaded, in pixels.image_height - the full height of the image that was uploaded, in pixels.colors - an array of color objects representing the top 6 colors in the uploaded image.palette_colors - an array of color objects representing the reduced-palette equivalents of the colors in the colors array.complementary_colors - an array of color objects representing the complementary color for each color in the colors array.The “color object” that is in each color array is simply an object with the key hex, whose value is a RGB hex value for the color proceeded by a # character. Originally, the API design called for additional properties in this object, but those were removed.
curl -X GET "https://api.snaphack.website/api/v1/photo-last?company=ashleyfurniturehomestore"
GET /api/v1/photo-last?company=ashleyfurniturehomestore HTTP/1.1
Host: api.snaphack.website
| Status | 200 |
|---|---|
| content-type | application/json |
| date | Tue, 05 Jun 2018 16:53:57 GMT |
| referrer-policy | no-referrer |
| server | nginx |
| status | 200 |
| strict-transport-security | max-age=31536000; includeSubdomains; preload |
| x-content-type-options | nosniff |
| x-frame-options | SAMEORIGIN |
| x-xss-protection | 1; mode=block |
| |
This is a GET request return the response to the last request to fetch products from the catalog for the given company using the products endpoint.
The company to associate the photo upload request with is indicated by the company query parameter. This isn’t used by the actual photo processing code, but helps with later being able to display the most recently uploaded photo for a given company in the demo/debug web interface. Correct values can be retrieved from the companies endpoint.
Response documentation:
nonce - this is a value that can be used as an id of sorts for this request. It is a dynamic value that changes on each request, and is mainly used when polling the server for changes using the products-last endpoint.company - this is the value of the company parameter that was actually used. If a valid company query parameter was provided in the request, then the values will match. Otherwise, this indicates which company was actually used when storing the photo information.product_types - This is an array of the product types that were provided in the producttypes[] query parameter(s).products - This is an array of “product objects” for the matching products.The “product object” has the following properties:
title - the title of the productimage - a full URL for the thumbnail of the producturl - a full URL to the product page for the product on the company’s websiteprice - the price of the product (as a formatted string), but without the $ dollar sign.colors - array of color objects representing the top 6 colors in the product image.palette_colors - array of hex string representing the reduced-color palette value from the colors in the product image. I’m pretty sure this was a mistake that they aren’t the full color objects.The “color object” that is in each color array is simply an object with the key hex, whose value is a RGB hex value for the color proceeded by a # character. Originally, the API design called for additional properties in this object, but those were removed.
curl -X GET "https://api.snaphack.website/api/v1/products-last?company=ashleyfurniturehomestore"
GET /api/v1/products-last?company=ashleyfurniturehomestore HTTP/1.1
Host: api.snaphack.website
| Status | 200 |
|---|---|
| content-type | application/json |
| date | Tue, 05 Jun 2018 16:54:10 GMT |
| referrer-policy | no-referrer |
| server | nginx |
| status | 200 |
| strict-transport-security | max-age=31536000; includeSubdomains; preload |
| x-content-type-options | nosniff |
| x-frame-options | SAMEORIGIN |
| x-xss-protection | 1; mode=block |
| |