Skip to main content

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

Metadata

Release files for taskanalytics-data-wrapper 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for taskanalytics-data-wrapper 0.3.0
File Size Uploaded
taskanalytics_data_wrapper-0.3.0.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for taskanalytics-data-wrapper 0.3.0
File Interpreter ABI Platform
taskanalytics_data_wrapper-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.5 kB

Release files / taskanalytics_data_wrapper-0.3.0.tar.gz

Download URL taskanalytics_data_wrapper-0.3.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2ca68e14f642ea1e669dc0a5d375b0034a1d4055d84be0ff85ca3f22863ce6b4
BLAKE2b-256 checksum
How to use checksums
8367b18e1d1a1bebaa25be84bb7efdec6af24d860efa4dd53475f99b70b6bddf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.3

Release files / taskanalytics_data_wrapper-0.3.0-py3-none-any.whl

Download URL taskanalytics_data_wrapper-0.3.0-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa8464682c46bff6b0cc44e195dfed4287d10ebdcc7bc43944aae8c2e069a393
BLAKE2b-256 checksum
How to use checksums
726b2c96fc0f44b3496cb25be00dbeff32a57285fb86bcea4bce09b4af582f06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.3

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page