Bit form API
An API (Application Protocol Interface) defines a set of functions that interact with other software components or applications or you can call microservices between web applications. If any web application or software needs any information from another software, they have to make a call or request to get the information. This specific call or request is called API.
To simplify this context, we can take an example that a user installed a form plugin from which he/she wants to deliver form data to our Bit Form plugin where the user has already made a form. What the user has to do is to make an API request to Bit Form. In response, users will get all the data that they have requested will be stored in Bit Form.
API Key Option
- Go to Bit form Settings and then navigate to API
- Copy your
API Keythen use it in the request header.
API Endpoints
Get Forms
To fetch all forms.
- Request
- Response
Parameters
| Name | Type | In | Description |
|---|---|---|---|
Bitform-Api-Key | string | Header | Specify your secret key to get access. |
GET Request
https://{base_url}/wp-json/bitform/v1/forms
{
"forms": [
{
"form_name": "Contact Form"
"id": "1"
}
],
"status": 200,
"code": 4000,
"sucess":true
}
Fetch Entries
Fetch all entries by specific form ID.
- Request
- Response
Parameters
| Name | Type | In | Default | Description | |
|---|---|---|---|---|---|
Bitform-Api-Key | string | Header | Specify your secret key to get access. | required | |
form_id | Integer | Path | Sepecify form ID. | required | |
per_page | Integer | Path | 200 | How many data fetch in each request. | optional |
page | Integer | Path | 1 | Page offset. | optional |
GET Request
https://{base_url}/wp-json/bitform/v1/form/response/{form_id}
{
"data": {
"count":"95",
"entries":[
{
"entry_id":"12",
"bf1-1":"test data"
},
…
]
},
"status": 200,
"sucess": true
}
Get Form Fields
Fetch all fields of a specific form.
- Request
- Response
Parameters
| Name | Type | In | Description |
|---|---|---|---|
Bitform-Api-Key | string | Header | Specify your secret key to get access. |
form_id | Integer | Path | Sepecify form ID. |
GET Request
https://{base_url}/wp-json/bitform/v1/fields/{form_id}
{
"data": {
"fields": {
"bf1-1-": {
"typ": "txt",
"lbl": "First Name",
"ph": "Enter Your First Name",
"valid": {}
}
},
"fieldkeys": {
"bf1-1-": "bf1-1-"
},
"workflows": [
{
"workflow_name": "workflow 2",
"id": "2"
}
],
"workflow_key_name": "workflow"
},
"status": 200,
"code": 4000,
"sucess": true
}
In this API request user have to indicate the specific id to form_id in which fields will be used to fetch information. Suppose a client sent an API request, under a specific form some field’s information will be inserted where , typ = field type, lbl = field label name, ph = a indicator of the fields action. The valid : {} denotes True/False. If the required field is enabled then valid : {} will return True otherwise valid : {} will be empty. Then fieldkeysis the key name of the input field. Clients can also run workflows using conditional logic by sending API requests. As example, if a client wants any records to be created & submitted, an email notification will be sent. Clients have to set this workflow & have to mention that specific workflow name on their API request. They can set actions like : Success Message, Redirect URL, Web hook, Integration and run those actions through our API request. The workflow_key_name is the input key name of all the created workflows.
Add record/entries
Add entries to a specific form.
- Request
- Response
Parameters
| Name | Type | In | Description |
|---|---|---|---|
Bitform-Api-Key | string | Header | Specify your secret key to get access. |
form_id | Integer | Path | Sepecify form ID. |
field_key | string | Body | Specify field key and value. |
Note: field_key is form field key, e.g: bf1-2
POST Request
https://{base_url}/wp-json/bitform/v1/entry/{form_id}
{
"status": 200,
"code": 4000,
"message": "Data Added Successfully.",
"sucess": true
}
Edit record/entries
- Request
- Response
Parameters
| Name | Type | In | Description | |
|---|---|---|---|---|
Bitform-Api-Key | string | Header | Specify your secret key to get access. | required |
form_id | Integer | Path | Sepecify form ID. | required |
field_key_1 | string | Body | Specify the value for the field. | optional |
field_key_2 | string | Body | Specify the value for the field. | optional |
Note: field_key is form field key, e.g: bf1-2
POST/PUT Request
https://{base_url}/wp-json/bitform/v1/entry_update/{form_id}
{
"status": 200,
"code": 4000,
"message": "Data Updated Successfully",
"sucess": true
}
Delete records/entries
- Request
- Response
Parameters
| Name | Type | In | Description | |
|---|---|---|---|---|
Bitform-Api-Key | string | Header | Specify your secret key to get access. | required |
form_id | Integer | Path | Specify form ID. | required |
DELETE Request
https://{base_url}/wp-json/bitform/v1/entry_delete/{form_id}
{
"status": 200,
"code": 4000,
"message": "Data Deleted Successfully",
"sucess": true
}
Get workflow or conditional logic
This api is used to get the list of all the workflow in the system.
- Request
- Response
Parameters
| Name | Type | In | Description | |
|---|---|---|---|---|
| Integer | Path | The id of the form for which the workflow is to be fetched. | required |
Bitform-Api-Key | string | Header | The api key of the form for which the workflow is to be fetched. | required |
Get Request:
https://{base_url}/wp-json/bitform/v1/workflow/{form_id}
Response:
{
"workflow": [
{
"id": "72",
"workflow_name": "Action 2",
"workflow_type": "onsubmit",
"workflow_run": "create_edit",
"workflow_behaviour": "always"
},
{...}
}
Add Record/Entries with workflow or conditional logic
This api is used to add record/entries in the form with workflow or conditional logic.
- Request
- Response
Parameters
| Name | Type | In | Description | |
|---|---|---|---|---|
| Integer | Path | The id of the form for which the record/entries is to be added. | required |
Bitform-Api-Key | string | Header | The api key of the form for which the record/entries is to be added. | required |
field_key_1 | string | Body | Specify field key and value. | required |
field_key_2 | string | Body | Specify the value for the field. | required |
| workflow | Integer/array of Integers | Body | Single onsubmit workflow id or array of multiple onsubmit workflow IDs. | required |
Post Request:
https://{base_url}/wp-json/bitform/v1/entry/{form_id}
Response:
{
"success": true,
"data": {
"entry_id": 530,
"message": "Form Submitted Successfully",
"msg_id": 0
}
}
API Status Codes
The success or failure of an API request is conveyed by the code and message in its response.
| Http Status Code | HTTP Status | Code | Message |
|---|---|---|---|
200 | OK | 4000 | Successfully data submitted |
200 | OK | 3910 | No forms available |
200 | OK | 3920 | No fields available |
200 | OK | 3710 | No field named {field} found. Please check and try again. |
200 | OK | 3120 | Data type mismatch |
200 | OK | 3970 | The get records API can fetch up to 200 records per request. You’ll have to use the from parameter in your requests to fetch records 1-200, 201-400, and so on |
400 | Not Found | 3030 | The API request’s body content is missing |
404 | Not Found | 3100 | No Entry with ID |
404 | Not Found | 3200 | No Form with ID |
404 | Not Found | 3130 | No form was found. Please check and try again |
422 | Validation Error | 3070 | Data validation failure |
Watch a demo tutorial here!
🖐 Let us know if you have any feedback or any API requests at support@bitapps.pro.
