A type-safe and developer-friendly TypeScript wrapper for the tally.so API.
Disclaimer: The Tally.so API is currently in Private Beta and might be subject to change. You need to sign up for the Beta to get access.
Full documentation available here
npm install tally-js
This tally client provides access to all endpoints of the Tally.so API by exposing services
Service endpoints always return a response with
{
data: TallyDTO | null,
error: Error | null
}
Wrapper uses a three-layer architecture for maximum type safety and flexibility:
DTOs (Data Transfer Objects)
Domain Interfaces
TallyForm interface with addBlock functionModels
import { TallyClient } from 'tally-js'
const tally = new TallyClient({
apiKey: 'your-api-key','https://api.tally.so'
})
// Access data
const { data: form, error } = await tally.forms.get('form-id')
console.log(form)
// init client as described above
import {
TallyFormModel,
TallyFormStatus,
TallyBlockTypes,
initNewTallyBlock,
TallyPayloadFormTitleDTO,
} from 'tally-js'
const newForm = new TallyFormModel(
[], // no blocks - starting from scratch
TallyFormStatus.DRAFT,
{}, // default settings
'your-workspace-id',
)
const titleBlock = initNewTallyBlock(TallyBlockTypes.TITLE)
titleBlock.payload = {
title: 'Official Title',
html: 'Official Title',
} as TallyPayloadFormTitleDTO
// simple option for auto-completion without class instantiation
newForm.addBlock(titleBlock)
const { data: createdForm, error: createError } = await tally.forms.create(newForm)
console.log(createdForm.id, createError)
// should print the form id of the created form and null
let forms = null
let currentPage = 0
do {
currentPage += 1
const { data, error } = await tally.forms.list(currentPage)
if (!error && data) {
forms = data
forms.items.forEach((form) => {
console.log(form.id)
})
}
} while (forms?.hasMore)
const { data, error } = await tally.webhooks.create({
formId: 'xZllsk',
url: 'https://webhook.site/1b1b1b1b',
eventTypes: [TallyWebhookEventType.FORM_RESPONSE],
})
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
tally-js/
├── src/
│ ├── client.ts
│ ├── lib/
│ ├── models/
│ ├── services/
│ ├── types/
│ ├── util/