Get Distances and Duration for Closest Locations
1 min
code examples curl request post \\ \ url https //api upstartcommerce com/v1/location/closestlocationswithdistancesandduration \\ \ header 'accept application/json' \\ \ header 'content type application/json' \\ \ header 'x upstart tenant string' \\ \ data '{ "coordinates" { "latitude" "", "longitude" "" }, "distance" { "value" "" }, "term" { "and" { "or" { "not" {} }, "not" {} }, "or" { "not" {} }, "not" {} } }'var myheaders = new headers(); myheaders append("accept", "application/json"); myheaders append("content type", "application/json"); myheaders append("x upstart tenant", "string"); var raw = json stringify({ "coordinates" { "latitude" "", "longitude" "" }, "distance" { "value" "" }, "term" { "and" { "or" { "not" {} }, "not" {} }, "or" { "not" {} }, "not" {} } }); var requestoptions = { method 'post', headers myheaders, body raw, redirect 'follow' }; fetch("https //api upstartcommerce com/v1/location/closestlocationswithdistancesandduration", requestoptions) then(response => response text()) then(result => console log(result)) catch(error => console log('error', error));require "uri" require "json" require "net/http" url = uri("https //api upstartcommerce com/v1/location/closestlocationswithdistancesandduration") https = net http new(url host, url port) https use ssl = true request = net http post new(url) request\["accept"] = "application/json" request\["content type"] = "application/json" request\["x upstart tenant"] = "string" request body = json dump({ "coordinates" { "latitude" "", "longitude" "" }, "distance" { "value" "" }, "term" { "and" { "or" { "not" {} }, "not" {} }, "or" { "not" {} }, "not" {} } }) response = https request(request) puts response read body import requests import json url = "https //api upstartcommerce com/v1/location/closestlocationswithdistancesandduration" payload = json dumps({ "coordinates" { "latitude" "", "longitude" "" }, "distance" { "value" "" }, "term" { "and" { "or" { "not" {} }, "not" {} }, "or" { "not" {} }, "not" {} } }) headers = { 'accept' 'application/json', 'content type' 'application/json', 'x upstart tenant' 'string' } response = requests request("post", url, headers=headers, data=payload) print(response text) responses // object with filtered locations, including several distances and duration data from specified coordinates { "coordinatesfrom" { "latitude" "", "longitude" "" }, "locationswithgoogledata" \[ { "location" { "id" "", "name" "", "siteids" \[ "" ], "locationtype" "", "public" true, "operational" true, "address" { "city" "", "country" "", "county" "", "postalcode" "", "stateorregion" "", "street1" "", "street2" "" }, "coordinates" { "latitude" "", "longitude" "" }, "contactinformation" "", "operationhoursexceptions" \[ { "closed" 1200, "exceptiontype" "", "isopen" false, "name" "memorial day", "open" "08 00" } ], "pickuphoursexceptions" \[ { "closed" 1200, "exceptiontype" "", "isopen" false, "name" "memorial day", "open" "08 00" } ], "dateoriginallyopened" "", "remodeldates" \[ "2019 05 29" ], "externalapplicationreferences" "", "content" \[ { "content" "", "enddatetime" "", "identifier" "", "startdatetime" "" } ], "dynamicproperties" {}, "pricingzone" "", "pickupavailable" false, "deliveryavailable" false, "numreviews" "", "avgrating" "", "directionssummary" "", "hoursofoperation" \[ { "closed" 1200, "day" "", "isopen" false, "open" "08 00" } ], "pickuphours" \[ { "closed" 1200, "day" "", "isopen" false, "open" "08 00" } ], "media" "" }, "directdistance" { "value" 157 75, "unit" "" }, "roaddistance" { "value" 157 75, "unit" "" }, "durationinseconds" 0 } ] }// the request contained information that the server was unable to process appropriate errors are provided in the response body { "name" "", "code" "", "detail" "" }// the provided credentials were not valid for this endpoint it may be that they are expired or that the user's roles are insufficient { "name" "", "code" "", "detail" "", "reason" "" }