{"id":18338724,"url":"https://github.com/tableflip/smartsurvey-client","last_synced_at":"2025-06-30T00:02:46.325Z","repository":{"id":57364052,"uuid":"84173451","full_name":"tableflip/smartsurvey-client","owner":"tableflip","description":"A simple JavaScript client to the SmartSurvey REST API","archived":false,"fork":false,"pushed_at":"2017-06-28T09:10:45.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-05T23:39:59.611Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tableflip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-07T08:20:40.000Z","updated_at":"2018-10-12T18:52:21.000Z","dependencies_parsed_at":"2022-09-16T22:50:45.004Z","dependency_job_id":null,"html_url":"https://github.com/tableflip/smartsurvey-client","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/tableflip/smartsurvey-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflip%2Fsmartsurvey-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflip%2Fsmartsurvey-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflip%2Fsmartsurvey-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflip%2Fsmartsurvey-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tableflip","download_url":"https://codeload.github.com/tableflip/smartsurvey-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflip%2Fsmartsurvey-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262685618,"owners_count":23348445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T20:14:58.494Z","updated_at":"2025-06-30T00:02:46.265Z","avatar_url":"https://github.com/tableflip.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# smartsurvey-client\n\nA simple JavaScript client to the SmartSurvey REST API.\n\n## Example\n\n```js\nvar SmartSurveyClient = require('smartsurvey-client')\nvar client = new SmartSurveyClient({ apiToken: 'TOKEN', apiTokenSecret: 'SECRET' })\n\nclient.getSurveys({ page: 1, pageSize: 25 }, function (err, result) {\n  if (err) throw err\n  console.log(result)\n  // result:\n  // {\n  //   data: [],\n  //   meta: {\n  //     pagination: { page: 1, pageSize: 25, returned: 25, total: 31 }\n  //   }\n  // }\n})\n```\n\n## Errors\n\nNon HTTP 200 responses to API calls will be returned as an error. If the API provides it, the error message will have a `status`, `message` and `code` property. If not, `status` will be set to the status code from the request and `message` will be a generic error message.\n\n```js\nRequestError {\n  status: 404,\n  message: \"Survey with id '123' could not be found.\",\n  code: 'not_found'\n}\n```\n\n## Callbacks\n\nCallback results to API methods have a standard structure. They are objects with a `data` property (the data returned by the API - an array or an object), a `meta` property (metadata included in the HTTP headers) and a raw `response` property.\n\n```js\nResult {\n  data: [...],\n  meta: {\n    pagination: { page: 1, pageSize: 25, returned: 25, total: 31 }\n    release: '1.1.0.29',\n    server: 'Web1'\n  },\n  response: {...}\n}\n```\n\n## Conventions\n\nRequest params are named as per the params documented in the SmartSurvey API docs, however they are renamed from `snake_case` to `camelCase`.\n\nAll requests take `apiToken` and `apiTokenSecret` params, but they can be optionally passed to the constructor where they will automatically be added to each request.\n\n## API\n\n**This module is work in progress**.\n\nThe following API calls have been implemented:\n\n### `getSurveys([options,] cb)`\n\nhttps://docs.smartsurvey.io/v1/reference#surveys\n\nFetch a page of surveys.\n\n* `options.page` - page to fetch (default 1)\n* `options.pageSize` - number of items per page (default 10)\n* `options.sortBy` - field(s) to sort by\n\n### `getSurvey(surveyId, [options,] cb)`\n\nhttps://docs.smartsurvey.io/v1/reference#get-a-survey\n\nFetch a single survey.\n\n* `options.detailed` - fetch more detailed survey data\n\n### `getResponses(surveyId, [options,] cb)`\n\nhttps://docs.smartsurvey.io/v1/reference#get-responses\n\nFetch a page of responses.\n\n* `options.completed` - 0=Partial, 1=Completed, 2=Both - Return completed responses or partial\n* `options.since` - return responses that completed no earlier than this date\n* `options.until` - return responses that completed no later than this date\n* `options.filterId` - enter the filter report ID you would like to use. Other filters will be ignored\n* `options.trackingLinkId` - filter by tracking link id\n* `options.uniqueId` - filter the unique (x) value\n* `options.includeLabels` - return text of page/question/choice labels, rather than indices only\n* `options.page` - page to fetch (default 1)\n* `options.pageSize` - number of items per page (default 10)\n* `options.sortBy` - field(s) to sort by\n\n### `getResponse(surveyId, responseId, [options,] cb)`\n\nhttps://docs.smartsurvey.io/v1/reference#get-a-response\n\nFetch a single response.\n\n### `getFolder(folderId, [options,] cb)`\n\nhttps://docs.smartsurvey.io/v1/reference#get-a-response\n\nFetch a details on a folder (a way that surveys are collected).\n\nhttps://docs.smartsurvey.io/v1/reference#surveyfoldersfolder_iddetailed\n\n\n## Utility\n\n### `getAll(get, [options,] cb)`\n\n* `get` - function that retrieves a page of content\n* `options.pageSize` - size of pages that are retrieved (default 10)\n* `options.onPage` - called when each page of results is retrieved\n\ne.g.\n\n```js\nvar SmartSurveyClient = require('smartsurvey-client')\nvar getAll = require('smartsurvey-client/get-all')\nvar client = new SmartSurveyClient({ apiToken: 'TOKEN', apiTokenSecret: 'SECRET' })\n\n// Retrieve a page of surveys\nfunction getPageOfSurveys (page, pageSize, cb) {\n  // Merge page and pageSize with your request options\n  client.getSurveys({ page: page, pageSize: pageSize }, cb)\n}\n\n// Optional callback for each page\nfunction onPage (result) {\n  console.log('Got page number', result.meta.pagination.page)\n}\n\n// Start fetch all the pages!\ngetAll(getPageOfSurveys, { pageSize: 10, onPage: onPage }, function (err, result) {\n  console.log(result.data) // All surveys\n})\n```\n\n----\n\nA [(╯°□°）╯︵TABLEFLIP](https://tableflip.io) side project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftableflip%2Fsmartsurvey-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftableflip%2Fsmartsurvey-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftableflip%2Fsmartsurvey-client/lists"}