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 micro services 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 user has already made a form. What user has to do is to make an API request to Bit Form. In response, user 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 API
- Copy your
API Key
then use it in 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. |
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 | number | Path | Sepecify form ID. | required | |
per_page | number | Path | 200 | How many data fetch in each request. | optional |
page | number | Path | 1 | Page offset. | optional |
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 field of a specific form.
- Request
- Response
Name | Type | In | Description |
---|---|---|---|
Bitform-Api-Key | string | Header | Specify your secret key to get access. |
form_id | number | Path | Sepecify form ID. |
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 specific form.
- Request
- Response
Name | Type | In | Description |
---|---|---|---|
Bitform-Api-Key | string | Header | Specify your secret key to get access. |
form_id | number | Path | Sepecify form ID. |
field_key | string | Body | Specify field key and value. |
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 | number | 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
https://<base_url>/wp-json/bitform/v1/entry_update/<form_id>
{
"status": 200,
"code": 4000,
"message": "Data Updated Successfully",
"sucess": true
}
Delete record/entries
- Request
- Response
Parameters
Name | Type | In | Description | |
---|---|---|---|---|
Bitform-Api-Key | string | Header | Specify your secret key to get access. | required |
form_id | number | Path | Specify form ID. | required |
https://<base_url>/wp-json/bitform/v1/entry_delete/<form_id>
{
"status": 200,
"code": 4000,
"message": "Data Updated Successfully",
"sucess": true
}
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!