Collect Resource Entity ID Stats

API Endpoint: get_resource_entity_ids

Collects Resource Entity ID 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

query

Parameter used to list nested parameters within the dictionary in the parameter

Required

query_group

Parameter used to create a nested dictionary to query fields.

Required

start_date

Start date of the query date range

Required

end_date

End date of the query date range. Cannot be greater than the current date

Required

date_field

Field that is queried to match the value within the date range

Required

Note

The date_field parameter must be set to a valid column type
  • last_modified

  • cache_last_updated

  • webstore_last_updated

  • created



Parameter Definitions for query_group within User Table

Parameter Name

Description

Required Fields

id

User ID number associated with the resource

Optional

url

URL path to the resource

Optional

format

Format of the resource (Ex: PDF, JPG, MP3,CSV,PNG, etc.)

Optional

description

Description of the resource

Optional

position

Integer position of the resource within the submission

Optional

revision_id

ID of the resource revision of resource metadata

Optional

hash

Optional

state

State of the resource within a submission

Optional

operator

Filters the “WHERE” clause within the state field

Optional

extras

“Extras” column data stored within the resource table

Optional

name

Name of the resource

Optional

resource_type

The type of resource and how it was obtained (Ex: file.upload)

Optional

mimetype

Mime type of the resource (Ex: image)

Optional

mimetype_inner

Inner mime type of the resource (Ex: image/jpeg)

Optional

size

Big Integer data for the size of the resource

Optional

last_modified

Date of last modification to a resource

Optional

cache_url

Project number associated with a submission within a workspace

Optional

cache_last_updated

Date of the last update to the cache URL

Optional

webstore_url

Optional

webstore_last_updated

Date of the last update to the webstore URL

Optional

created

Date the resource was created

Optional

url_type

State of the resource (Ex: state : active)

Optional

package_id

ID of the resource revision of resource metadata

Optional

license_type

Type of the submission within the workspace

Optional

owner_org

Organization associated with the owner of the resource

Optional

folder_id

Folder ID associated with the resource

Optional

recycle_removed

Boolean to determine if the resource was removed via recycle bin

Optional

rating

Numeric rating the resource has been given

Optional

fgdc_metadata

Boolean to determine if the resource contains fgdc metadata

Optional

owner

Owner of the resource

Optional

key

Optional



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 main query 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 separated

    • The 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’}]

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 (=)



