# Matrix Response

> Contains the distances and times between specified locations.

Page: https://docs.icepack.ai/distance-matrix/matrix-response/

## Overview

The matrix response is the object returned after a [matrix request](/distance-matrix/matrix-request/) is submitted to the API. The response contains named elements for each of the source-destination pairs computed.

### Applicable models

* Matrix `matrix-vyv95n7wchpl`

### Endpoint

* GET: **https://api.icepack.ai/matrix/{requestid}**

<hr>

## Matrix Response Element

### Schema definition

```protobuf
message Element{
  required string fromId = 1;
  required string toId = 2;
  required float distance = 3;
  required float duration = 4;
}
```



### Fields

fromId
: The [location id](/distance-matrix/location/) for the source of the element.

toId
: The [location id](/distance-matrix/location/) for the destination of the element.

distance
: The distance between source and destination in the units specified in the [matrix request](/distance-matrix/matrix-request/).

duration
: The duration between source and destination in the units specified in the [matrix request](/distance-matrix/matrix-request/).

## Matrix Response

### Schema definition 

```protobuf
message MatrixResponse{
  repeated Element elements = 1;
}
```



### Fields

elements
: A list of elements corresponding to the distances and durations between the requested source and destination [locations](/distance-matrix/location/).

### Examples

The following illustrates a valid response corresponding to a 3x3 matrix request between `The Oval Bar Dublin`, `Kehoes Pub` and `The Confession Box` (the same 3x3 matrix in the [request examples](/distance-matrix/matrix-request/#examples)). You'll notice that only 6 elements are returned as the distances and times between locations to themselves are zero (and are thus omitted in the response).
```protobuf
elements {
  fromId: "The Oval Bar Dublin"
  toId: "The Confession Box"
  distance: 1.49974537
  duration: 0.0618333332
}
elements {
  fromId: "The Oval Bar Dublin"
  toId: "Kehoes Pub"
  distance: 3.18078804
  duration: 0.133638889
}
elements {
  fromId: "The Confession Box"
  toId: "The Oval Bar Dublin"
  distance: 1.48606718
  duration: 0.0595
}
elements {
  fromId: "The Confession Box"
  toId: "Kehoes Pub"
  distance: 3.03498483
  duration: 0.126638889
}
elements {
  fromId: "Kehoes Pub"
  toId: "The Oval Bar Dublin"
  distance: 2.14612246
  duration: 0.0943055525
}
elements {
  fromId: "Kehoes Pub"
  toId: "The Confession Box"
  distance: 2.80850101
  duration: 0.110138886
}
```



> **Note:**
> If you’re a fan of **R** make sure to check out the **iceR** package which handles processing the matrix responses really quickly into either long-form or matrix form.



<hr>

