API Basics for Formsite Forms & Results
One of the ways Formsite helps form owners is by connecting to third-party services through integrations. The payment integrations, for example, allow form owners to collect payments from order forms by simply adding the merchant account information. Where we don’t have a built-in integration, the Application Program Interface connects online services, or API for short.
The API for any service communicates with the service and passes data from one side to the other. This data transfer can either PUSH or PULL the data, depending on which side is making the request:
- Formsite can PUSH the data by triggering the Server Post integration when the form is submitted and sending the form result data to another system. Read more about using Server Post.
- An external system can PULL the data by connecting to Formsite using the API and receiving the information.
Formsite API
The API settings for every Formsite account can be found on the “Form Settings->Integrations->API” page.
That settings page contains some quick links to the most common tools, in addition to the account’s key.
The major actions available are:
- List the forms in the account
- Return the status of a form (open, closed)
- List the number of results for a form
- List the results for a form
When the browser sends the correct action syntax, the response is provided in XML format, a widely used and easily processed format used by virtually every system.
Parameters
Using parameters with the API actions greatly expands its functionality. For example, referring to the major actions list above and choosing the first option (list the forms), the syntax is:
https://fsX.formsite.com/api/users/yourAccount/forms
To authorize the action, add the parameter ‘fs_api_key’ and the value:
https://fsX.formsite.com/api/users/yourAccount/forms?fs_api_key=xxxxxxxxx
Try it:
- Copy the link and replace the bold values with the actual values from your account. The API key can be found on the “Form Settings->Integrations->API” page.
- Paste the link into a browser address bar and press Enter to see your account’s forms.
Combining parameters is done by listing them at the end and separating with a ‘&’ symbol. For example, to retrieve a list of results for a form:
https://fsX.formsite.com/api/users/yourAccount/forms/yourForm/results?fs_api_key=xxxxxxxxx
To retrieve the last 5 results, add ‘&fs_limit=5’:
https://fsX.formsite.com/api/users/yourAccount/forms/yourForm/results?fs_api_key=xxxxxxxxx&fs_limit=5
Each action has a list of available parameters on the API documentation page.
Practical Example
Task: Create a way for members to view previous orders. This tool can be part of the company’s member area and linked to a page titled ‘Order History’.
- Create the link to the order form to return the results for the form, then add the parameter for ‘fs_search_contains_x’, then add the member’s information:
https://fsX.formsite.com/api/users/yourAccount/forms/yourForm/results?fs_api_key=xxxxxxxxx&fs_search_contains_x=MemberNumber
- Use Javascript or jQuery to connect to that URL and return the data, then use the Order History page to format the code.