Traffic - Get Traffic Flow Segment

Use to get information about the speeds and travel times of the specified section of road.

The Traffic Flow Segment API is an HTTP GET request that provides information about the speeds and travel times of the road fragment closest to the given coordinates. It is designed to work alongside the Flow layer of the Render Service to support clickable flow data visualizations. With the Traffic Flow Segment API, the client side can connect any place in the map with flow data on the closest road and present it to the user.

GET https://atlas.microsoft.com/traffic/flow/segment/{format}?api-version=1.0&style={style}&zoom={zoom}&query={query}
GET https://atlas.microsoft.com/traffic/flow/segment/{format}?api-version=1.0&style={style}&zoom={zoom}&query={query}&unit={unit}&thickness={thickness}&openLr={openLr}

URI Parameters

Name In Required Type Description
format
path True

ResponseFormat

Desired format of the response. Value can be either json or xml.

api-version
query True

string

Version number of Azure Maps API.

query
query True

number[]

Coordinates of the point close to the road segment. This parameter is a list of four coordinates, containing two coordinate pairs (lat, long, lat, long), and calculated using EPSG4326 projection. When this endpoint is called directly, coordinates are passed in as a single string containing four coordinates, separated by commas.

style
query True

TrafficFlowSegmentStyle

The style to be used to render the tile. Valid values are absolute which returns colors reflecting the absolute speed measured, relative which returns the speed relative to free-flow, Relative-delay which displays relative speeds only where they are different from the freeflow speeds

zoom
query True

integer

int32

Zoom level for the desired tile. Zoom value must be in the range: 0-22 (inclusive). Please see Zoom Levels and Tile Grid for details.

openLr
query

boolean

Boolean on whether the response should include OpenLR code

thickness
query

integer

int32

The value of the width of the line representing traffic. This value is a multiplier and the accepted values range from 1 - 20. The default value is 10.

unit
query

SpeedUnit

Unit of speed in KMPH or MPH

Request Header

Name Required Type Description
x-ms-client-id

string

Specifies which account is intended for usage in conjunction with the Microsoft Entra ID security model. It represents a unique ID for the Azure Maps account and can be retrieved from the Azure Maps management plane Account API. To use Microsoft Entra ID security in Azure Maps see the following articles for guidance.

Responses

Name Type Description
200 OK

TrafficFlowSegmentData

OK

Other Status Codes

ErrorResponse

An unexpected error occurred.

Security

AADToken

These are the Microsoft Entra OAuth 2.0 Flows. When paired with Azure role-based access control it can be used to control access to Azure Maps REST APIs. Azure role-based access controls are used to designate access to one or more Azure Maps resource account or sub-resources. Any user, group, or service principal can be granted access via a built-in role or a custom role composed of one or more permissions to Azure Maps REST APIs.

To implement scenarios, we recommend viewing authentication concepts. In summary, this security definition provides a solution for modeling application(s) via objects capable of access control on specific APIs and scopes.

Notes

  • This security definition requires the use of the x-ms-client-id header to indicate which Azure Maps resource the application is requesting access to. This can be acquired from the Maps management API.

The Authorization URL is specific to the Azure public cloud instance. Sovereign clouds have unique Authorization URLs and Microsoft Entra ID configurations. * The Azure role-based access control is configured from the Azure management plane via Azure portal, PowerShell, CLI, Azure SDKs, or REST APIs. * Usage of the Azure Maps Web SDK allows for configuration based setup of an application for multiple use cases.

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
https://atlas.microsoft.com/.default https://atlas.microsoft.com/.default

subscription-key

This is a shared key that is provisioned when you Create an Azure Maps account in the Azure portal or using PowerShell, CLI, Azure SDKs, or REST API.

With this key, any application can access all REST API. In other words, this key can be used as a master key in the account that they are issued in.

For publicly exposed applications, our recommendation is to use the confidential client applications approach to access Azure Maps REST APIs so your key can be securely stored.

Type: apiKey
In: query

SAS Token

This is a shared access signature token is created from the List SAS operation on the Azure Maps resource through the Azure management plane via Azure portal, PowerShell, CLI, Azure SDKs, or REST APIs.

With this token, any application is authorized to access with Azure role-based access controls and fine-grain control to the expiration, rate, and region(s) of use for the particular token. In other words, the SAS Token can be used to allow applications to control access in a more secured way than the shared key.

For publicly exposed applications, our recommendation is to configure a specific list of allowed origins on the Map account resource to limit rendering abuse and regularly renew the SAS Token.

