Last active
February 24, 2020 21:05
-
-
Save wkarney/e0e9aa626320d77b8cbaaaf046b21a09 to your computer and use it in GitHub Desktop.
[VA Facilities API Intro] Some examples for US VA Dept Facilities API #Python #API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import requests package | |
| import requests | |
| # API Key (request one at https://developer.va.gov/apply) | |
| apikey = 'your-api-key-here' | |
| # Typical request | |
| url = 'https://dev-api.va.gov/services/va_facilities/v0/facilities/' | |
| response = requests.get( | |
| url, | |
| params={'ids':['vha_688','nvc_100']}, # example IDs, see schema | |
| headers={"apiKey": apikey} | |
| ) | |
| response.json() | |
| # Bulk request - json | |
| bulkurl = 'https://dev-api.va.gov/services/va_facilities/v0/facilities/all' | |
| response = requests.get( | |
| bulkurl, | |
| params ={}, | |
| headers={"apiKey": apikey, 'Accept':'application/vnd.geo+json'} | |
| ) | |
| va_bulk_json = response.json() | |
| va_bulk_info = [] | |
| for i in range(len(va_bulk_json['features'])): | |
| va_bulk_info.append(va_bulk_json['features'][i]['properties']) | |
| va_bulk_info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment