{"id":2543,"date":"2023-12-14T19:47:34","date_gmt":"2023-12-14T19:47:34","guid":{"rendered":"https:\/\/developers.maplink.global\/building-requests-for-the-trip-api\/"},"modified":"2024-02-28T18:11:54","modified_gmt":"2024-02-28T18:11:54","slug":"building-requests-for-the-trip-api","status":"publish","type":"post","link":"https:\/\/developers.maplink.global\/en\/building-requests-for-the-trip-api\/","title":{"rendered":"Building requests for the Trip API"},"content":{"rendered":"\n<p>Before you can start using the API, you will need to <a href=\"https:\/\/developers.maplink.global\/en\/how-do-i-generate-the-token-for-authentication\/\" data-type=\"post\" data-id=\"999\">obtain the <em>authentication token<\/em><\/a>. <\/p>\n\n<p>The following <em>headers <\/em>will be required, where the word <strong><em>token <\/em><\/strong>must be replaced by the token obtained in the authentication process:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">--header 'Content-Type: application\/json' \\\n--header 'Authorization: Bearer token'<\/pre>\n\n<p>In <em>body <\/em>all the parameters will be sent to solve the route calculation.<\/p>\n\n<p>The Trip API can work in two ways, <strong>synchronously <\/strong>or <strong>asynchronously<\/strong>.<\/p>\n\n<h3 class=\"wp-block-heading\">Synchronous Trip<\/h3>\n\n<p>With Synchronous Trip it is possible to obtain <strong>the routing result in a single request<\/strong>. Synchronous Trip has the following endpoints, where the term  <code>{{tripId}}<\/code><strong> <\/strong>must be replaced by the ID of the route to be queried:<\/p>\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/api.maplink.global\/trip\/v2\/calculations\">https:\/\/api.maplink.global\/trip\/v2\/calculations<\/a> &#8211; <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">POST<\/mark><\/strong><br\/>Used to send the logistics problem. The complete routing result is returned.<br\/><\/li>\n\n\n\n<li><a href=\"https:\/\/api.maplink.global\/trip\/v1\/solutions\/%7B%7BtripId%7D%7D\">https:\/\/api.maplink.global\/trip\/v1\/solutions\/{{tripId}}<\/a> &#8211; <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">GET<\/mark><\/strong><br\/>Returns the routing result according to the ID entered. So that you don&#8217;t have to send the request again, you can use the route ID you previously used for the query.<\/li>\n<\/ul>\n\n<p>The route coordinates in Synchronous Trip will be returned in the format <strong>\n  <em><a href=\"https:\/\/developers.maplink.global\/alterar-tipo-de-retorno-das-coordenadas-da-rota\/\" data-type=\"post\" data-id=\"1081\">polyline<\/a> <\/em>\n<\/strong>format for better performance.<\/p>\n\n<h3 class=\"wp-block-heading\"><strong>Asynchronous Trip<\/strong><\/h3>\n\n<p>Unlike Synchronous Trip, when sending a request to Asynchronous Trip <strong>only the route ID will be returned<\/strong> for future reference. It also has two extra endpoints that make it possible to check the status of request processing.<\/p>\n\n<p>Asynchronous Trip has the following endpoints, where the term <code>{{tripId}}<\/code> must be replaced by the ID of the route to be consulted:<\/p>\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/api.maplink.global\/trip\/v1\/problems\">https:\/\/api.maplink.global\/trip\/v1\/problems<\/a> &#8211; <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">POST<\/mark><\/strong><br\/>Used to send the route to be routed. An ID will be returned for the query.<\/li>\n\n\n\n<li><a href=\"https:\/\/api.maplink.global\/trip\/v1\/events?jobId=%7B%7BtripId%7D%7D\">https:\/\/api.maplink.global\/trip\/v1\/events?jobId={{tripId}}<\/a> &#8211; <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">GET<\/mark><\/strong><br\/>Returns all the states from the time the request was received until its completion.<\/li>\n\n\n\n<li><a href=\"https:\/\/api.maplink.global\/trip\/v1\/jobs\/%7B%7BtripId%7D%7D\">https:\/\/api.maplink.global\/trip\/v1\/jobs\/{{tripId}}<\/a> &#8211; <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\"><strong>GET<\/strong><\/mark><br\/>Returns the current processing status of the request.<\/li>\n\n\n\n<li><a href=\"https:\/\/api.maplink.global\/trip\/v1\/solutions\/%7B%7BtripId%7D%7D\">https:\/\/api.maplink.global\/trip\/v1\/solutions\/{{tripId}}<\/a> &#8211; <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-green-cyan-color\">GET<\/mark><\/strong><br\/>Returns the result of the routing.<\/li>\n<\/ul>\n\n<p>The route coordinates in Asynchronous Trip will be returned in <strong><a href=\"https:\/\/developers.maplink.global\/alterar-tipo-de-retorno-das-coordenadas-da-rota\/\" data-type=\"post\" data-id=\"1081\">object<\/a><\/strong>.<\/p>\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><\/p>\n<cite><strong>Note<\/strong>: Route IDs are available for consultation for a period of <strong>7 days<\/strong>. If you need your route to be stored for longer, check out <a href=\"https:\/\/developers.maplink.global\/armazenando-rotas-com-route-storage\/\" data-type=\"post\" data-id=\"1085\">Route Storage<\/a> to find out more.<\/cite><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Before you can start using the API, you will need to obtain the authentication token. The following headers will be required, where the word token must be replaced by the token obtained in the authentication process: In body all the parameters will be sent to solve the route calculation. The Trip API can work in [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[161],"tags":[],"class_list":["post-2543","post","type-post","status-publish","format-standard","hentry","category-trip-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/comments?post=2543"}],"version-history":[{"count":1,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2543\/revisions"}],"predecessor-version":[{"id":2544,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2543\/revisions\/2544"}],"wp:attachment":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/media?parent=2543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/categories?post=2543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/tags?post=2543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}