title: Search and download files via API with Python
body: <p>got a question on downloading files via API. I got this code, which searches the file and returns the info on it.</p>
  <pre><code>import requests
  import pprint
  
  
  token = requests.post(&quot;https://usda.library.cornell.edu/user_token&quot;,
                        json={'auth':
                                 {'email': 'my_mail',
                                  'password':'my_pass'}})
  
  bearer = token.json()['jwt']
  
  data = requests.get('https://usda.library.cornell.edu/api/v1/publication/findById/ws859f67m',
                      headers={'Authorization': 'Bearer '+token.json()['jwt']})
  
  
  pprint.pprint(data.json())
  </code></pre>
  <p>But how can I download the file itself with Python? Can you, please, advice the best way or some tutorials on this topic?</p>
  <p>The output for the code above will be:</p>
  <pre><code>[{'agency': ['Agricultural Marketing Service',
               'Livestock, Poultry and Seed Program'],
    'agency_acronym': ['AMS'],
    'contact_email': ['Websupport.lpgmn@ams.usda.gov'],
    'contact_organization': ['Livestock, Poultry, and Grain Market News'],
    'description': ['This report contains the number of metric tons of grains '
                    'inspected and/or weighed for export from January to '
                    'December by region and country of destination. '],
    'division_acronym': ['AMS-LPS'],
    'frequency': ['Not Specified'],
    'id': 'ws859f67m',
    'identifier': ['WA_GR153'],
    'keywords': ['exports', 'weight', 'barley', 'wheat', 'soybeans', 'corn'],
    'resource_type': ['Report'],
    'status': ['Active'],
    'subject': ['Crops and Crop Products:Grains and Oilseeds'],
    'subscribable': 'Yes',
    'title': ['Annual Grains Inspected and/or Wtd for Export by Region and COD']}]
  </code></pre>