Collect User Metadata Stats
Important
An API Key is required for ALL private workspace activities
The API Key name component can be added to your header using any of the following ways, “X-CKAN-API-Key”, “EDX-API-Key”, or “Authorization”.
Note
Only System Admins can user the stats collection APIs
Parameter Definitions
Parameter Name |
Description |
Required Fields |
---|---|---|
|
Dictionary of user id(s) to query |
Required |
|
Dictionary listing the table columns the query will search against |
Required |
Parameter Definitions for User Table Columns Used in the fields
Parameter
Parameter Name |
Description |
Required Fields |
---|---|---|
|
Nested parameter to determine the state of the user’s account |
Optional |
|
Name of the user within the user’s account |
Optional |
|
User ID number associated with their EDX account |
Optional |
|
API key associated with their EDX account |
Optional |
|
Text field about the EDX User found within the associated user profile |
Optional |
|
Password associated with the EDX user account |
Optional |
|
Full name associated with the EDX user account |
Optional |
|
Email address associated with the EDX user account |
Optional |
|
Boolean value stating if the associated EDX user is a system admin |
Optional |
|
Boolean value stating if the associated EDX user has been reviewed |
Optional |
|
Point of Contact (POC) associated with the EDX user account |
Optional |
|
Point of Contact (POC) email address associated with the EDX user account |
Optional |
|
Boolean to determine if the associated EDX user’s account has been deactivated |
Optional |
|
Boolean to determine if the associated EDX user’s account has a DOE affiliation |
Optional |
|
DOE affiliation type of the associated EDX user. Dependent on |
Optional |
|
Organization associated with the EDX user account |
Optional |
|
Occupation associated with the EDX user account |
Optional |
|
Phone number associated with the EDX user account |
Optional |
|
Reason for suspension associated with a EDX user account |
Optional |
|
Boolean value stating if the suspension associated with an EDX user account was automated |
Optional |
|
DUID associated with the EDX user account |
Optional |
|
ORCID associated with the EDX user account |
Optional |
Example 1: Single User Metadata Stat Collection
Attention
Add the
"User-Agent":
parameter within theheaders
of the API requestSet
"User-Agent":
to the value"EDX-USER"
import requests
headers = {
"EDX-API-Key": '<YOUR_EDX_API_KEY>',
"User-Agent": 'EDX-USER',
'Content-Type': 'application/json',
'Accept':'application/json'
}
data = {
'ids': ['<ENTER-USER-ID-HERE>'], # Required.
'fields': ['<ENTER-PARAMETER-HERE>'] #Required
}
url = 'https://edx.netl.doe.gov/api/3/action/user_metadata'
r = requests.post(
url, # URL to API endpoint
headers=headers, # Headers dictionary
json=data, # Dictionary of data params
)
r_json = r.json()
print (r.json())
Example 2 : Multi-User Metadata Stat Collection
Attention
Add the
"User-Agent":
parameter within theheaders
of the API requestSet
"User-Agent":
to the value"EDX-USER"
import requests
headers = {
"EDX-API-Key": '<YOUR_EDX_API_KEY>',
"User-Agent": 'EDX-USER',
'Content-Type': 'application/json',
'Accept':'application/json'
}
data = {
'ids': ['<ENTER-USER-ID-HERE>', '<ENTER-USER-ID-HERE>', '<ENTER-USER-ID-HERE>'], # Required.
'fields': ['<ENTER-PARAMETER-HERE>', '<ENTER-PARAMETER-HERE>', '<ENTER-PARAMETER-HERE>'] #Required
}
url = 'https://edx.netl.doe.gov/api/3/action/user_metadata'
r = requests.post(
url, # URL to API endpoint
headers=headers, # Headers dictionary
json=data, # Dictionary of data params
)
r_json = r.json()
print (r.json())