Centroid API

Introduction

The centroid method helps businesses identify the location of depots and facilities used for manufacturing, supplying and other production-related aspects of the business. The ultimate goal of this method is to use mathematical formulations to achieve either lower shipping costs, lower shipping time or both in relation to profits. Centroid are used primarily with a geographic information system to create different clusters of business demand points and then determine an optimal location that will service demand from a given set of points.

Authentication

To authenticate to the API you need to add api-key header to your requests with an active subscription key supporting the centroid API, you can get your keys from subscriptions page under your AMS account.

Endpoint

endpoint for the centroid api is available at:

https://amsapis.azure-api.net/location/centroid

Request

The request you send will include the list of locations you want to find the centroid for,plus metadata on the centroids

{
    "locations": [
        {
            "lat": 25.1128,
            "lng": 55.17367
        },
        {
            "lat": 25.12873,
            "lng": 55.18886
        },
        {
            "lat": 25.14295,
            "lng": 55.20551
        }
    ],
    "numberOfCentroid": 2,
    "travelTimeInMints": 1000,
    "departureTime":1652954924000
}

Breakdown of request fields is as follow:

  • locations: list of points
  • numberOfCentroid : Number of clusters that needs to created
  • travelTimeInMints : from the center return only those points that can be reached with this defined time period
  • departureTime : Departure time, in millisecond unix epoch format

Response

The response lists the the clusters the centroid engines creates based on the location and centroids criteria provided in request, example response:

[
    {
        "cluster": [
            {
                "lat": 25.16097,
                "lng": 55.21933
            },
            {
                "lat": 25.18031,
                "lng": 55.2322
            },
            {
                "lat": 25.19716,
                "lng": 55.24495
            },
            {
                "lat": 25.21361,
                "lng": 55.25591
            }
        ],
        "centroid": {
            "lat": 25.18031,
            "lng": 55.2322
        }
    },
    {
        "cluster": [
            {
                "lat": 25.1128,
                "lng": 55.17367
            },
            {
                "lat": 25.12873,
                "lng": 55.18886
            },
            {
                "lat": 25.14295,
                "lng": 55.20551
            }
        ],
        "centroid": {
            "lat": 25.1128,
            "lng": 55.17367
        }
    }
]

The API groups each cluster of points, with the associated centroid.

Open API Documentation

You can view the API documentation in open API format from here