Skip to main content

siamang

Research-as-code framework for sociological surveys.
Define variables, questionnaires, and logic in pure Python — then deploy, collect, and analyze in a single pipeline.

Quick start · Full pipeline example · API Reference


pip install siamang
siamang validate my_survey.py
siamang preview  my_survey.py        # local preview
siamang deploy   my_survey.py --backend supabase --frontend vercel

What it does

siamang turns a survey into a running web application from a single Python script:

my_survey.py          ← you write this
    │
    ├─ siamang validate   → catches errors before deployment
    ├─ siamang preview    → local frontend (hot-reload)
    ├─ siamang deploy     → Vercel + Supabase (cloud deployment)
    └─ survey.simulate()  → synthetic data for testing

No GUI builders. No drag-and-drop. No lock-in. Your survey is a Python module — version-control it, test it, reuse it.


Siamang Studio

Prefer to build surveys and analyze their answers without writing code? Siamang Studio is the hosted survey platform built on this engine, with the GUI the engine leaves out: a visual questionnaire builder, publishing and fieldwork monitoring, a response database with exports, a node-based analysis canvas, live dashboards and reports. Every questionnaire and analysis flow you build in Studio is also Python, and any version of a project downloads as a research bundle that reproduces its tables, charts and report on this engine, outside Studio.

→ Try the open beta https://studio.siamang.org


Quick start

from siamang.core import (
    Variable, SingleChoice, LikertScale, Page, Questionnaire,
)

# Define variables with full metadata
satisfaction = Variable(
    "satisfaction", scale="ordinal",
    label="Overall satisfaction",
    labels={1: "Very dissatisfied", 2: "Dissatisfied",
            3: "Neutral", 4: "Satisfied", 5: "Very satisfied"},
)
remote_freq = Variable(
    "remote_freq", scale="ordinal",
    label="Remote work frequency",
    labels={1: "Never", 2: "1-2 days/week",
            3: "3-4 days/week", 4: "Fully remote"},
)

# Build questions
q_sat = LikertScale("How satisfied are you with your current role?",
                    var=satisfaction, points=5, required=True)
q_remote = SingleChoice("How often do you work remotely?",
                        var=remote_freq, display="radio", required=True)

# Assemble questionnaire
survey = Questionnaire(
    title="Work Attitudes Study",
    pages=[Page("main", items=[q_sat, q_remote])],
)

# Simulate and analyze
data = survey.simulate(n=200)
print(data.report.freq("satisfaction").to_markdown())

# Visualize (requires: pip install "siamang[charts]")
data.plot.bar("satisfaction").show()

Full Pipeline Example

The examples/full_pipeline/ directory contains a complete Jupyter notebook demonstrating the entire research workflow — from survey design to statistical analysis:

  1. Survey Design — 12 variables, 5 pages, conditional routing (show_if), matrix questions, Likert scales
  2. Simulation & Deployment — 250 synthetic respondents, local SQLite storage, interactive HTML preview
  3. Declarative Reporting — frequency tables, cross-tabs with Chi², grouped means with auto-selected tests, correlation heatmaps
  4. Visualizations — bar charts, boxplots, heatmaps, scatter plots — all with one line of code
cd examples/full_pipeline
jupyter notebook full_pipeline_demo.ipynb

The folder also includes survey_preview.html — an interactive HTML survey you can open in any browser to see how the questionnaire looks for respondents.


Features

