Skip to content

Instantly share code, notes, and snippets.

@gordonje
Created December 18, 2023 16:27
Show Gist options
  • Save gordonje/0fff0811cd18a5f761d5165e18a5439a to your computer and use it in GitHub Desktop.
Save gordonje/0fff0811cd18a5f761d5165e18a5439a to your computer and use it in GitHub Desktop.
Get VAN Survey Question Response in JSONL format

VAN Survey Question Responses

This script will:

  • Send an authenticated request to the /surveyQuestions endpoint of VAN's API
  • Unnest responses from each item
  • Output to a local file in newline delimited JSON (aka JSONL, which is...not?...the same as NDJSON...)

Dependencies

This script requires the following programs to be installed and available on your current PATH:

  • cURL for sending an authenticated GET request
  • jq for manipulating the JSON response

Environment Variables

All requests sent to VAN's API must be authenticated.

  • VAN_APP_NAME should be set to your VAN "Application Name" (e.g., XXXX.######.###)
  • VAN_GUID should be set to you VAN API Key (e.g., #xxx##x#-###x-x###-x##x-###xxxx##x#x)
.items[] |
{
surveyQuestionId,
type,
cycle,
name,
mediumName,
shortName,
scriptQuestion
} +
(
.responses[] |
{
surveyResponseId,
name,
mediumName,
shortName
}
)
curl \
--header 'accept: application/json' \
--user "$VAN_APP_NAME:$VAN_GUID|0" \
--basic \
'https://api.securevan.com/v4/surveyQuestions?statuses=Active%2CArchived%2CInactive&$top=200' \
| jq \
--compact-output \
--from-file ./filters.jq \
> survey-questions.jsonl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment