Formium API Client
The Formium client library provides an API client for communicating with the Formium backend.
Prerequisites
This package requires an active Formium account, project, and a form. You can sign up for free at https://dashboard.formium.io/signup. Free accounts allow for 100 monthly submissions, 10 active forms, and 100MB of total file storage.
Installation
npm install @formium/client
Usage
Create an instance of the FormiumClient with by calling createClient
wiht your project ID and, if you are in Node.js, a personal access token.
Browser
import { createClient } from '@formium/client';const formium = createClient('your_project_id');
Node.js
import { createClient } from '@formium/client';const formium = createClient('your_project_id', {apiToken: 'your_access_token',});
Reference
method createClient
@formium/client
Returns | |
---|---|
Create a new Formium API client |
Parameters | Description |
---|---|
projectSlug | string Project slug Required |
options | Options Client options |
class FormiumClient
Formium Client
method deleteSubmit
@formium/client
Returns | |
---|---|
Promise<void> | Delete a Submission |
Parameters | Description |
---|---|
submitId | string The id of the Submission Required |
fetchOptions | RequestInit Additional request options |
method deleteSubmits
@formium/client
Returns | |
---|---|
Promise<void> | Delete mulitple Submissions |
Parameters | Description |
---|---|
query | DeleteSubmitsQuery Query parameters Required |
fetchOptions | RequestInit Additional request options |
method findForms
@formium/client
Returns | |
---|---|
Return Forms in a project |
Parameters | Description |
---|---|
query | FindFormsQuery Query parameters |
fetchOptions | RequestInit Additional request options |
method findSubmits
@formium/client
Returns | |
---|---|
Find Submissions of a given form |
Parameters | Description |
---|---|
query | FindSubmitsQuery Query parameters Required |
fetchOptions | RequestInit Additional request options |
method getFormById
@formium/client
Returns | |
---|---|
Promise<Form> | Return a Form given its id |
Parameters | Description |
---|---|
id | string Required |
query | GetFormQuery Query parameters |
fetchOptions | RequestInit Additional request options |
method getFormBySlug
@formium/client
Returns | |
---|---|
Promise<Form> | Return a Form based on its slug |
Parameters | Description |
---|---|
formSlug | string form slug Required |
query | GetFormQuery Query parameters |
fetchOptions | RequestInit Additional request options |
method getMe
@formium/client
Returns | |
---|---|
Promise<User> | Return the current User (based on the token) |
Parameters | Description |
---|---|
fetchOptions | RequestInit |
method getMyProjects
@formium/client
method getProject
@formium/client
Returns | |
---|---|
Promise<Project> | Return a Project by id |
Parameters | Description |
---|---|
id | string Project id Required |
fetchOptions | RequestInit fetch overrides |
method getProjectBySlug
@formium/client
Returns | |
---|---|
Promise<Project> | Return a Project by slug |
Parameters | Description |
---|---|
projectSlug | string A Project slug Required |
fetchOptions | RequestInit |
method getSubmit
@formium/client
Returns | |
---|---|
Promise<Submit> | Return a Submission |
Parameters | Description |
---|---|
submitId | string The id of the submission Required |
fetchOptions | RequestInit Additional request options |
method logout
@formium/client
Returns | |
---|---|
Promise<any> | Delete the current Oauth2 bearer token (for signout) |
Parameters | Description |
---|---|
fetchOptions | RequestInit |
method submitForm
@formium/client
Returns | |
---|---|
Promise<void> | Submit data to a Form |
Parameters | Description |
---|---|
formSlug | string Slug of the Form Required |
data | SubmitData An object or FormData instance containing submission data. Required |
method uploadFile
@formium/client
Returns | |
---|---|
Promise<string | null> | Upload a file to Formium. All uploads are private by default. |
Parameters | Description |
---|---|
formSlug | string Slug of the Form Required |
file | File File to be uploaded Required |