Collect Workspace 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

name

Name of the user within the user’s account

Optional

id

User ID number associated with their EDX account

Optional

title

title of submission found within the workspace

Optional

description

Description of the submission found within the workspace

Optional

created

Date the workspace was created

Optional

state

State of the workspace

Optional

revision_id

ID of the resource revision of a submission within the workspace

Optional

type

Type of the submission within the workspace

Optional

approval_status

Approval status of a submission within the workspace

Optional

image_url

URL of an image resource found within the workspace

Optional

owner_id

ID of the owner for the workspace

Optional

landing_page

String text name of the landing page for a workspace

Optional

group_reviewed

Boolean to determine if the workspace submission is group reviewed

Optional

open_access

Boolean to determine if the workspace has open access

Optional

netl_only

Boolean to determine if the workspace is only available to access by NETL-only users

Optional

last_modified

Date of last modification to a submission within the workspace

Optional

project_number

Project number associated with a submission within a workspace

Optional

roster

A list of user IDs in the workspace

Optional

Note

When using the * within the fields parameter, it will include all fields



Example 1: Single Workspace 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
  • Roster Output
import requests

headers = {
  "EDX-API-Key": '<YOUR_EDX_API_KEY>',
  "User-Agent": 'EDX-USER',
  'Content-Type': 'application/json',
  'Accept':'application/json'
}

data = {
  'ids': ['<WORKSPACE-ID-HERE>'], # Required.
  'fields': ['<ENTER-PARAMETER-HERE>'] #Required
}

url = 'https://edx.netl.doe.gov/api/3/action/workspace_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())


{
  "help":"/api/3/action/help_show?name=workspace_metadata",
  "success":true,
  "result":{
      "total_count":3,
      "metadata":[
        {
            "workspace_id":"0aa9f4e9-f4bf-470d-aeea-8affcf7c8b9d",
            "roster":[
              "35de479c-e02c-4d60-8f3d-8234caeee02e"
            ]
        },
        {
            "workspace_id":"657a84e6-3950-4af8-aa2e-9c6d32794918",
            "roster":[
              "b1b62511-8e97-4474-a58d-a53c10dec4ff",
              "938907a2-c261-46f9-b154-ea070dd8887b"
            ]
        },
        {
            "workspace_id":"da435e4c-23fd-43a4-91cc-d08a1bce033c",
            "roster":[
              "89ba43f7-d490-48cb-9719-72c4c88344a3"
            ]
        }
      ]


Example 2 : Multi-Workspace 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': ['<WORKSPACE-ID-HERE>', '<WORKSPACE-ID-HERE>', '<WORKSPACE-ID-HERE>'], # Required.
  'fields': ['<ENTER-PARAMETER-HERE>', '<ENTER-PARAMETER-HERE>', '<ENTER-PARAMETER-HERE>'] #Required
}

url = 'https://edx.netl.doe.gov/api/3/action/workspace_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())