|
| 1 | +# REST APIs |
| 2 | + |
| 3 | +## Connect REST API to Openblocks |
| 4 | + |
| 5 | +Follow these steps to connect to REST APIs. |
| 6 | + |
| 7 | +1. Click **Data Sources** on Openblocks homepage. |
| 8 | +2. Click **New Data Source** on the upper right. This permission is restricted to workspace admins and developers. |
| 9 | +3. Select **APIs** > **REST API**. |
| 10 | + |
| 11 | + <figure><img src="../../.gitbook/assets/rest-api-1.png" alt=""><figcaption></figcaption></figure> |
| 12 | +4. Configure general settings. At a minimum, input **Name** and the base **URL** of the API to connect to. **Headers** and **Parameters** are optional. These are all common parameters that consist of URL query prefixes. For more information, see Make API requests. |
| 13 | +5. Configure **Authentication Type**. |
| 14 | +6. Click **Save**. |
| 15 | + |
| 16 | + <figure><img src="../../.gitbook/assets/rest-api-2.png" alt=""><figcaption></figcaption></figure> |
| 17 | + |
| 18 | +You can also connect to a new REST API data source when creating or editing queries in query library or query editor. |
| 19 | + |
| 20 | +## Authentication type |
| 21 | + |
| 22 | +The default authentication type is **None**. Other options are **Basic** and **Digest**, which require configuration of **Username** and **Password**. |
| 23 | + |
| 24 | +<figure><img src="../../.gitbook/assets/rest-api-3.png" alt=""><figcaption></figcaption></figure> |
| 25 | + |
| 26 | +If you need other customized authentication methods, contact our customer service on the homepage. |
| 27 | + |
| 28 | +## SSL Cert Verification |
| 29 | + |
| 30 | +In the advanced settings tab, you can configure SSL Cert Verification for your data sources. Three options are available: CA (Certificate Authority) Certificate, Self Signed Certificate, or Disabled. For security reasons, Openblocks accepts APIs with CA certificates by default. For APIs without CA certificates, you can either select "Verify Self Signed Cert" and enter the self-signed certificate or disable the SSL Cert verification. |
| 31 | + |
| 32 | +<figure><img src="../../.gitbook/assets/rest-api-4.png" alt=""><figcaption></figcaption></figure> |
| 33 | + |
| 34 | +Note that for self-signed certificate, the information should be provided in .[PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced\_Mail) (Privacy-Enhanced Mail) format. This certificate will be encrypted and stored securely in Openblocks. |
| 35 | + |
| 36 | +<figure><img src="../../.gitbook/assets/rest-api-5.png" alt=""><figcaption></figcaption></figure> |
| 37 | + |
| 38 | +## Forward Cookies |
| 39 | + |
| 40 | +If you are self-hosting Openblocks in your own domain, you can make REST API requests with cookies to existing services under that domain. You can either toggle the option "Forward all cookies" or specify certain cookies to forward in the text box. This feature can be helpful in cases where you use cookies to share common context (like identity info in JWT format) across different services. |
| 41 | + |
| 42 | +<figure><img src="../../.gitbook/assets/rest-api-6.png" alt=""><figcaption></figcaption></figure> |
| 43 | + |
| 44 | +## Create a REST API query |
| 45 | + |
| 46 | +You can create REST API queries in two ways: |
| 47 | + |
| 48 | +* add a new data source and then create a query |
| 49 | +* create a query directly |
| 50 | + |
| 51 | +Note that without creating a new data source, the REST API data source is not stored in your **Data Sources** and thus cannot be accessed to build other queries. |
| 52 | + |
| 53 | +### Create a query with a new data source |
| 54 | + |
| 55 | +Follow the steps to add a new REST API data source first and then create a query. |
| 56 | + |
| 57 | +1. Connect REST API to access to. |
| 58 | +2. In the query editor, click **+ New**. |
| 59 | +3. Select the added API in **Data source**.  |
| 60 | + |
| 61 | + <figure><img src="../../.gitbook/assets/rest-api-7.png" alt=""><figcaption></figcaption></figure> |
| 62 | + |
| 63 | + |
| 64 | +4. Enter URL, Headers, Parameters, and fill in other fields if needed. |
| 65 | +5. Click ▶ **Run**. |
| 66 | + |
| 67 | +### Create a REST API query with predefined data source |
| 68 | + |
| 69 | +Follow the steps to create a REST API query directly. |
| 70 | + |
| 71 | +1. In the query editor, click **+ New**. |
| 72 | +2. Select **REST Query** in Data Sources. Openblocks offers this built-in plain data source so that you can quickly create REST API queries without adding a new data source first.  |
| 73 | + |
| 74 | + <figure><img src="../../.gitbook/assets/rest-api-8.png" alt=""><figcaption></figcaption></figure> |
| 75 | +3. Enter URL, Query, Variables, Parameters, and fill in other fields if needed. |
| 76 | + |
| 77 | + <figure><img src="../../.gitbook/assets/rest-api-9.png" alt=""><figcaption></figcaption></figure> |
| 78 | + |
| 79 | + |
| 80 | +4. Click ▶ **Run**. |
0 commit comments