Type: apiKey
In: header

Examples

Request traffic flow segment information

Sample request

GET https://atlas.microsoft.com/traffic/flow/segment/json?api-version=1.0&style=absolute&zoom=10&query=52.41072,4.84239

Sample response

{
  "flowSegmentData": {
    "frc": "FRC3",
    "currentSpeed": 79,
    "freeFlowSpeed": 79,
    "currentTravelTime": 33,
    "freeFlowTravelTime": 33,
    "confidence": 0.5,
    "coordinates": {
      "coordinate": [
        {
          "latitude": 52.404648,
          "longitude": 4.8442388
        },
        {
          "latitude": 52.408447,
          "longitude": 4.8357286
        }
      ]
    },
    "openlr": null,
    "@version": "1.0.53-mascoma"
  }
}

Definitions

Name Description
Coordinates

Includes the coordinates describing the shape of the segment. Coordinates are shifted from the road depending on the zoom level to support high quality visualization in every scale.

ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Error response

FlowSegmentData

Flow Segment Data property

LatLongPair

A location represented as a latitude and longitude.

ResponseFormat

Desired format of the response. Value can be either json or xml.

SpeedUnit

Unit of speed in KMPH or MPH

TrafficFlowSegmentData

This object is returned from a successful Traffic Flow Segment call

TrafficFlowSegmentStyle

The style to be used to render the tile. Valid values are absolute which returns colors reflecting the absolute speed measured, relative which returns the speed relative to free-flow, Relative-delay which displays relative speeds only where they are different from the freeflow speeds

Coordinates

Includes the coordinates describing the shape of the segment. Coordinates are shifted from the road depending on the zoom level to support high quality visualization in every scale.

Name Type Description
coordinate

LatLongPair[]

Coordinate array

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

object

The additional info.

type

string

The additional info type.

ErrorDetail

The error detail.

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorDetail[]

The error details.

message

string

The error message.

target

string

The error target.

ErrorResponse

Error response

Name Type Description
error

ErrorDetail

The error object.

FlowSegmentData

Flow Segment Data property

Name Type Description
@version

string

This indicates the software version that generated the response.

confidence

number

The confidence is a measure of the quality of the provided travel time and speed. A value of 1 means full confidence, that the response contains the highest quality data. Lower values indicate the degree that the response may vary from the actual conditions on the road. Any value greater than 0.6 means the information was based on real-time probe input. A value of 0.5 means the reported speed is based on historical info. A value between 0.5 and 0.6 has a calculated weighted average between historical and live speeds.

coordinates

Coordinates

Includes the coordinates describing the shape of the segment. Coordinates are shifted from the road depending on the zoom level to support high quality visualization in every scale.

currentSpeed

integer

The current average speed at the selected point, in the units requested. This is calculated from the currentTravelTime and the length of the selected segment.

currentTravelTime

integer

Current travel time in seconds, across this traffic segment, based on fused real-time measurements between the defined locations in the specified direction.

frc

string

Functional Road Class. This indicates the road type: 0: Motorway, freeway or other major road. 1: Major road, less important than a motorway. 2: Other major road. 3: Secondary road. 4: Local connecting road. 5: Local road of high importance. 6: Local road.

freeFlowSpeed

integer

The free flow speed expected under ideal conditions, expressed in the units requested. This is related to the freeFlowTravelTime.

freeFlowTravelTime

integer

The travel time in seconds, across this traffic segment, which would be expected under ideal free flow conditions.

openlr

string

OpenLR code for segment. See OpenLR for more information on the use of Open LR codes.

LatLongPair

A location represented as a latitude and longitude.

Name Type Description
latitude

number

Latitude property

longitude

number

Longitude property

ResponseFormat

Desired format of the response. Value can be either json or xml.

Name Type Description
json

string

The JavaScript Object Notation Data Interchange Format

xml

string

The Extensible Markup Language

SpeedUnit

Unit of speed in KMPH or MPH

Name Type Description
KMPH

string

Kilometers Per Hour

MPH

string

Miles Per Hour

TrafficFlowSegmentData

This object is returned from a successful Traffic Flow Segment call

Name Type Description
flowSegmentData

FlowSegmentData

Flow Segment Data property

TrafficFlowSegmentStyle

The style to be used to render the tile. Valid values are absolute which returns colors reflecting the absolute speed measured, relative which returns the speed relative to free-flow, Relative-delay which displays relative speeds only where they are different from the freeflow speeds

Name Type Description
absolute

string

relative

string

relative-delay

string