Area Capabilities
Core Variables (nominal/ordinal/interval/ratio), questions (single/multi/open/numeric/likert/matrix/ranking), pages, skip logic (show_if/hide_if), quotas, validation
Reporting Declarative tables (FreqTable, CrossTable, GroupMeanTable) and charts (BarChart, BoxPlot, HeatMap, LikertChart, ScatterPlot, TrendChart over waves or dates) and the chart of an analysis's result drawn from its own numbers (result_charts.chart) — automatic labels, statistical tests, and metadata awareness, in a report theme's chart colors when asked (palette="theme"); every chart as a Vega-Lite 6 spec (vega_lite()) that a report's HTML draws interactively — tooltips, a legend that toggles series, zoom — with Vega vendored in the package (Report.save("r.html", interactive=True)); a report's tables in one Excel workbook (Report.save_tables), and a tab book of every question by a banner (write_tabbook)
Analysis Tests chosen for you or by hand — t-tests, ANOVA and Welch's ANOVA, Mann-Whitney and Kruskal-Wallis with Tukey, Games-Howell and Dunn post-hoc tests, chi-square and Fisher's exact test, Pearson, Spearman and Kendall correlations and matrices, Wilcoxon, McNemar, Friedman and Cochran's Q for paired answers; descriptives, factor analysis, PCA, reliability, regression (linear, logistic, ordinal logit), clustering, key drivers (relative weights, Shapley), perceptual maps (correspondence analysis), price sensitivity (Van Westendorp with NMS, Gabor-Granger) — each weighted or saying it is not
Scripts Inline JavaScript for survey-side behaviour — 7 trigger points
Frontend SurveyJS and React 18 runtimes, dark mode, auto-save, access codes, 6 theme presets
Backend Local SQLite for development, Supabase for production, Google Sheets for collaborative access
Deploy Vercel and Netlify frontends with CSP headers; self-contained HTML bundle for offline use
Data I/O CSV, Excel (.xlsx), SPSS (.sav), Stata (.dta), R — SPSS/Stata round-trip labels and missing values; CSV/Excel carry data only (labels via the JSON dictionary); R export is CSV + dictionary + loader script

Declarative Reporting API

Siamang automatically uses variable metadata (labels, scales, missing values) to produce publication-ready outputs — like SPSS, but in Python:

data = survey.simulate(n=300)

# Tables — automatic labels, tests, and formatting
data.report.freq("it_role")                              # frequency table
data.report.crosstab("gender", "satisfaction", pct="col") # cross-tab + Chi²
data.report.means("autonomy", by="remote_freq")          # means + Kruskal-Wallis

# Charts — one line, automatic axis labels
data.plot.bar("it_role")
data.plot.boxplot("satisfaction", by="remote_freq", show_points=True)
data.plot.heatmap(["surv_keystroke", "surv_camera"], by="remote_freq")
data.plot.scatter("satisfaction", "autonomy", hue="gender")

# Export
data.report.freq("it_role").to_markdown()   # Markdown string
data.report.freq("it_role").to_frame()       # pandas DataFrame
data.report.freq("it_role").to_html()       # HTML table

Deployment

Local (development)

siamang preview my_survey.py        # → http://127.0.0.1:8000

Cloud — Vercel + Supabase (high concurrency)

siamang init                        # one-time: stores credentials
siamang deploy my_survey.py --backend supabase --frontend vercel

Cloud — Netlify + Google Sheets (lightweight)

export SIAMANG_GSHEETS_CREDENTIALS_FILE=./service-account-key.json
export NETLIFY_AUTH_TOKEN=nfp_...
siamang deploy my_survey.py --backend gsheets --frontend netlify

Responses are written to a Google Spreadsheet (one row per respondent) via an Apps Script proxy that acts as a secure intermediary. The survey is hosted on Netlify CDN with automatic HTTPS and global edge distribution.

Note: The Google Sheets backend is currently experimental for public web deployments. Browser-to-Sheets writes require an Apps Script Web App URL to avoid exposing credentials. See docs/reference/deploy.md for setup instructions.

Deployment combinations

Use case Backend Frontend
Local development / testing local local
Small survey, shared with team gsheets netlify
Production, high concurrency supabase vercel or netlify
Offline / air-gapped local local (HTML bundle)

Project Layout

siamang/
├── core/        Variable, Question types, Block, Page, Questionnaire, Expression, Quota, Script
├── data/        SurveyData, DataAnalysis, DataProcessing, SurveyTables
├── reporting/   Declarative tables (FreqTable, CrossTable, GroupMeanTable) and charts (BarChart, BoxPlot, HeatMap, ScatterPlot)
├── frontend/    SurveyJS & React runtimes, bundle builder, UIConfig theme engine, presets
├── deploy/      Backends (SQLite, Supabase, Google Sheets), frontends (Vercel, Netlify, local), pipeline orchestration
├── cli/         validate, preview, deploy, init
├── io/          Import/export for CSV, Excel, SPSS, Stata, R
└── config/      User configuration (~/.siamang.toml), secrets

