Collect Group Count Stats
API Endpoint: get_group_count
Collects User Count 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 |
---|---|---|
|
Name of the group |
Optional |
|
User ID number associated with EDX group |
Optional |
|
Title of submission found within the group |
Optional |
|
Description of the submission found within the group |
Optional |
|
Date the group was created |
Optional |
|
State of the group |
Optional |
|
Filters the “WHERE” clause within the |
Optional |
|
ID of the revision of a submission within the group |
Optional |
|
Type of the submission within the group |
Optional |
|
Approval status of a submission within the group |
Optional |
|
URL of an image resource found within the group |
Optional |
|
ID of the owner for a submission in a group |
Optional |
|
String text name of the landing page for a group |
Optional |
|
Boolean to determine if the submission is group reviewed |
Optional |
|
Boolean to determine if the group has open access |
Optional |
|
Boolean to determine if the group is only available to access by NETL-only users |
Optional |
|
Date of last modification to a submission within the group |
Optional |
|
Project number associated with a submission within a group |
Optional |
Important
The landing_page
parameter value should be set to dashboard
if using this field, unless another page has been specified as the landing page
Note
- The
date_field
parameter must be set to a valid column type last_modified
created
Important
The operator
parameter must come after the column name for the parameter in the query_group
Note
- Values for the
operator
parameter are as follows: less than (<)
greater than (>)
less than equal to (<=)
greater than equal to (>=)
like
not equals (!)
equals (=)
By deafult the operator parameter to
equals (=)
Note
Within the query
parameter, the values must be set up as a list of dictionaries nested within the main query
’s main dictionary
Important
- Within the
query
parameter dictionary: Multiple requests for
query_group
can be called within the mainquery
dictionary- Within each
query_group
request, the value will be placed within its own dictionary Within the
query_group
request, values stored within the nested dictionary will be comma separatedThe comma separation works as an “OR” condition to check the value of the first field “OR” the value of the second field
Ex: ‘query_group’: [{‘state’: ‘active’}, {‘state’: ‘pending’}]
- Within each
Example 1: Simplified Group Count 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>',
# "EDX-API-Key": '<YOUR_EDX_API_KEY>',
"User-Agent": 'EDX-USER',
'Content-Type': 'application/json',
'Accept':'application/json'
}
data = {
'query': [{'query_group': [{'<ENTER-PARAMETER-HERE>': '<ENTER-PARAMETER-VALUE-HERE>'}]}], # Required.
'start_date': '<START-DATE>', # Required. Date must be in date format (E.g. YYYY-MM-DD) and not greater than current date.
# start_date cannot be greater than end_date
'end_date': '<END-DATE>', # Required. Date must be in date format (E.g. YYYY-MM-DD) and not greater than current date.
# end_date cannot be less than start_date
'date_field': '<ENTER-DATE-FIELD-PARAMETER-HERE>'
}
url = 'https://edx.netl.doe.gov/api/3/action/get_group_count'
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=get_group_count', 'success': True, 'result': {'count': 1}}
{'help': '/api/3/action/help_show?name=get_group_count', 'error': {'query': 'Field "test" not recognized in group table.', '__type': 'Validation Error'},
'success': False}
Example 2: Advanced Group Count 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>',
# "EDX-API-Key": '<YOUR_EDX_API_KEY>',
"User-Agent": 'EDX-USER',
'Content-Type': 'application/json',
'Accept':'application/json'
}
data = {
'query': [{'query_group': [{'<ENTER-PARAMETER-HERE>': '<ENTER-PARAMETER-VALUE-HERE>'}]}, {'query_group': [{'<ENTER-PARAMETER-HERE>': '<ENTER-PARAMETER-VALUE-HERE>'}]}], # Required.
'start_date': '<START-DATE>', # Required. Date must be in date format (E.g. YYYY-MM-DD) and not greater than current date.
# start_date cannot be greater than end_date
'end_date': '<END-DATE>', # Required. Date must be in date format (E.g. YYYY-MM-DD) and not greater than current date.
# end_date cannot be less than start_date
'date_field': '<ENTER-DATE-FIELD-PARAMETER-HERE>'
}
url = 'https://edx.netl.doe.gov/api/3/action/get_group_count'
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=get_group_count', 'success': True, 'result': {'count': 1}}
{'help': '/api/3/action/help_show?name=get_group_count', 'error': {'query': 'Field "test" not recognized in group table.', '__type': 'Validation Error'},
'success': False}