• Assign a asset to a collection partially implemented
  • Run a partial update of a asset TODO

List of asset endpoints

Lists the asset endpoints accessible to requesting user, for anonymous access a list of public data endpoints is returned.

GET /api/v2/assets/

Example

  curl -X GET https://[kpi]/api/v2/assets/

Search can be made with q parameter. Search filters can be returned with results by passing metadata=on to querystring.

Example

  curl -X GET https://[kpi]/api/v2/assets/?metadata=on
  {
      "count": 0
      "next": ...
      "previous": ...
      "results": []
      "metadata": {
          "languages": [],
          "countries": [],
          "sectors": [],
          "organizations": []
      }
  }

Look at README for more details.

Results can be sorted with ordering parameter. Allowed fields are:

  • asset_type
  • date_modified
  • name
  • owner__username
  • subscribers_count

Example

  curl -X GET https://[kpi]/api/v2/assets/?ordering=-name

Note: Collections can be displayed first with parameter collections_first

Example

  curl -X GET https://[kpi]/api/v2/assets/?collections_first=true&ordering=-name

Get a hash of all version_ids of assets. Useful to detect any changes in assets with only one call to API

GET /api/v2/assets/hash/

Example

  curl -X GET https://[kpi]/api/v2/assets/hash/

CRUD

  • uid - is the unique identifier of a specific asset

Retrieves current asset

GET /api/v2/assets/{uid}/

Example

  curl -X GET https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/

Creates or clones an asset.

POST /api/v2/assets/

Example

  curl -X POST https://[kpi]/api/v2/assets/

Payload to create a new asset

   {
      "name": {string},
      "settings": {
          "description": {string},
          "sector": {string},
          "country": {string},
          "share-metadata": {boolean}
      },
      "asset_type": {string}
   }

Payload to clone an asset

  {
      "clone_from": {string},
      "name": {string},
      "asset_type": {string}
  }

where asset_type must be one of these values:

  • block (can be cloned to block, question, survey, template)
  • question (can be cloned to question, survey, template)
  • survey (can be cloned to block, question, survey, template)
  • template (can be cloned to survey, template)

Settings are cloned only when type of assets are survey or template. In that case, share-metadata is not preserved.

When creating a new block or question asset, settings are not saved either.

Data

Retrieves data

GET /api/v2/assets/{uid}/data/

Example

  curl -X GET https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/data/

Deployment

Retrieves the existing deployment, if any.

GET /api/v2/assets/{uid}/deployment/

Example

  curl -X GET https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/deployment/

Creates a new deployment, but only if a deployment does not exist already.

POST /api/v2/assets/{uid}/deployment/

Example

  curl -X POST https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/deployment/

Updates the active field of the existing deployment.

PATCH /api/v2/assets/{uid}/deployment/

Example

  curl -X PATCH https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/deployment/

Overwrites the entire deployment, including the form contents, but does not change the deployment's identifier

PUT /api/v2/assets/{uid}/deployment/

Example

  curl -X PUT https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/deployment/

Reports

Returns the submission data for all deployments of a survey. This data is grouped by answers, and does not show the data for individual submissions. The endpoint will return a 404 NOT FOUND error if the asset is not deployed and will only return the data for the most recently deployed version.

GET /api/v2/assets/{uid}/reports/

Example

  curl -X GET https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/reports/

Data sharing

Control sharing of submission data from this project to other projects

PATCH /api/v2/assets/{uid}/

Example

  curl -X PATCH https://[kpi]/api/v2/assets/aSAvYreNzVEkrWg5Gdcvg/

Payload

   {
      "data_sharing": {
         "enabled": true,
         "fields": []"
      }
   }
  • fields: Optional. List of questions whose responses will be shared. If missing or empty, all responses will be shared. Questions must be identified by full group path separated by slashes, e.g. group/subgroup/question_name.

Response

  HTTP 200 Ok
   {
      ...
      "data_sharing": {
         "enabled": true,
         "fields": []"
      }
   }

CURRENT ENDPOINT