Documentation

Resource Description
docs/reference/core.md API reference — Variable, Expression, all Question types, Page, Questionnaire
docs/reference/data.md API reference — SurveyData, DataAnalysis, DataProcessing, SurveyTables
docs/reference/reporting.md API reference — Declarative tables and charts
docs/reference/frontend.md API reference — UIConfig, theme presets, runtimes, bundle builder
docs/reference/deploy.md API reference — Backends (Local, Supabase, Google Sheets), Frontends (Local, Vercel, Netlify), pipeline
examples/full_pipeline/ Complete worked example: design → deploy → analyze

Free User Guide

See the complete textbook for the engine, from first installation to banner tables and report documents.


Requirements

  • Python 3.11+
  • For cloud deployment (option A): a Supabase project and a Vercel account
  • For cloud deployment (option B): a Google Cloud service account and a Netlify account

Dependencies

All core dependencies are installed automatically with pip install siamang.

Core (installed automatically)

Package Version Purpose
pandas ≥ 2.0, < 3 Data manipulation, SurveyData backbone
scipy ≥ 1.11 Statistical tests (chi-square, t-test, ANOVA)
openpyxl ≥ 3.1 Excel (.xlsx) import/export
pyreadstat ≥ 1.2 SPSS (.sav) and Stata (.dta) import/export
fastapi ≥ 0.110 Local preview server (siamang preview)
uvicorn ≥ 0.29 ASGI server for local preview
supabase ≥ 2.0 Supabase backend (Postgres + RLS + Edge Functions)
requests ≥ 2.31 HTTP client for Netlify/Vercel deployment APIs

Charts (optional)

pip install "siamang[charts]"
Package Version Purpose
matplotlib ≥ 3.7 Chart rendering (data.plot.bar(), .boxplot(), .scatter(), .heatmap())
seaborn ≥ 0.13 Statistical visualization helpers

Charts are optional — if you only use tables (data.report.freq(), data.report.crosstab()), matplotlib is not needed. A clear error message will guide you if you try to render a chart without it.

Google Sheets backend (optional)

pip install "siamang[gsheets]"
Package Version Purpose
google-auth ≥ 2.0 Service account authentication
google-auth-httplib2 ≥ 0.1 HTTP transport for Google APIs
google-api-python-client ≥ 2.0 Google Sheets API and Google Drive API client

Development

pip install "siamang[dev]"
Package Version Purpose
ruff ≥ 0.4 Linting and formatting
mypy ≥ 1.10 Static type checking
pytest ≥ 8.0 Test runner
matplotlib ≥ 3.7 Required for chart tests
seaborn ≥ 0.13 Required for chart tests

License

Siamang is dual-licensed:

Siamang and Siamang Studio are operated by Siamang Labs LLC (Wyoming, USA).

Metadata

Release files for siamang 0.6.5

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

Source distribution (sdist)

Source distribution for siamang 0.6.5
File Size Uploaded Provenance Actions
siamang-0.6.5.tar.gz 2.5 MB Without provenance Details for siamang-0.6.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for siamang 0.6.5
File Interpreter ABI Platform Actions
siamang-0.6.5-py3-none-any.whl Python 3 none any Details for siamang-0.6.5-py3-none-any.whl

Total release size: 4.4 MB

Release files / siamang-0.6.5.tar.gz

Download URL siamang-0.6.5.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
e6b7c13304faa9748c7ae3a3176f6d95250ecde26b547be3a70929d80cba8480
BLAKE2b-256 checksum
How to use checksums
a814a9b070356c418e317ea450d29461ecb343c29910274cacd8f2d996d129e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / siamang-0.6.5-py3-none-any.whl

Download URL siamang-0.6.5-py3-none-any.whl
Size 1.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
577932e8d68dd91c89d71db1c7fe34c7b98659ed6d53d03108a099bdea89a5c9
BLAKE2b-256 checksum
How to use checksums
fba7828944e38eec7665ae5a81760dd0000945c828af07a07e3084515a0b2a72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for siamang 0.6.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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