Basic python3 module to query the Smithsonian's Enterprise Digital Asset Network (EDAN). Requires Python 3.11 or higher.
Install using pip:
pip install edanThen, load the module in Python:
import edanYou will need an ID and key, make the request in ServiceNow: https://edandoc.si.edu/more.html#auth
The function metadata_search() takes these arguments:
q= Search termsfqs= Python list of filter query parameters, for example:["online_media_type:\"Images\""]- Select records with images["data_source:\"Smithsonian+Gardens\""]- Limit results to a unit, SG in this case
edan_schema= Filter results by specifying one of the valid EDAN schemas or record types (list at https://edandoc.si.edu/more.html#schemas)AppID= Your AppIDAppKey= Your AppKeyrows= How many rows to return, max is 100, default is 10start= Which row to start the results, default is 0
Example of setting your credentials and using metadata_search():
#EDAN creds
AppID = "APP_ID"
AppKey = "verylong_key"
#Search for images of orchids from Smithsonian Gardens
results = edan.metadata_search(q="orchids", fqs=["online_media_type:\"Images\"", "data_source:\"Smithsonian+Gardens\""], AppID=AppID, AppKey=AppKey)
#Number of results available for this search
results['rowCount']
#To get the rows of results
results_rows = results['rows']To get the list of units:
unit_search = edan.metadata_search(edan_schema="si-unit", AppID=AppID, AppKey=AppKey, rows=100)
# Create a list with unit title, url in EDAN, and description
units = []
#iterate through the results and save to list
for i in range(len(unit_search['rows'])):
units.append([unit_search['rows'][i]['title'], unit_search['rows'][i]['url'], unit_search['rows'][i]['content']['description']])The function content_getcontent() takes these arguments (must provide either id or url):
id= ID of the itemurl= URL of the itemAppID= Your AppIDAppKey= Your AppKey
To see the details of an item:
import json
item = edan.content_getcontent(url=results['rows'][0]['url'], AppID=AppID, AppKey=AppKey)
print(json.dumps(item, sort_keys = True, indent = 4))The function metadata_suggestions() takes these arguments:
suggest= Search termsAppID= Your AppIDAppKey= Your AppKey