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

ids

Dictionary of user id(s) to query

Required

field

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

state

Nested parameter to determine the state of the user’s account

Optional

name

Name of the user within the user’s account

Optional

id

User ID number associated with their EDX account

Optional

apikey

API key associated with their EDX account

Optional

about

Text field about the EDX User found within the associated user profile

Optional

password

Password associated with the EDX user account

Optional

fullname

Full name associated with the EDX user account

Optional

email

Email address associated with the EDX user account

Optional

sysadmin

Boolean value stating if the associated EDX user is a system admin

Optional

user_reviewed

Boolean value stating if the associated EDX user has been reviewed

Optional

poc

Point of Contact (POC) associated with the EDX user account

Optional

poc_email

Point of Contact (POC) email address associated with the EDX user account

Optional

user_deactivated

Boolean to determine if the associated EDX user’s account has been deactivated

Optional

doe_affiliation

Boolean to determine if the associated EDX user’s account has a DOE affiliation

Optional

affiliation_type

DOE affiliation type of the associated EDX user. Dependent on doe_affiliation field value

Optional

organization

Organization associated with the EDX user account

Optional

occupation

Occupation associated with the EDX user account

Optional

phone_number

Phone number associated with the EDX user account

Optional

suspension_reason

Reason for suspension associated with a EDX user account

Optional

automated_suspension

Boolean value stating if the suspension associated with an EDX user account was automated

Optional

duid

DUID associated with the EDX user account

Optional

orcid

ORCID associated with the EDX user account

Optional



Example 1: Single User Metadata Stat Collection

Attention

  • Add the "User-Agent": parameter within the headers of the API request

  • Set "User-Agent": to the value "EDX-USER"

  • python
  • Successful Output
  • Failed Output
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 the headers of the API request

  • Set "User-Agent": to the value "EDX-USER"

  • python
  • Successful Output
  • Failed Output
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())