GET /api/v2/assets/arkE7MYLrvfz3K5827bo6K/
HTTP 200 OK
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "url": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/",
    "owner": "https://kobo.humanitarianresponse.info/api/v2/users/cpaor/",
    "owner__username": "cpaor",
    "parent": null,
    "settings": {},
    "asset_type": "collection",
    "date_created": "2017-04-26T13:14:37.358534Z",
    "summary": {},
    "date_modified": "2017-04-26T13:14:37.358584Z",
    "version_id": null,
    "version__content_hash": null,
    "version_count": 0,
    "has_deployment": false,
    "deployed_version_id": null,
    "deployed_versions": {
        "count": 0,
        "next": null,
        "previous": null,
        "results": []
    },
    "deployment__identifier": null,
    "deployment__links": {},
    "deployment__active": false,
    "deployment__data_download_links": {},
    "deployment__submission_count": 0,
    "report_styles": {},
    "report_custom": {},
    "map_styles": {},
    "map_custom": {},
    "content": {},
    "downloads": [
        {
            "format": "xls",
            "url": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K.xls"
        },
        {
            "format": "xml",
            "url": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K.xml"
        }
    ],
    "embeds": [
        {
            "format": "xls",
            "url": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/xls/"
        },
        {
            "format": "xform",
            "url": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/xform/"
        }
    ],
    "koboform_link": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/koboform/",
    "xform_link": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/xform/",
    "hooks_link": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/hooks/",
    "tag_string": "",
    "uid": "arkE7MYLrvfz3K5827bo6K",
    "kind": "asset",
    "xls_link": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/xls/",
    "name": "Child Protection Rapid Assessment (CPRA)",
    "assignable_permissions": [
        {
            "url": "https://kobo.humanitarianresponse.info/api/v2/permissions/view_asset/",
            "label": "View collection"
        },
        {
            "url": "https://kobo.humanitarianresponse.info/api/v2/permissions/change_asset/",
            "label": "Edit collection"
        },
        {
            "url": "https://kobo.humanitarianresponse.info/api/v2/permissions/discover_asset/",
            "label": "Discover collection"
        },
        {
            "url": "https://kobo.humanitarianresponse.info/api/v2/permissions/manage_asset/",
            "label": "Manage collection"
        }
    ],
    "permissions": [
        {
            "url": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/permission-assignments/pMwYNYcWSNNWuFKqrDCGyb/",
            "user": "https://kobo.humanitarianresponse.info/api/v2/users/AnonymousUser/",
            "permission": "https://kobo.humanitarianresponse.info/api/v2/permissions/discover_asset/",
            "label": "Discover collection"
        },
        {
            "url": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/permission-assignments/poYYbqC6nLJJJWcpEAt9F4/",
            "user": "https://kobo.humanitarianresponse.info/api/v2/users/AnonymousUser/",
            "permission": "https://kobo.humanitarianresponse.info/api/v2/permissions/view_asset/",
            "label": "View collection"
        },
        {
            "url": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/permission-assignments/pDQKAK8mJZRTA5SMR9Kbk6/",
            "user": "https://kobo.humanitarianresponse.info/api/v2/users/cpaor/",
            "permission": "https://kobo.humanitarianresponse.info/api/v2/permissions/change_asset/",
            "label": "Edit collection"
        },
        {
            "url": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/permission-assignments/p7AVudxeQ5F8b5j2CA3N2z/",
            "user": "https://kobo.humanitarianresponse.info/api/v2/users/cpaor/",
            "permission": "https://kobo.humanitarianresponse.info/api/v2/permissions/view_asset/",
            "label": "View collection"
        }
    ],
    "exports": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/exports/",
    "export_settings": [],
    "data": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/data/",
    "children": {
        "count": 3
    },
    "subscribers_count": 141,
    "status": "public-discoverable",
    "access_types": [
        "public"
    ],
    "data_sharing": {},
    "paired_data": "https://kobo.humanitarianresponse.info/api/v2/assets/arkE7MYLrvfz3K5827bo6K/paired-data/"
}