# Data sharing API

## Get your personal API key

You can generate, manage, and perform actions on your API key to use the Data Service API.

1. Click **How to call API?** in the utility bar
2. The API Key is hidden by default. Click on **Reveal the key** to see its value, and you can quickly click to **Copy.**
3. Follow the API documentation below for API endpoints, request parameters and usage guidelines.

<figure><img src="https://786945529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFTrGKWnjusKCQj11CkuL%2Fuploads%2FdxYyhW39bKZWwnHT0acj%2FScreenshot%202025-02-27%20at%2012.44.28.png?alt=media&#x26;token=e7147bcb-c037-48a6-ba44-74770782a84a" alt=""><figcaption></figcaption></figure>

You can click **Rotate** to generate a new API key (replace the existing one).

<figure><img src="https://786945529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFTrGKWnjusKCQj11CkuL%2Fuploads%2FUmRfymbFNljAkC9Q86HY%2FScreenshot%202025-02-27%20at%2016.06.47.png?alt=media&#x26;token=9d8acd65-6830-45d0-aa31-105f2db9c4ce" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
The current key will immediately be disabled once rotated and requests made using the key will be rejected.
{% endhint %}

### API Documentation

### Prerequisite

Obtain your [personal API key](#get-your-personal-api-key) from the Data Service detail page.

### API Request

#### **Request Header**

| Request header | Value                       |
| -------------- | --------------------------- |
| Authorization  | Bearer `{{ your_API_key }}` |

#### **Request Body**

<table><thead><tr><th width="128">Parameter</th><th width="92">Type</th><th width="539">Description</th></tr></thead><tbody><tr><td>filters</td><td>array</td><td><p>Filter conditions list. Each filter contains:</p><ul><li><code>field</code>: The field name to filter on.</li><li><code>operator</code>: The comparison operator. </li></ul><p>Supported operators: </p><p><code>=</code>, <code>!=</code>, <code>></code>, <code>&#x3C;</code>, <code>&#x3C;=</code>, <code>~</code> (inclusive), <code>!~</code> (exclusive), </p><p><code>time_between</code>, <code>time_relative</code> (for special time ranges including <code>today</code>, <code>yesterday</code>, <code>this_week</code>, <code>last_week</code>, <code>this_month</code>, <code>this_year</code>, <code>last_year</code>).</p><ul><li><code>value</code>: The filter value. </li></ul><p>If using <code>time_between</code>, the value must be an array in the format <code>[start_time, end_time]</code>.</p></td></tr><tr><td>sorts</td><td>array</td><td><p>Sort conditions list. Each sort condition contains:</p><ul><li><code>field</code>: The field name to sort by.</li><li><code>order</code>: The sorting order, either <code>asc</code> (ascending) or <code>desc</code> (descending).</li></ul></td></tr><tr><td>page</td><td>int</td><td>The page number for pagination.</td></tr><tr><td>page_size</td><td>int</td><td><p>The number of records returned per page. </p><p>Allowed values: <code>[100, 10000]</code>. Default: <code>100</code>.</p></td></tr></tbody></table>

#### **Request Example**

{% code overflow="wrap" %}

```sh
curl --location --request POST 'https://api.reorc.cloud/api/data-service/open/services/{{ data_service_id }}/preview' \
--header 'Accept-Language: en-US,en;q=0.9,zh;q=0.8,zh-CN;q=0.7' \
--header 'Cache-Control: no-cache' \
--header 'Connection: keep-alive' \
--header 'DNT: 1' \
--header 'Origin: https://demo.reorc.cloud' \
--header 'Pragma: no-cache' \
--header 'Referer: https://demo.reorc.cloud/' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Sec-Fetch-Site: same-site' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36' \
--header 'accept: application/json' \
--header 'sec-ch-ua: "Chromium";v="133", "Not(A:Brand";v="99"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--header 'content-type: application/json' \
--header 'Authorization: Bearer {{ your_api_key }}' \
--header 'Host: api.reorc.cloud' \
--data-raw '{
    "filters": [
        {
            "field": "PaymentMethod",
            "operator": "=",
            "value": "Cash"
        }
    ],
    "filter_logic": "all",
    "sorts": [],
    "timezone": "Asia/Shanghai"
}'
```

{% endcode %}

{% hint style="info" %}
Please replace the following parameters with actual values:

* `{{ data_service_id }}`: the actual ID of the data service.
* `{{ your_api_key }}`: your personal API key.
  {% endhint %}

#### **Response Example**

Successful Response Example

{% code fullWidth="false" %}

```json
{
    "code": "0",
    "msg": "success",
    "data": {
        "total": 304,
        "items": [
            {
                "o_orderkey": {
                    "type": "bigint",
                    "name": "o_orderkey",
                    "normalized_type": "integer",
                    "value": "5997922"
                },
                "o_orderdate": {
                    "type": "date",
                    "name": "o_orderdate",
                    "normalized_type": "date",
                    "value": "1992-12-04"
                },
                "o_custkey": {
                    "type": "int",
                    "name": "o_custkey",
                    "normalized_type": "integer",
                    "value": "88970"
                },
                "o_orderstatus": {
                    "type": "varchar",
                    "name": "o_orderstatus",
                    "normalized_type": "string",
                    "value": "F"
                },
                "o_totalprice": {
                    "type": "decimal",
                    "name": "o_totalprice",
                    "normalized_type": "float",
                    "value": "91422.19"
                },
                "o_orderpriority": {
                    "type": "varchar",
                    "name": "o_orderpriority",
                    "normalized_type": "string",
                    "value": "4-NOT SPECIFIED"
                },
                "o_clerk": {
                    "type": "varchar",
                    "name": "o_clerk",
                    "normalized_type": "string",
                    "value": "Clerk#000000108"
                },
                "o_shippriority": {
                    "type": "int",
                    "name": "o_shippriority",
                    "normalized_type": "integer",
                    "value": "0"
                },
                "o_comment": {
                    "type": "varchar",
                    "name": "o_comment",
                    "normalized_type": "string",
                    "value": "oze blithely across the slyly bold packages. dolphin"
                }
            },
            {
                "o_orderkey": {
                    "type": "bigint",
                    "name": "o_orderkey",
                    "normalized_type": "integer",
                    "value": "5997921"
                },
                "o_orderdate": {
                    "type": "date",
                    "name": "o_orderdate",
                    "normalized_type": "date",
                    "value": "1997-03-16"
                },
                "o_custkey": {
                    "type": "int",
                    "name": "o_custkey",
                    "normalized_type": "integer",
                    "value": "117583"
                },
                "o_orderstatus": {
                    "type": "varchar",
                    "name": "o_orderstatus",
                    "normalized_type": "string",
                    "value": "O"
                },
                "o_totalprice": {
                    "type": "decimal",
                    "name": "o_totalprice",
                    "normalized_type": "float",
                    "value": "68401.33"
                },
                "o_orderpriority": {
                    "type": "varchar",
                    "name": "o_orderpriority",
                    "normalized_type": "string",
                    "value": "2-HIGH"
                },
                "o_clerk": {
                    "type": "varchar",
                    "name": "o_clerk",
                    "normalized_type": "string",
                    "value": "Clerk#000000101"
                },
                "o_shippriority": {
                    "type": "int",
                    "name": "o_shippriority",
                    "normalized_type": "integer",
                    "value": "0"
                },
                "o_comment": {
                    "type": "varchar",
                    "name": "o_comment",
                    "normalized_type": "string",
                    "value": "xcuses nag slyly. idle dolphins cajole ironically-- regular, bold ex"
                }
            },
            {
                "o_orderkey": {
                    "type": "bigint",
                    "name": "o_orderkey",
                    "normalized_type": "integer",
                    "value": "5997920"
                },
                "o_orderdate": {
                    "type": "date",
                    "name": "o_orderdate",
                    "normalized_type": "date",
                    "value": "1992-08-02"
                },
                "o_custkey": {
                    "type": "int",
                    "name": "o_custkey",
                    "normalized_type": "integer",
                    "value": "42044"
                },
                "o_orderstatus": {
                    "type": "varchar",
                    "name": "o_orderstatus",
                    "normalized_type": "string",
                    "value": "F"
                },
                "o_totalprice": {
                    "type": "decimal",
                    "name": "o_totalprice",
                    "normalized_type": "float",
                    "value": "36627.47"
                },
                "o_orderpriority": {
                    "type": "varchar",
                    "name": "o_orderpriority",
                    "normalized_type": "string",
                    "value": "1-URGENT"
                },
                "o_clerk": {
                    "type": "varchar",
                    "name": "o_clerk",
                    "normalized_type": "string",
                    "value": "Clerk#000000205"
                },
                "o_shippriority": {
                    "type": "int",
                    "name": "o_shippriority",
                    "normalized_type": "integer",
                    "value": "0"
                },
                "o_comment": {
                    "type": "varchar",
                    "name": "o_comment",
                    "normalized_type": "string",
                    "value": "al instructions nag carefully until the requests. fluffily re"
                }
            },
            {
                "o_orderkey": {
                    "type": "bigint",
                    "name": "o_orderkey",
                    "normalized_type": "integer",
                    "value": "5997895"
                },
                "o_orderdate": {
                    "type": "date",
                    "name": "o_orderdate",
                    "normalized_type": "date",
                    "value": "1996-01-15"
                },
                "o_custkey": {
                    "type": "int",
                    "name": "o_custkey",
                    "normalized_type": "integer",
                    "value": "91180"
                },
                "o_orderstatus": {
                    "type": "varchar",
                    "name": "o_orderstatus",
                    "normalized_type": "string",
                    "value": "O"
                },
                "o_totalprice": {
                    "type": "decimal",
                    "name": "o_totalprice",
                    "normalized_type": "float",
                    "value": "199978.64"
                },
                "o_orderpriority": {
                    "type": "varchar",
                    "name": "o_orderpriority",
                    "normalized_type": "string",
                    "value": "2-HIGH"
                },
                "o_clerk": {
                    "type": "varchar",
                    "name": "o_clerk",
                    "normalized_type": "string",
                    "value": "Clerk#000000075"
                },
                "o_shippriority": {
                    "type": "int",
                    "name": "o_shippriority",
                    "normalized_type": "integer",
                    "value": "0"
                },
                "o_comment": {
                    "type": "varchar",
                    "name": "o_comment",
                    "normalized_type": "string",
                    "value": "ly among the regular, even depend"
                }
            }
        ],
        "error": null
    }
}
```

{% endcode %}

Failed Response Example

{% code overflow="wrap" %}

```json
{
    "code": "0",
    "msg": "success",
    "data": {
        "total": 0,
        "items": [],
        "error": {
            "code": "A1402",
            "reason": "Preview data failed: (1105, \"errCode = 2, detailMessage = Unknown column 'o_orderke' in '_reorc_limit_subquery' in SORT clause\")",
            "data": null
        }
    }
}
```

{% endcode %}
