Skip to main content

a wrapper for using Task Analytics APIs and downloading survey responses

Project description

Task Analytics Data Wrapper

Ruff

This is a wrapper for Task Analytics APIs. You can use it to download survey responses and metadata for each survey.

Install with

pip install taskanalytics-data-wrapper

or

uv add taskanalytics-data-wrapper

Supported APIs

Log in to Task Analytics

import taskanalytics_data_wrapper.taskanalytics_api as task

You can log in with email and password

status = log_in_taskanalytics(username=email, password=password)  
status.status_code

Download Survey responses

You can download survey responses for a Top Task survey using the survey ID, email, password and setting a path for where to store the file.

import taskanalytics_data_wrapper.taskanalytics_api as task

get_survey = task.download_survey(
    username=email, password=password, survey_id="03324", filename="data/survey.csv"
)
get_survey.status_code

Download Survey metadata

You can download the survey metadata which includes the questions and response options for each survey using the survey ID, email and password.

survey_metadata = task.get_survey_metadata(
    username=email,
    password=password,
    survey_id="03419",
    filename_path="data/metadata_survey.json",
)
survey_metadata.status_code

The object can be easily inspected transformed into a dictionary for analysis

survey_metadata.text # survey metadata
our_dict = survey_metadata.json() # convert string to dict and store as a variable

Download Discovery survey responses

You can download responses from open ended task discovery surveys as well

get_openended_survey = task.download_discovery_survey(
    username=email,
    password=password,
    organization_id=organization,
    survey_id="03230",
    filename_path="data/open_ended_survey.json",
)

See how to turn this into csv in the code example below by expanding

Expandable example
data = get_openended_survey.json()

#create a new dict from our subset of data
def flatten_openended_dict(data):
    """ """
    respondent = []
    completion = []
    category = []
    discovery = []
    comment = []
    for i in data:
        respondent.append(i["id"])
        completion.append(i["completion"])
        category.append(i["category"])
        discovery.append(i["answers"]["discovery"])
        try:
            comment.append(i["answers"]["comment"])
        except:
            comment.append("")
    newlist = [
        {
            "id": respondent,
            "completion": completion,
            "category": category,
            "discovery": discovery,
            "comment": comment,
        }
        for respondent, completion, category, discovery, comment in zip(
            respondent, completion, category, discovery, comment
        )
    ]
    return newlist


newlist = flatten_openended_dict(data["responses"])

# write open ended survey to csv with your preferred encoding and delimiter
keys = newlist[0].keys()

with open("data/open_survey.csv", "w", encoding="utf-8-sig", newline="") as output_file:
    writer = csv.DictWriter(output_file, fieldnames=keys, delimiter=";")
    writer.writeheader()
    writer.writerows(newlist)

Download organization metadata

Get all the organization account metadata including the list of all survey IDs

# Get all organization settings including surveys from task analytics
get_organization = task.get_organization_metadata(
    username=email,
    password=password,
    organization_id=organization,
    filename_path="data/organization.json",
)
get_organization.status_code 

# %%
get_organization.json()  # read response as json

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taskanalytics_data_wrapper-0.2.9.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

taskanalytics_data_wrapper-0.2.9-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file taskanalytics_data_wrapper-0.2.9.tar.gz.

File metadata

File hashes

Hashes for taskanalytics_data_wrapper-0.2.9.tar.gz
Algorithm Hash digest
SHA256 ca526775e343b57371a727d16a45f6166d1658a90e906b1bec8b3a880bf01447
MD5 ddcf8a78345221af0cd82ba009f350df
BLAKE2b-256 f4d905f5e4ca3bc2f3590d24da23ca8922c12729bc1e694eff20c64a493ddc8e

See more details on using hashes here.

File details

Details for the file taskanalytics_data_wrapper-0.2.9-py3-none-any.whl.

File metadata

File hashes

Hashes for taskanalytics_data_wrapper-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 18e25cce8fe6da3f7fbfba0e83192c5f33d6e7a4e7de21cfac81e64f93c7d062
MD5 f81e0349b47ccfacd0574dad61024b56
BLAKE2b-256 bc69042145546291a7430d223a6ed1bd8840f463d6473b5dc88b1b8b337d738f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page