Survey data

List of submissions for a specific asset

By default, JSON format is used, but XML and GeoJSON are also available:

curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/

Pagination

Two parameters can be used to control pagination.

  • start: Index (zero-based) from which the results start
  • limit: Number of results per page <span class='label label-warning'>Maximum results per page cannot exceed 1000, unless changed by server configuration</span>
curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/?start=0&limit=10

Query submitted data

Provides a list of submitted data for a specific form. Use query parameter to apply form data specific, see <a href="http://docs.mongodb.org/manual/reference/operator/query/">http://docs.mongodb.org/manual/reference/operator/query/</a>.

For more details see <a href="https://github.com/SEL-Columbia/formhub/wiki/Formhub-Access-Points-(API)#api-parameters">API Parameters</a>.

curl -X GET https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/?query={"__version__": "vWvkKzNE8xCtfApJvabfjG"}
curl https://kf.kobotoolbox.org/api/v2/assets/{uid}/data/?query={"_submission_time": {"$gt": "2019-09-01T01:02:03"}}

About the GeoJSON format

Requesting the geojson format returns a FeatureCollection where each submission is a Feature. If your form has multiple geographic questions, use the geo_question_name query parameter to determine which question's responses populate the geometry for each Feature; otherwise, the first geographic question is used. All question/response pairs are included in the properties of each Feature, but repeating groups are omitted.

Question types are mapped to GeoJSON geometry types as follows:

  • geopoint to Point;
  • geotrace to LineString;
  • geoshape to Polygon.

⚠️ Note: DRF-Spectacular Limitation

Due to limitations in DRF-Spectacular, the ACCEPT headers do not sync properly with the request. As a result, all responses will default to application/json, regardless of the specified format.

This means that while alternative formats (like XML) are technically supported and will work via command-line tools (e.g., curl), they will not work when trying out the endpoint directly from the documentation page.

We’ve still included the header to show supported formats, but keep in mind: Only application/json will be used in the docs UI.

get/api/v2/assets/{uid_asset}/data/

Request

  • The document declares no server URL.
  • Auth: one of:
    • HTTP basic
    • API key in header Authorization

Path parameters

idinteger required

ID of the data (when applicable)

uid_assetstring required

UID of the parent asset

Query parameters

fieldsstring

Include only given list of fields in results

format'geojson' | 'json' | 'xml'
limitinteger

Number of results to return per page. Use with start.

offsetinteger

Deprecated alias of start.

querystring

Filter the results with search query

sortstring

Sort the results by a field, e.g. {"_id":-1}

startinteger

The initial index from which to return the results. Use with limit.

Response

countinteger required
nextstring uri nullable
previousstring uri nullable

Example response

{
  "count": 123,
  "next": "https://kf.kobotoolbox.org/api-endpoint/?start=400&limit=100",
  "previous": "https://kf.kobotoolbox.org/api-endpoint/?start=200&limit=100",
  "results": [
    {
      "_attachments": [
        {
          "download_url": "https://kf.kobotoolbox.org/api/v2/assets/aTPPUDScaFZkvBzd8FyK4Q/data/18/attachments/1",
          "download_large_url": "https://kf.kobotoolbox.org/api/v2/assets/aTPPUDScaFZkvBzd8FyK4Q/data/18/attachments/attWNZNwhXK6HDYVkZJSn9jy/large/",
          "download_medium_url": "https://kf.kobotoolbox.org/api/v2/assets/aTPPUDScaFZkvBzd8FyK4Q/data/18/attachments/attWNZNwhXK6HDYVkZJSn9jy/medium/",
          "download_small_url": "https://kf.kobotoolbox.org/api/v2/assets/aTPPUDScaFZkvBzd8FyK4Q/data/18/attachments/attWNZNwhXK6HDYVkZJSn9jy/small/",
          "mimetype": "image/png"
        }
      ]
    }
  ]
}

Changes

    • info

      added the optional property /// to the response with the status (media type: application/json)

    • info

      added the optional property /// to the response with the status (media type: text/xml)

    • breaking

      response property results/items/_supplementalDetails list-of-types was widened by adding types null to media type application/json of response 200