title: Write JSON data from multiple API requests to a file and take one key
body: <p>I need to write JSON data from multiple API request to a file and then get from it only summary: distance without anything else.</p>
  
  <p>My output is:</p>
  
  <pre><code>200 OK
  {"routes":[{"warnings":[{"code":1,"message":"There may be restrictions on some roads"}],"summary":{"distance":899.6,"duration":102.1},"geometry_format":"encodedpolyline","geometry":"u~uiHir{iFb@SXzADTlAk@JOJ]@_@CWW{AKo@k@eDEYKo@y@{EGc@G]GYCOa@gCc@iCoBsLNGlAm@VK^Sh@Un@tD","segments":[{"distance":899.6,"duration":102.1,"steps":[{"distance":22.1,"duration":5.3,"type":11,"instruction":"Head south","name":"","way_points":[0,1]},{"distance":45.4,"duration":10.9,"type":1,"instruction":"Turn right","name":"","way_points":[1,3]},{"distance":645.5,"duration":52.3,"type":0,"instruction":"Turn left onto Партизанська вулиця","name":"Партизанська вулиця","way_points":[3,21]},{"distance":114.4,"duration":20.6,"type":1,"instruction":"Turn right","name":"","way_points":[21,26]},{"distance":72.1,"duration":13,"type":1,"instruction":"Turn right","name":"","way_points":[26,27]},{"distance":0,"duration":0,"type":10,"instruction":"Arrive at your destination, on the left","name":"","way_points":[27,27]}]}],"way_points":[0,27],"extras":{"roadaccessrestrictions":{"values":[[0,1,0],[1,3,2],[3,27,0]],"summary":[{"value":0,"distance":854.2,"amount":94.95},{"value":2,"distance":45.4,"amount":5.05}]}},"bbox":[38.484536,48.941171,38.492904,48.943022]}],"bbox":[38.484536,48.941171,38.492904,48.943022],"info":{"attribution":"openrouteservice.org | OpenStreetMap contributors","engine":{"version":"5.0.1","build_date":"2019-05-29T14:58:37Z"},"service":"routing","timestamp":1568139032916,"query":{"profile":"driving-car","preference":"fastest","coordinates":[[38.485115,48.942059],[38.492073,48.941676]],"language":"en","units":"m","geometry":true,"geometry_format":"encodedpolyline","instructions_format":"text","instructions":true,"elevation":false}}}
  200 OK
  {"routes":[{"summary":{"distance":2298,"duration":365.6},"geometry_format":"encodedpolyline","geometry":"u~a{Gee`zDLIvBvDpClCtA|AXHXCp@m@bBsBvBmC`AmAtIoKNVLXHPb@c@`A_AFENGzAc@XKZCJ?PDLBH@F?T?PC~CcATOt@Sd@QLKBCBAb@]ZG|@OY_DQ}IE{DC_DAg@Eg@q@aFgBuH^GjBFj@B`ABzFPjGRHA","segments":[{"distance":2298,"duration":365.6,"steps":[{"distance":9,"duration":2.1,"type":11,"instruction":"Head southeast","name":"","way_points":[0,1]},{"distance":284,"duration":68.1,"type":1,"instruction":"Turn right onto Будьонного вулиця","name":"Будьонного вулиця","way_points":[1,6]},{"distance":237.1,"duration":56.9,"type":4,"instruction":"Turn slight left","name":"","way_points":[6,10]},{"distance":243.9,"duration":58.5,"type":13,"instruction":"Keep right","name":"","way_points":[10,11]},{"distance":34.9,"duration":8.4,"type":1,"instruction":"Turn right","name":"","way_points":[11,14]},{"distance":470.9,"duration":98.8,"type":0,"instruction":"Turn left","name":"","way_points":[14,38]},{"distance":583.6,"duration":46.7,"type":0,"instruction":"Turn left onto М-05","name":"М-05","way_points":[38,46]},{"distance":434.7,"duration":26.1,"type":3,"instruction":"Turn sharp right onto Леніна вулиця","name":"Леніна вулиця","way_points":[46,53]},{"distance":0,"duration":0,"type":10,"instruction":"Arrive at Леніна вулиця, on the right","name":"","way_points":[53,53]}]}],"way_points":[0,53],"bbox":[30.642095,46.533388,30.654847,46.545869]}],"bbox":[30.642095,46.533388,30.654847,46.545869],"info":{"attribution":"openrouteservice.org | OpenStreetMap contributors","engine":{"version":"5.0.1","build_date":"2019-05-29T14:22:56Z"},"service":"routing","timestamp":1568139033134,"query":{"profile":"driving-car","preference":"fastest","coordinates":[[30.644173,46.545864],[30.654559,46.533388]],"language":"en","units":"m","geometry":true,"geometry_format":"encodedpolyline","instructions_format":"text","instructions":true,"elevation":false}}}
  </code></pre>
  
  <p>And now i'm using this to get the json data into a file and then to get only needed values to me.</p>
  
  <pre><code>result = json.loads(resp.text)
      for rows in result["routes"]:
          f_o.write(json.dumps(rows["summary"]["distance"])) # depending on how do you want the result
       print(result["routes"])
  </code></pre>
  
  <p>But it's giving me only the last one output value, so my question is how to put ALL output to a file and to get a distance from each request not for last one only.</p>