title: Google Distance Matrix API: How to specify origin-destination pairs?
body: <p>I am using the Python client library for Google Maps API (<a href="https://github.com/googlemaps/google-maps-services-python" rel="nofollow noreferrer">Github link</a>).</p>
  
  <p>I would like to get the <code>duration_in_traffic</code> figures for the following trips:</p>
  
  <ul>
  <li><p><code>Address1</code> to <code>Address2</code></p></li>
  <li><p><code>Address2</code> to <code>Address1</code></p></li>
  <li><p><code>Address1</code> to <code>Address3</code></p></li>
  <li><p><code>Address3</code> to <code>Address1</code></p></li>
  </ul>
  
  <p>But the syntax of the Google Distance Matrix API (<a href="https://developers.google.com/maps/documentation/distance-matrix/intro" rel="nofollow noreferrer">documentation</a>) is problematic in its presumptuousness. It assumes that the user wants data for all conceivable pairings of origin and destination addresses.</p>
  
  <p>The issue is that the following code (<a href="https://github.com/googlemaps/google-maps-services-python/blob/master/googlemaps/test/test_distance_matrix.py" rel="nofollow noreferrer">source</a>)...</p>
  
  <pre><code>origins = [Address1, Address2, Address3]
  destinations = [Address1, Address2, Address3]
  
  matrix = client.distance_matrix(origins, destinations,
                                          mode="driving",
                                          language="en",
                                          units="imperial",
                                          departure_time=now,
                                          traffic_model="best_guess")
  </code></pre>
  
  <p>produces <strong>nine</strong> results (that is, every possible combination of origin-destination pairings), when I only need the previously-stated <strong>four</strong>.</p>
  
  <p>I realize that I can parse these results to extract only the four durations that I need, but I don't want to needlessly double the execution time of my script by forcing it to download data that I do not want.</p>
  
  <p>I also realize that I can send 4 separate requests to get just the durations that I want (that is, one pairing per request), but I am trying not to surpass the quota for my free, non-premium Distance Matrix API account.</p>
  
  <p>So, is it possible to specify the origin-destination pairings within the same request? </p>