Example 1: Simplified Resource Entity 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 = {
  'query': [
      {
        'query_group': [{'<ENTER-PARAMETER-HERE>': '<ENTER-PARAMETER-VALUE-HERE>'}, {'<ENTER-PARAMETER-HERE>': '<ENTER-PARAMETER-VALUE-HERE>'}],
      }
    ], # Required. Must be a list of dictionaries.
    # Ex: WHERE (mimetype = 'image/svg+xml' OR mimetype = 'image/png') AND (owner ='admin' OR owner = 'tjones') AND state = 'active'
  '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_resource_entity_ids'
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_resource_entity_ids', 'success': True, 'result': {'resource_ids': ['00293651-8d82-4222-8ab1-450f4eb38385',
'0073d2b7-23ab-4247-8ef9-0e365894c8da', '008b9cf4-95b8-48d9-8952-b17f2946e4af', '00b0d2f0-8ed4-4858-a491-326512a8316d', '00b4b435-5adb-4d3f-a071-02ba21b1df52',
'0110dee3-5f72-4a99-af64-1bf85617f97a', '013a6f0d-7fd3-421b-be51-acb25a76fc14', '01a3e875-39bd-47d2-b073-6a67c1d3d2dc', '01d19480-8eb6-4cc8-9d56-cfd1cfaf522d',
'01d882a1-a59e-4a76-b90c-e3e08b2d76f2', '01fe6866-9c46-4221-babd-bf445e2f888d', '0203017b-6aea-44d1-bbdf-f3832fc61f7f', '020d068a-2b41-4907-b7bc-6d83e3c9490f',
'021a4bf2-00eb-42b9-8ff7-694f4965f939', '027f1a03-fe2b-4f9b-9e92-27a826bcd87c', '028d4523-46cc-4ce8-9518-db7a01f474e6', '02a1423b-573a-49fc-a8dd-9db16fca1792',
'02a4efc5-d32a-4d25-a7aa-0df488ec3700', '02c21c59-2552-425a-8939-32c616df56c6', '02fdb08d-11ba-4727-8fa9-b5ccf0b9a2e9', '03333b8e-c04d-414a-976b-869dd5cc70ec',
'03451740-ed80-44d0-927f-fd71e97ecc51', '03558a2d-3667-4607-afef-f235596bd99e', '037d052b-5f4f-4b34-b7cd-bf894c77d4f2', '037ef7c4-2ce4-4479-8225-01a3bf1f91f5',
'03dfb197-683d-452a-990c-b1c4db7f1e0f', '0429f0ea-d62d-4923-8872-222f81ef4671', '044981f4-bff9-4fe0-8cd9-ffd1aa48d14d', '048769b2-27e1-4142-9d6f-be4f90110ede',
'049d0be2-040d-4a36-9ccc-1966a244c0af', '04cd097b-5540-4d2b-a275-a1367bf099e9', '0544dee4-a424-402d-a54f-03129eee2f70', '05a32ad0-3af2-4b49-a2f8-bc02b6ad43aa',
'06087a1b-82bd-4aea-ad60-a3de03fa8e57', '06185b00-0297-411c-9dce-0e7193786b56', '062a601c-3c39-4a22-bbd4-6856fb70aa2b', '063fb274-e853-412b-ae35-4ce71bd3faf5',
'0641525b-df14-4dd9-8ea4-8ddd4f559a08', '0649c2c9-ae7b-41c8-bf6a-3c882e191382', '06ae3191-6c47-434e-a191-6cd20a29ce7e', '06c071cd-5d13-4eba-b20a-3c103f89e4d2',
'06f44d77-4aee-4158-a12c-5e4c1a9a6cf0', '071a9296-996c-441e-957c-c13c90c94abf', '0786542e-eb9c-4c83-8ad6-4f9703b85705', '078e5596-ada1-4195-b8e3-81cce4cd3028',
'07b438b1-a5ba-407e-bc70-d71994d62497', '07c03036-668e-41cd-a3cd-ee5884a20e8d', '084f0190-b0ea-4f82-9af3-cb411dccbeaf', '088bd9f0-bf19-4efe-b2df-82bc78261633',
'089761d7-fa0a-4634-bbb3-432969adb1ef', '08d0f88b-09c6-4701-93c1-d146bb41dda9', '08e8bd8d-04ed-4c96-8f5f-bc837f18d4d8', '091302f6-3c0a-4c94-a23b-cbeda365f814',
'0917ffd2-4f95-42c7-a20e-b55648299ecc', '093a3412-9b19-4c49-8250-139129a0c02c', '093e7a1a-8542-47c1-b61b-d303ad960d29', '09545bd5-94f4-41ed-a98f-ed72d59fe633',
'099b128a-196b-4e16-98ce-36227f2232ef', '09d13b34-f2c9-4dd0-9a58-e20ad7a19306', '09e8f799-57f5-45a7-ae52-918fb7e31359', '0a0b914b-10bb-485b-9119-731f9c0fd13f',
'0a13a750-ed8f-409b-a063-546d52f71ed2', '0a209e1f-b789-4fab-8ece-38d68478cccf', '0a49b694-454e-412e-8327-30090fcbac43', '0a710533-5bb1-4786-8786-1a39bcf1ffdf',
'0ac4049d-e61d-4449-9d09-7e456f6ab19a', '0ae4b2ab-13c8-4c55-9022-d8874b127721', '0ae8562f-7712-47ed-a6a6-9c5c9c4648cc', '0af76c7b-be00-4010-b76a-a8a03671a12e',
'0b057d22-817b-4abe-a1a5-1d3127138201', '0b186255-9912-4a92-b962-68520a5b0404', '0b19e367-cdc1-47c0-9782-36c6d5dd4946', '0b1fbb74-4acc-426c-b393-66da5bcc06bb']}}
{'help': '/api/3/action/help_show?name=get_resource_entity_ids', 'error': {'date_field': ['Please enter correct value.'], '__type': 'Validation Error'},
'success': False}


