We are already accustomed to the fact that many different IT services have real knowledge about the world around us. Relying on such knowledge in various fields, we make certain decisions. For example, when it comes to different types of translocations, we strive to get optimized routes to get to the desired destinations by car, bike, public transport or even on foot.
What will help us get these actual, optimal and complete routes? As an answer to this question, we suggest that you get acquainted with such a tool as the distance matrix API (DM API). And to work with the DM API, you need to visit the official distance api website.
Your assistant DM API
By using the specified service, any user gets access to those resources that he may need to achieve certain goals and objectives. Of course, first of all, the user will not interfere with familiarity with the documentation of the service. Yes, the volume of documents there is rather big, but it’s justified because this makes it possible to use all the features of the DM API easily and conveniently, wherever users of the service are located.
Within the framework of this article, we will not be able to make a detailed review of the service, but we will still tell about the main features of the DM API. And we remind you, before you get started, by clicking on the link above, you can read the necessary documentation, including the guide for developers itself. After that, you will be firmly convinced that, using the DM API, you can get full-fledged and up-to-date routes for moving by bicycle, in a car, in another form of transport, and also on foot. At the same time, support for such parameters as the distance of your route, travel time, the specific peculiarities of the route, etc. is preserved. Moreover, the capabilities of the DM API allow you to work with information about several starting and ending positions of the route. Also unprecedented is the fact that both the distance and the time to overcome it are calculated for each element and displayed in a matrix. And the definition of the element itself implies the chain “starting position – finishing position”. Users will also benefit from the information that taking into account the actual situation of the route in the calculations is not necessary if it does not affect their business goals. And this will allow them to save both time and money when interacting with the DM API.
Strictly speaking, all data provided by the DM API can be used for further filtering, sorting and ranking on those sites whose visitors are looking for a wide variety of information in relation to work, real estate, hotels, etc.
DM API – it`s simple
So, we have a distance matrix, let’s analyze it. In its composition, we can see mandatory fields with request data and the so-called extended (optional) fields that may not be included in the request. Continuing to analyze further, we will see that the combination of the request body and response will be shown in real time, and therefore subject to constant updates, if only any of the indicators change.
Let’s simulate the work of the DM API. For example, let’s say we choose the center of London as our starting point and want to calculate the distance from it to nine finishing positions on the outskirts of the city. At the same time, we definitely need to get information and time spent on the road.
Our first step will be the correct formation of the request. We have already mentioned the required and optional query parameters. Let’s remember them again.
Let’s start with the obligatory indication of the initial position from which the requested route should start. In our example, this is the center of London. How can we label it? Anyone. Can we provide it as an address? Yes, we can. It will not be a problem for a geocoder to convert a postal address into geographic coordinates and use them to calculate the distance. But what if we already specified the coordinates of the original location in the request? Well, this option will be used by the service for calculations without changes.
The next mandatory component of the request is the indication of the finishing positions. In our example, these are those nine places on the outskirts of the city where you need to get from its center. It is for these routes that we want to calculate the distance and time. In what form should the finishing positions be indicated? Exactly the same as the starting ones, either by addresses or geographical coordinates.
And the well-known API key, which is your unique identifier, completes our set of required request characteristics.
As for the so-called extended query parameters, their list and explanations can be found by clicking on the above link to our service. Moreover, by clicking on the link, you will also receive information about the components of the response parameters (mandatory and optional), as well as about all the data you are interested in relation to the DM API and not only it.