Skip to main content

Surveys - NPS Data

Enterprise

This endpoint is part of Countly Enterprise. To get access, contact sales or compare versions. Existing customers can reach the support portal with questions.

Endpoint

/o/surveys/nps/data

Overview

Returns NPS response table data and NPS-specific method branches.

Authentication

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions

  • Surveys: Read permission.

Request Parameters

ParameterTypeRequiredDescription
api_keyStringYes (or auth_token)API key authentication
auth_tokenStringYes (or api_key)Auth token authentication
app_idStringYesApp ID
widget_idStringNoWidget ID (required for meta and graph)
methodStringNograph, meta or omitted for table data
periodStringRequired for meta/graphPeriod filter
periodOffsetNumberNoOffset in minutes
uidStringNoUser filter
sSearchStringNoSearch filter
iDisplayStartNumberNoOffset
iDisplayLengthNumberNoPage size

Examples

/o/surveys/nps/data?api_key=YOUR_API_KEY&app_id=YOUR_APP_ID&widget_id=67b9db56f67aab0012cd8899&method=meta&period=30days
/o/surveys/nps/data?api_key=YOUR_API_KEY&app_id=YOUR_APP_ID&widget_id=67b9db56f67aab0012cd8899&method=graph&period=30days

Response

Success Response

{
"sEcho": "1",
"iTotalRecords": 120,
"iTotalDisplayRecords": 20,
"aaData": [
{
"ts": 1739557500,
"uid": "u_102",
"rating": 9,
"comment": "Great product"
}
]
}

Response Fields

FieldTypeDescription
sEchoStringEcho value for table requests
iTotalRecordsNumberTotal records count
iTotalDisplayRecordsNumberDisplayed records count
aaDataArrayResponse rows

Error Responses

  • HTTP 400 - Missing period for meta:
{
"result": "Missing request parameter: period"
}
  • HTTP 400 - Invalid period:
{
"result": "Bad request parameter: period"
}

Behavior

  • method=graph returns NPS graph data from the aggregate collection (nps{app_id}) using widget_id as the segmentation value.
  • method=meta requires period, validates Countly period syntax, and returns metadata aggregates from surveyQueries.fetchNpsMeta.
  • Without method, returns a DataTables response table from Drill event [CLY]_nps.
  • Table mode supports filters for widget_id, uid, rating, platform, platform_version, version, source, period, and device_id.
  • source=default filters responses without sg.journeyId; any other source value matches sg.journeyId.
  • Table rows project rating, comment, platform, platform version, app version, widget id, timestamp, uid, did, and user name.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly_drill.drill_eventsDrill event recordsStores granular event rows queried or updated by this endpoint.