The Public Application Programming Interface (API) function is an interface that allows sharing your datasets and widgets with your clients. In the Public API section of the MSPbots app, you can create, share, and delete your own API key. Once you have made and shared your public API, your clients can access the datasets and widgets assigned to that key.
1. How to access the Public API section
To access the Public API section, log in to MSPbots and navigate to Settings > Public API.
2.
-
Create an API key:
-
Go to the Public API tab and click the Add New Key button.
- Input a Name, select Custom for Type, and provide a short description for your API.
-
Click Save.
-
-
Copy the API Key
-
Select the API you created in Step 1 from the APIKey dropdown.
-
Click the copy icon to copy the API. Send this to your clients for access to your datasets and widgets.
-
To remove an API Key, click the Remove This Key button. Removing an API key will draw your client's access to the datasets and widgets you assigned to the key.
3. Connecting your data to an API
3.1. Binding a dataset to the API key
- Go to the Public API tab, click Datasets, and hit the Add button.
- On the Add Dataset window, select the dataset or datasets that should be accessible with the API key.
- When done selecting the datasets for binding, click the Selected button to view your selection. You may remove datasets from the list by clicking the X sign corresponding to the dataset for removal.
- Click Add Selected once you confirm the list is correct.
- Then you can see the selected dataset in the dataset list.
3.2. Binding a widget to the API key
- Go to the Public API tab, click Widget, and hit the Add button.
- On the Add Widget window, select the widget or widgets that should be accessible with the API key.
- When done selecting the widgets for binding, click the Selected button to view your selection. You may remove widgets from the list by clicking the X sign corresponding to the widget for removal.
- Click Add Selected once you confirm the list is correct.
- Then you will see the selected widget in the widget list.
4. Stop connecting your data to the API
To disconnect and unbind data to the API
- click the Delete icon for the datasets and widgets.
- Click Confirm to finish the deletion.
5. Enable Public API Switch
The Enable Public API feature is the global switch that controls the availability of the Public API feature. To activate, switch the Enable Public API toggle ON. If disabled, the API Keys and all connected data will be inaccessible.
6. Summary
- Public API provides an HTTP-based API that follows the principles of REST.
- The HTTP rules allow the use of simple HTTP clients like cURL.
- The URLs are resource-oriented, the request format is form-encoded, and the responses are JSON.
- All operations are read-only.
7. Resources
Public API follows the REST model of exposing resources as URLs. The unified domain name of all interfaces is:
https://api.mspbots.ai/
8. Request, Response, Sample Request
REQUEST
Depending on the type of operation, the endpoints use one of two HTTP methods: POST, GET
RESPONSE
The response is in JSON format.
SAMPLE REQUEST
GET REQUEST (Dataset)
curl https://api.mspbots.ai/api/dataset/{resourceId} -H 'apikey: {apiKey}' -X GET
REQUEST
RESPONSE
GET REQUEST (Widget)
curl https://api.mspbots.ai/api/widget/{resourceId} -H 'apikey: {apiKey}' -X GET
REQUEST
RESPONSE
Supported query criteria
https://api.mspbots.ai/api/widget/{resourceId}?current=1&size=10&Real Name=n&Update Date=2021-10-10,2023-03-30,2023-04-05&Id=,1534956341424005122
Logical Operators | Field Type | Example | ||||
TEXT | NUMBER | BOOLEAN | DATE | DATETIME | ||
Is Empty | √ | √ | √ | √ | √ | status= |
Contains | √ | name=Tod | ||||
Equals | √ | √ |
is_default=true id=654321324612312 |
|||
Later Than (>=) | √ | √ | √ |
price=12.6, date=2022-07-01 |
||
Earlier Than (<=) | √ | price=,56.3 | ||||
between (>= and <=) | √ | √ | √ |
price=12.6,56.3 date=2022-07-01,2023-02-01 |
||
Multiple intervals (>= and <=) or (>= and <=) |
√ | √ | √ |
price=12.6,56.3,103,210 date=2022-07-01,2023-02-01,2023-04-01,2023-05-01 |
||
(>= and <=) or (=) | √ | price=12.6,56.3,105.1 | ||||
(>= and <=) or (>=) | √ | √ | date=2022-07-01,2023-02-01,2023-04-01 |
9. Sample Error Responses
- Rate limits
-
Invalid apiKey: Error or deleted
-
Resource unbound
-
The resource does not exist
- HTTP 502 error status code, please refer to Receiving HTTP 502 Error Status Code When Fetching Data Requests from Widget Using Public API for resolution.