Example 2: Advanced Resource(s) Entity Stat Collection with Multiple Query Parameters

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 = {
  'query': [
      {
        'query_group': [{'<ENTER-PARAMETER-HERE>': '<ENTER-PARAMETER-VALUE-HERE>'}, {'<ENTER-PARAMETER-HERE>': '<ENTER-PARAMETER-VALUE-HERE>'}],
      },
      #AND
      {
        'query_group': [{'<ENTER-PARAMETER-HERE>': '<ENTER-PARAMETER-VALUE-HERE>'}, {'<ENTER-PARAMETER-HERE>': '<ENTER-PARAMETER-VALUE-HERE>'}]
      },
      #AND
      {
        'query_group': [{'<ENTER-PARAMETER-HERE>': '<ENTER-PARAMETER-VALUE-HERE>'}]
      }
    ], # Required. Must be a list of dictionaries.
    # Ex: WHERE (mimetype = 'image/svg+xml' OR mimetype = 'image/png') AND (owner ='admin' OR owner = 'tjones') AND state = 'active'
  '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_resource_entity_ids'
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_resource_entity_ids', 'success': True, 'result': {'resource_ids': ['00293651-8d82-4222-8ab1-450f4eb38385',
'0073d2b7-23ab-4247-8ef9-0e365894c8da', '008b9cf4-95b8-48d9-8952-b17f2946e4af', '00b0d2f0-8ed4-4858-a491-326512a8316d', '00b4b435-5adb-4d3f-a071-02ba21b1df52',
'0110dee3-5f72-4a99-af64-1bf85617f97a', '013a6f0d-7fd3-421b-be51-acb25a76fc14', '01a3e875-39bd-47d2-b073-6a67c1d3d2dc', '01d19480-8eb6-4cc8-9d56-cfd1cfaf522d',
'01d882a1-a59e-4a76-b90c-e3e08b2d76f2', '01fe6866-9c46-4221-babd-bf445e2f888d', '0203017b-6aea-44d1-bbdf-f3832fc61f7f', '020d068a-2b41-4907-b7bc-6d83e3c9490f',
'021a4bf2-00eb-42b9-8ff7-694f4965f939', '027f1a03-fe2b-4f9b-9e92-27a826bcd87c', '028d4523-46cc-4ce8-9518-db7a01f474e6', '02a1423b-573a-49fc-a8dd-9db16fca1792',
'02a4efc5-d32a-4d25-a7aa-0df488ec3700', '02c21c59-2552-425a-8939-32c616df56c6', '02fdb08d-11ba-4727-8fa9-b5ccf0b9a2e9', '03333b8e-c04d-414a-976b-869dd5cc70ec',
'03451740-ed80-44d0-927f-fd71e97ecc51', '03558a2d-3667-4607-afef-f235596bd99e', '037d052b-5f4f-4b34-b7cd-bf894c77d4f2', '037ef7c4-2ce4-4479-8225-01a3bf1f91f5',
'03dfb197-683d-452a-990c-b1c4db7f1e0f', '0429f0ea-d62d-4923-8872-222f81ef4671', '044981f4-bff9-4fe0-8cd9-ffd1aa48d14d', '048769b2-27e1-4142-9d6f-be4f90110ede',
'049d0be2-040d-4a36-9ccc-1966a244c0af', '04cd097b-5540-4d2b-a275-a1367bf099e9', '0544dee4-a424-402d-a54f-03129eee2f70', '05a32ad0-3af2-4b49-a2f8-bc02b6ad43aa',
'06087a1b-82bd-4aea-ad60-a3de03fa8e57', '06185b00-0297-411c-9dce-0e7193786b56', '062a601c-3c39-4a22-bbd4-6856fb70aa2b', '063fb274-e853-412b-ae35-4ce71bd3faf5',
'0641525b-df14-4dd9-8ea4-8ddd4f559a08', '0649c2c9-ae7b-41c8-bf6a-3c882e191382', '06ae3191-6c47-434e-a191-6cd20a29ce7e', '06c071cd-5d13-4eba-b20a-3c103f89e4d2',
'06f44d77-4aee-4158-a12c-5e4c1a9a6cf0', '071a9296-996c-441e-957c-c13c90c94abf', '0786542e-eb9c-4c83-8ad6-4f9703b85705', '078e5596-ada1-4195-b8e3-81cce4cd3028',
'07b438b1-a5ba-407e-bc70-d71994d62497', '07c03036-668e-41cd-a3cd-ee5884a20e8d', '084f0190-b0ea-4f82-9af3-cb411dccbeaf', '088bd9f0-bf19-4efe-b2df-82bc78261633',
'089761d7-fa0a-4634-bbb3-432969adb1ef', '08d0f88b-09c6-4701-93c1-d146bb41dda9', '08e8bd8d-04ed-4c96-8f5f-bc837f18d4d8', '091302f6-3c0a-4c94-a23b-cbeda365f814',
'0917ffd2-4f95-42c7-a20e-b55648299ecc', '093a3412-9b19-4c49-8250-139129a0c02c', '093e7a1a-8542-47c1-b61b-d303ad960d29', '09545bd5-94f4-41ed-a98f-ed72d59fe633',
'099b128a-196b-4e16-98ce-36227f2232ef', '09d13b34-f2c9-4dd0-9a58-e20ad7a19306', '09e8f799-57f5-45a7-ae52-918fb7e31359', '0a0b914b-10bb-485b-9119-731f9c0fd13f',
'0a13a750-ed8f-409b-a063-546d52f71ed2', '0a209e1f-b789-4fab-8ece-38d68478cccf', '0a49b694-454e-412e-8327-30090fcbac43', '0a710533-5bb1-4786-8786-1a39bcf1ffdf',
'0ac4049d-e61d-4449-9d09-7e456f6ab19a', '0ae4b2ab-13c8-4c55-9022-d8874b127721', '0ae8562f-7712-47ed-a6a6-9c5c9c4648cc', '0af76c7b-be00-4010-b76a-a8a03671a12e',
'0b057d22-817b-4abe-a1a5-1d3127138201', '0b186255-9912-4a92-b962-68520a5b0404', '0b19e367-cdc1-47c0-9782-36c6d5dd4946', '0b1fbb74-4acc-426c-b393-66da5bcc06bb']}}
{'help': '/api/3/action/help_show?name=get_resource_entity_ids', 'error': {'date_field': ['Please enter correct value.'], '__type': 'Validation Error'},
'success': False}