Created
October 11, 2021 07:20
-
-
Save frankstrater/130a5308f8df9e0493f5dbae72a9bd11 to your computer and use it in GitHub Desktop.
CKAN get datasets tests
This file contains 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
#!/usr/bin/python3 | |
import requests | |
import json | |
api_url = 'https://mediasuitedata.clariah.nl/api' | |
cacheFile = 'ckan_test.json' | |
response = requests.get(api_url + '/action/package_list') | |
listCKANCollections = response.json()['result'] | |
collectionData = {} | |
for collectionId in listCKANCollections: | |
response = requests.get(api_url + '/action/package_show?id=' + collectionId) | |
collectionData[collectionId] = response.json()['result'] | |
f = open(cacheFile, 'w+') | |
prettyData = json.dumps(collectionData, indent=4, sort_keys=True) | |
f.write(prettyData) | |
f.close() |
This file contains 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
#!/usr/bin/python3 | |
import requests | |
import json | |
api_url = 'https://mediasuitedata.clariah.nl/api' | |
cacheFile = 'ckan_test_new.json' | |
response = requests.get(api_url + '/action/current_package_list_with_resources?limit=1000') | |
listCKANCollections = response.json()['result'] | |
collectionData = {} | |
for collection in listCKANCollections: | |
collectionId = collection['name'] | |
collectionData[collectionId] = collection | |
f = open(cacheFile, 'w+') | |
prettyData = json.dumps(collectionData, indent=4, sort_keys=True) | |
f.write(prettyData) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment