# dataworks-open-api

Adopt this skill: https://proskills.md/skills/other/lucaducapuca-alibabacloud-bigdata-skills-skills-dataworks-open-api

Page: https://proskills.md/skills/other/lucaducapuca-alibabacloud-bigdata-skills-skills-dataworks-open-api
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: skills/dataworks/open-api/SKILL.md
size: 8042
upstream: https://github.com/lucaducapuca/alibabacloud-bigdata-skills/blob/main/skills/dataworks/open-api/SKILL.md

````text
---
name: dataworks-open-api
description: Operate Alibaba Cloud DataWorks through dynamic API discovery and official SDKs (Node.js, Python, Java). Covers data development, workflow operations, data integration, data quality, metadata lineage, workspace management, and more. APIs are discovered at runtime from official docs and OpenAPI metadata — no hardcoded list.
source: https://github.com/aliyun/alibabacloud-bigdata-skills
homepage: https://github.com/aliyun/alibabacloud-bigdata-skills/tree/main/skills/dataworks/open-api
env:
  - name: ALIBABA_CLOUD_ACCESS_KEY_ID
    description: Alibaba Cloud Access Key ID (required unless using credentials URI or shared config)
    required: false
  - name: ALIBABA_CLOUD_ACCESS_KEY_SECRET
    description: Alibaba Cloud Access Key Secret (required unless using credentials URI or shared config)
    required: false
  - name: ALIBABA_CLOUD_REGION_ID
    description: Target region (e.g. cn-shanghai, cn-beijing). Optional; skill will prompt if unset.
    required: false
  - name: ALIBABA_CLOUD_CREDENTIALS_URI
    description: HTTP endpoint for dynamic AK/SK/STS token (alternative to explicit AK/SK)
    required: false
---

# DataWorks (dataworks-public)

Use Alibaba Cloud OpenAPI (RPC) with official SDKs or OpenAPI Explorer to manage all DataWorks resources. MCP Server is available as an alternative integration.

## Workflow

1. Confirm region, project/resource identifiers, and desired action.
2. Discover available APIs and required parameters (see API discovery below).
3. Call API via SDK.
4. Verify results with describe/list/get APIs.

### Troubleshooting fallback chain (follow this order)

If execution fails at any step, escalate to the next level:

1. **Cookbook** — check `references/cookbook.md` first. It contains verified API patterns, pitfalls, error recovery, the full end-to-end lifecycle (Create → Submit → Deploy → Run → Monitor), and reusable code snippets. Most common issues are already documented there.
2. **Official help docs** — read the API overview and per-API doc pages.
   - If an API call fails or the request/error is not understood, fetch the API directory page to locate the relevant API documentation:
     `https://help.aliyun.com/zh/dataworks/developer-reference/api-dataworks-public-2024-05-18-dir`
     Browse the category list, find the matching API name, and navigate to its detail page (URL pattern: `https://help.aliyun.com/zh/dataworks/developer-reference/api-dataworks-public-2024-05-18-{apinameincamelcase}`) for parameter details, error codes, and usage examples.
     For example, if `CreateNode` fails, find it under "数据开发（新版）" in the directory, then read its detail page: `https://help.aliyun.com/zh/dataworks/developer-reference/api-dataworks-public-2024-05-18-createnode`
3. **OpenAPI metadata** — fetch the raw JSON spec for exact parameter names, types, and required fields.
4. **SDK API docs** — check the typed SDK reference for correct method signatures and request classes.

- Java: `https://aliyunsdk-pages.alicdn.com/apidocs/{PRODUCT_CODE}/{API_VERSION}/java-async-tea/8.0.3/index.html`
- Node.js / Python: see `references/sources.md`

5. **GitHub source code** — read the Java SDK source for model/request class definitions: `https://github.com/aliyun/alibabacloud-java-sdk/tree/master/dataworks-public-20240518` (browse `src/main/java/com/aliyun/dataworks_public20240518/` for request/response models).
6. **MCP Server** — use the MCP Server to call APIs directly (see `references/mcp_server.md`).
7. **Browser** — use browser-use to visit the DataWorks Homepage (`https://dataworks.data.aliyun.com/${ALIBABA_CLOUD_REGION_ID}/#/index`) and inspect the UI behavior, network requests, or page content for clues.

## Credentials priority (must follow)

1. Environment variables: `ALIBABA_CLOUD_ACCESS_KEY_ID` / `ALIBABA_CLOUD_ACCESS_KEY_SECRET` / `ALIBABA_CLOUD_REGION_ID`
2. Credentials URI: `ALIBABA_CLOUD_CREDENTIALS_URI` (e.g. `http://localhost:7002/api/v1/credentials/0`). The SDK credentials provider automatically fetches and refreshes AK/SK/STS tokens from this HTTP endpoint.
3. Shared config file: `~/.alibabacloud/credentials`

Region policy: `ALIBABA_CLOUD_REGION_ID` is an optional default. If unset, decide the most reasonable region for the task; if unclear, ask the user.

## API discovery

Constants (use these values throughout):

- **PRODUCT_CODE**: `dataworks-public`
- **API_VERSION**: `2024-05-18`
- Use OpenAPI metadata endpoints to list APIs and get schemas (see references).

Do NOT rely on a hardcoded API list. Always discover APIs dynamically. Methods are listed in priority order — try them top-down:

### Method 1: Fetch from official help docs

Run the discovery script to curl the official documentation page and extract the complete API overview:

```bash
python scripts/fetch_api_overview.py
```

This fetches `https://help.aliyun.com/zh/dataworks/developer-reference/api-{PRODUCT_CODE}-{API_VERSION}-overview`, extracts the API list from `window.__ICE_PAGE_PROPS__.docDetailData.storeData.data.content`, and parses the HTML tables into a grouped API overview.

### Method 2: Fetch from OpenAPI metadata (full spec with parameters and responses)

Fetch raw API schemas and parameter definitions:

```bash
python scripts/list_openapi_meta_apis.py
```

This calls `https://next.api.aliyun.com/meta/v1/products/{PRODUCT_CODE}/versions/{API_VERSION}/api-docs.json` and outputs the full API docs JSON and a summary list.

To get the schema of a single API (replace `{ApiName}` with a name from the list above, e.g. `ListProjects`):

```
https://next.api.aliyun.com/meta/v1/products/{PRODUCT_CODE}/versions/{API_VERSION}/apis/{ApiName}/api.json
```

### Method 3: MCP Server tools (curated subset with category and parameter-position metadata)

If the MCP Server is running, use the MCP `tools/list` capability, or fetch `https://dataworks.data.aliyun.com/pop-mcp-tools` directly for the tool catalog JSON. Includes some APIs not in Method 2 (e.g. data service, permission approval).

## Calling APIs via SDK

**Recommend using the latest SDK version.** The DataWorks SDK is updated frequently with new APIs, bug fixes, and model changes. Check the latest version from the package registry before installing:

- Node.js: `https://www.npmjs.com/package/@alicloud/dataworks-public20240518`
- Python: `https://pypi.org/project/alibabacloud-dataworks-public20240518/`
- Java: `https://central.sonatype.com/artifact/com.aliyun/alibabacloud-dataworks_public20240518`

Prefer the official Alibaba Cloud SDK. Two styles are supported:

### Style 1: Generalized call (recommended, covers all APIs)

Use `@alicloud/openapi-client` to call any DataWorks API without importing product-specific SDK classes. This is the approach used by the MCP Server source code (`src/tools/callTool.ts`).

```bash
npm install @alicloud/openapi-client @alicloud/openapi-util @alicloud/tea-util @alicloud/credentials
```

```typescript
import OpenApi from "@alicloud/openapi-client";
import Util from "@alicloud/tea-util";

// 1. Create client
const config = new OpenApi.Config({
  accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID,
  accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET,
  endpoint: `dataworks.${
    process.env.ALIBABA_CLOUD_REGION_ID || "cn-shanghai"
  }.aliyuncs.com`,
});
const client = new OpenApi.default(config);

// 2. Build request params (RPC style)
const params = new OpenApi.Params({
  style: "RPC",
  action: "ListProjects", // API name
  version: "{API_VERSION}", // see Constants above
  protocol: "HTTPS",
  method: "POST", // GET or POST per API spec
  authType: "AK",
  pathname: "/",
  bodyType: "json",
});

// 3. Build query/body from input
const query = { PageNumber: 1, PageSize: 10 };
const request = new OpenApi.OpenApiRequest({ query });
const runtime = new Util.RuntimeOptions({});

// 4. Call
const res = await client.callApi(params, request, runtime);
console.log(res.body);
```

Key rules from `src/tools/callTool.ts`:

- `style
````

## File: README.md
upstream: https://github.com/lucaducapuca/alibabacloud-bigdata-skills/blob/main/README.md

````text
# dataworks-open-api

Alibaba Cloud DataWorks skill for AI agents. Manage data development, workflow operations, data quality, metadata lineage, and workspace administration through a single skill.

## Skill structure

```
dataworks-open-api/
├── SKILL.md                          # Main skill instructions (read by AI agent)
├── README.md                         # This file — quick start & overview
├── agents/
│   └── openai.yaml                   # Agent interface definition
├── references/
│   ├── cookbook.md                    # Verified API patterns, pitfalls, end-to-end lifecycle, recipes & FAQ
│   ├── sources.md                    # API docs, SDK, and MCP Server links
│   └── mcp_server.md                # MCP Server setup and configuration
└── scripts/
    ├── fetch_api_overview.py         # Fetch API list from official help docs
    └── list_openapi_meta_apis.py     # Fetch API specs from OpenAPI metadata
```

## Quick start

```bash
# Option A: Credentials URI (recommended for local development)
export ALIBABA_CLOUD_CREDENTIALS_URI="http://localhost:7002/api/v1/credentials/0"

# Option B: Static AK/SK
export ALIBABA_CLOUD_ACCESS_KEY_ID="your-ak"
export ALIBABA_CLOUD_ACCESS_KEY_SECRET="your-sk"

export ALIBABA_CLOUD_REGION_ID="cn-shanghai"

# Discover available APIs
python scripts/fetch_api_overview.py
python scripts/list_openapi_meta_apis.py
```

## SDK support

| Language | Package                                            |
| -------- | -------------------------------------------------- |
| Node.js  | `@alicloud/dataworks-public20240518`               |
| Python   | `alibabacloud_dataworks_public20240518`            |
| Java     | `com.aliyun:alibabacloud-dataworks_public20240518` |

## Troubleshooting fallback chain

When execution fails, escalate in this order:

1. **Cookbook** (`references/cookbook.md`) — verified patterns, pitfalls & error recovery
2. Official help docs
3. OpenAPI metadata (raw JSON spec)
4. SDK API docs
5. GitHub SDK source code
6. MCP Server
7. Browser (DataWorks Homepage)

See `SKILL.md` for full details on each level.

## Links

- [DataWorks documentation](https://www.alibabacloud.com/help/dataworks)
- [OpenAPI Explorer](https://api.aliyun.com/product/dataworks-public)
- [MCP Server (npm)](https://www.npmjs.com/package/alibabacloud-dataworks-mcp-server)
- [MCP Server (GitHub)](https://github.com/aliyun/alibabacloud-dataworks-mcp-server)
````
