MeasureSquare Calculator Help Document

Calculator API URL https://calculator.measuresquare.com/public/calculator

Request

Headers

Name Type Description
apiKey string Please contact Allen Wang, api@measuresquare.com to get your Publishable API key for your application integration authorization.

Parameters

Name Type Description
measureSystem string The measure system of calculator, value: Imperial | Metric
imageWidth int The pixel of generated image width, value: 512 ~ 2048, default: 1024
modelScript string The xml formate of estimate models, include floorproduct&rooms informations

The format of [modelScript] Parameter


 <M2Script Direction="Auto" CutMargin="0'3"" MaxTSeamCount="2" GroutWidth="0.25"">
  <FloorProduct Type="Carpet" ID="carpet" Width="12'0"" Length="150'0"" HoriRepeat="0'0"" VertRepeat="0'0"" HoriDrop="0'0"" VertDrop="0'0""/> 
  <RectRoom RoomName="room 1" Width="13'0"" Length="15'0"" />
  <Stairway CoveringStyle="Waterfall" StairName="stair 1" >
    <StairUnit UnitStyle="Regular" StepCount="8" StairWidth="3'0"" TreadWidth="0'11"" RiseHeight="0'7"" />
    <StairUnit UnitStyle="RightAngleTurnArc"/>
    <StairUnit UnitStyle="Regular" StepCount="8" StairWidth="3'0"" TreadWidth="0'11"" RiseHeight="0'7"" />
  </Stairway>
     
  <FloorProduct Type="Tile" ID="tile" Width="2'0"" Length="2'0"" TileCalcMethod="WasteAddon" WasteAddon="0%" />
  <RectRoom RoomName="room 2" Width="15'0"" Length="18'0"" />
  <PolygonRoom Roomname="room 3" Points="0,2438.40|2438.40,2438.40|2438.40,6096.00|6096.00,6096.00|6096.00,8534.40|0,8534.40" />
 </M2Script>
    
 
Note Description
Atrribute in red

Atrribute in red color is a enumerator

M2Script -> Direction: Auto | Horizontal | Vertical
FloorProduct -> Type: Carpet | Tile | Hardwood | Laminate | Vinyl | CarpetTile | VinylTile
Stairway -> CoveringStyle: Waterfall | TreadAndRise | TreadOnly | RiseOnly | Fullwrap
StairUnit -> UnitStyle: Regular | RightAngleLanding | StraightLanding | RightAngleTurn |
RightAngleLandingArc | StraightLandingArc | RightAngleTurnArc
Atrribute in blue

Atrribute in blue color is optional, the attribute with the prefix * should be placed in M2Script node, otherwise in FloorProduct node

Tile | VinylTile | CarpetTile:
* GroutWidth default is 0.25"
TileCalcMethod WasteAddon | HalfReuse | CutAndFit, default is WasteAddon
LayoutDirection 0 | 45 | 90 | 135, default is 0
StartPoint Center | Top-Left | Top-Right | Bottom-Left | Bottom-Right, default is Center

Carpet | Vinyl :
* CutMargin default is 3"
* MaxTSeamCount default is 2
HoriRepeat/VertRepeat/HoriDrop/VertDrop default is 0'0"

Tile | VinylTile | CarpetTile | Hardwood | Laminate:
WasteAddon default is 0%
If Multiple Floor Product Room/shape will use the recent floor product in front.
PolygonRoom -> Points Points= "0,2438.40|2438.40,2438.40|2438.40,6096.00|6096.00,6096.00|6096.00,8534.40|0,8534.40"
Anticlockwise, each point split by |, can display room in any shape(include L-shape)
1(ft) = 304.8, 1(in) = 25.4
2438.40 = 8(ft), 6096.00 = 20(ft), 8534.40 = 28(ft)

Response

Status Code: 200 or 404. If 200, return json formate data, include Image and Estiamte Result

                
                {
                     "ImageBase64String":"{base64ImageString}",
                     "ProductEstimates":[
                        {
                            "ID": "carpet",
                            "ShapeQty":"285.09",
                            "Usage":"366.30",
                            "TileCount":null
                        },
                        {
                            "ID": "tile",
                            "ShapeQty":"526.00",
                            "Usage":"515.21",
                            "TileCount":"129"
                        },
                     ]
                }
                
            

Samples

C#
            
    string url = "https://calculator.measuresquare.com/public/calculator";
    XElement rootElement = new XElement("M2Script", new XAttribute("Direction", "Auto"), new XAttribute("GroutWidth", "0.25\""));
    rootElement.Add(new XElement("FloorProduct", new XAttribute("Type", "Carpet"), new XAttribute("ID", "carpet"),
                                                 new XAttribute("Width", "12'0\""), new XAttribute("Length", "150'0\"")));
    rootElement.Add(new XElement("RectRoom", new XAttribute("RoomName", "room 1"),
                                             new XAttribute("Width", "13'0\""), new XAttribute("Length", "15'0\"")));
    rootElement.Add(new XElement("Stairway", new XAttribute("CoveringStyle", "Waterfall"), new XAttribute("StairName", "stair 1"),
                            new XElement("StairUnit", new XAttribute("UnitStyle", "Regular"), new XAttribute("StepCount", "8"),
                                                      new XAttribute("StairWidth", "3'0\""), new XAttribute("TreadWidth", "0'11\""),
                                                      new XAttribute("RiseHeight", "0'7\"")),
                            new XElement("StairUnit", new XAttribute("UnitStyle", "RightAngleTurnArc")),
                            new XElement("StairUnit", new XAttribute("UnitStyle", "Regular"), new XAttribute("StepCount", "8"),
                                                      new XAttribute("StairWidth", "3'0\""), new XAttribute("TreadWidth", "0'11\""),
                                                      new XAttribute("RiseHeight", "0'7\""))));
    rootElement.Add(new XElement("FloorProduct", new XAttribute("Type", "Tile"), new XAttribute("ID", "tile"),
                            new XAttribute("Width", "2'0\""), new XAttribute("Length", "2'0\"")));
    rootElement.Add(new XElement("RectRoom", new XAttribute("RoomName", "room 2"),
                            new XAttribute("Width", "15'0\""), new XAttribute("Length", "18'0\"")));
    rootElement.Add(new XElement("PolygonRoom", new XAttribute("RoomName", "room 3"),
                            new XAttribute("Points", "0,2438.40|2438.40,2438.40|2438.40,6096.00|6096.00,6096.00|6096.00,8534.40|0,8534.40")));
    Dictionary<string, object> postObj = new Dictionary<string, object>();
    postObj.Add("measureSystem", "Imperial");
    postObj.Add("imageWidth", 1024);
    postObj.Add("modelScript", rootElement.ToString());
    using (HttpClient client = new HttpClient()){
        client.DefaultRequestHeaders.Add("apiKey", "Your Publishable API Key");
        using (HttpResponseMessage response = await client.PostAsJsonAsync(url, postObj))
        {
            if (response.StatusCode == HttpStatusCode.OK)
            {
               //response.Content see Response section
            }
        }
    }