special offer desktop
menu-icon
Bit Assist Menu Icon

API

Estimated reading: 6 minutes 410 views

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

  1. Go to Bit form Settings and then navigate to API
  2. Copy your API Key then use it in the request header.

API Endpoints

Get Forms

To fetch all forms.

  • Request
  • Response

Parameters

NameTypeInDescription
Bitform-Api-KeystringHeaderSpecify 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

NameTypeInDefaultDescription
Bitform-Api-KeystringHeaderSpecify your secret key to get access.required
form_idnumberPathSepecify form ID.required
per_pagenumberPath200How many data fetch in each request.optional
pagenumberPath1Page 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

NameTypeInDescription
Bitform-Api-KeystringHeaderSpecify your secret key to get access.
form_idnumberPathSepecify 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 typelbl = field label nameph = 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 MessageRedirect URLWeb hookIntegration 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

NameTypeInDescription
Bitform-Api-KeystringHeaderSpecify your secret key to get access.
form_idnumberPathSepecify form ID.
field_keystringBodySpecify 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

NameTypeInDescription
Bitform-Api-KeystringHeaderSpecify your secret key to get access.required
form_idnumberPathSepecify form ID.required
field_key_1stringBodySpecify the value for the field.optional
field_key_2stringBodySpecify 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

NameTypeInDescription
Bitform-Api-KeystringHeaderSpecify your secret key to get access.required
form_idnumberPathSpecify 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

NameTypeInDescription
form_idnumberPathThe id of the form for which the workflow is to be fetched.required
Bitform-Api-KeystringHeaderThe 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

NameTypeInDescription
form_idnumberPathThe id of the form for which the record/entries is to be added.required
Bitform-Api-KeystringHeaderThe api key of the form for which the record/entries is to be added.required
field_key_1stringBodySpecify field key and value.required
field_key_2stringBodySpecify the value for the field.required
workflownumberBodyOnly one onsubmit workflow.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 CodeHTTP StatusCodeMessage
200OK4000Successfully data submitted
200OK3910No forms available
200OK3920No fields available
200OK3710No field named {field} found. Please check and try again.
200OK3120Data type mismatch
200OK3970The 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
400Not Found3030The API request’s body content is missing
404Not Found3100No Entry with ID
404Not Found3200No Form with ID
404Not Found3130No form was found. Please check and try again
422Validation Error3070Data validation failure

Watch a demo tutorial here!

🖐 Let us know if you have any feedback or any API requests at [email protected].

Share this Doc

API

Or copy link

CONTENTS