REST API(データ取得用インターフェース)からデータを取得し、AIDP(アイデータプラットフォーム)の「aidataplatform」汎用REST コネクタを使用して Spark DataFrame(データ処理用の表形式データ構造)に変換します。 **次のような場合に使用:** ユーザーが Fusion・EPM・Essbase 以外の REST エンドポイント(データ提供先)を持っており、スキーマ(データ構造の定義)を記述した `manifest.url` がある場合 認証は HTTP Basic(ユーザー名とパスワードによるシンプルな認証方式)で行われ、派生プロパティ(計算結果として自動生成される属性)がクエリ(データ取得指示)パラメータを制御します。
Pull data from any REST API into a Spark DataFrame using the AIDP `aidataplatform` Generic REST connector. Use when the user has a non-Fusion / non-EPM / non-Essbase REST endpoint with a `manifest.url` describing the schema. Auth is HTTP Basic with derived properties driving query parameters.
aidp-rest-generic — AIDP aidataplatform 経由の汎用 REST (type=GENERIC_REST)任意の REST API を Spark DataFrame として読み込むコネクタです。 カスタム統合なしにレスポンスをパースできるよう、サーバー側で公開された マニフェスト(各 API エンドポイント・パラメータ・レスポンススキーマを記述した小さな JSON)が必要です。
aidp-fusion-rest を使用。
構造が異なります(マニフェスト不要、ページあたり ≤499 件のページング)。aidp-fusion-bicc を使用。aidp-epm-cloud を使用。aidp-essbase を使用。import os
from oracle_ai_data_platform_connectors.aidataplatform import (
AIDP_FORMAT, aidataplatform_options,
)
opts = aidataplatform_options(
type="GENERIC_REST",
user=os.environ["REST_USER"],
password=os.environ["REST_PASSWORD"],
schema=os.environ.get("REST_SCHEMA", "default"),
extra={
"base.url": os.environ["REST_BASE_URL"], # 例: http://api.internal/v1
"manifest.url": os.environ["REST_MANIFEST_URL"], # 例: http://api.internal/v1/manifest
"auth.type": "basic",
"api": os.environ["REST_API"], # 例: "getOrdersByOrderID"
# derived.property.<name> の値は API 呼び出しに渡されます(複数指定可):
"derived.property.orderNo": os.environ.get("REST_ORDER_NO", "12345"),
},
)
df = spark.read.format(AIDP_FORMAT).options(**opts).load()
df.show(5)
マニフェストには以下の内容を記述します:
apis — 名前付き API オペレーション(例: getOrdersByOrderID)parameters — コネクタが送信すべき内容(パス / クエリ / ボディ)responseSchema — コネクタが推論に使用する Spark スキーママニフェスト URL が用意できない場合、このコネクタは動作しません。
その場合は aidp-fusion-rest の requests ベースのパターンを参照し、対象 API に合わせて適用してください。
それぞれを extra={} の別々のキーとして渡します:
extra={
"base.url": "...",
"manifest.url": "...",
"auth.type": "basic",
"api": "searchOrders",
"derived.property.fromDate": "2025-01-01",
"derived.property.toDate": "2025-12-31",
"derived.property.status": "OPEN",
}
manifest.path)マニフェストが HTTP で配信されるのではなく、AIDP ワークスペースや Volume にアップロードされた静的ファイルである場合は、manifest.url の代わりに manifest.path を使用します。
内容の形式は同じで、取得元だけが異なります。
マニフェストを手動で作成した場合や、ノートブックと並べてバージョン固定で管理したい場合に便利です。
opts = aidataplatform_options(
type="GENERIC_REST",
user=os.environ["REST_USER"],
password=os.environ["REST_PASSWORD"],
schema="default",
extra={
"base.url": os.environ["REST_BASE_URL"],
"manifest.path": "/Volumes/myvol/manifests/orders_api.json",
"auth.type": "basic",
"api": "searchOrders",
"derived.property.status": "OPEN",
},
)
df = spark.read.format(AIDP_FORMAT).options(**opts).load()
指定できるパスの形式:
/Volumes/<catalog>/<schema>/<volume>/path/to/manifest.json(AIDP Volume)/Workspace/Shared/.../manifest.json(ワークスペースファイル — 動作はしますが FUSE 経由のため不安定な場合あり)Volume パスの使用を推奨します。
auth.type=basic のみ対応。 OAuth / API キーヘッダー / mTLS を使用する API には対応していません。その場合は Python の requests を使用してください。schema オプションは、結果として得られる DataFrame の AIDP / Spark 論理スキーマであり、サーバー側のスキーマではありません。不明な場合は default を使用してください。maxPageSize が宣言されている場合、コネクタは自動的にバッチ処理を行います。aidp-rest-generic — Generic REST via AIDP aidataplatform (type=GENERIC_REST)Read from arbitrary REST APIs as a Spark DataFrame. The connector requires a server-published manifest (a small JSON describing each API endpoint, parameters, and response schema) so it knows how to parse responses without a custom integration.
aidp-fusion-rest. Different shape (no manifest; ≤499/page paging).aidp-fusion-bicc.aidp-epm-cloud.aidp-essbase.import os
from oracle_ai_data_platform_connectors.aidataplatform import (
AIDP_FORMAT, aidataplatform_options,
)
opts = aidataplatform_options(
type="GENERIC_REST",
user=os.environ["REST_USER"],
password=os.environ["REST_PASSWORD"],
schema=os.environ.get("REST_SCHEMA", "default"),
extra={
"base.url": os.environ["REST_BASE_URL"], # e.g. http://api.internal/v1
"manifest.url": os.environ["REST_MANIFEST_URL"], # e.g. http://api.internal/v1/manifest
"auth.type": "basic",
"api": os.environ["REST_API"], # e.g. "getOrdersByOrderID"
# Any number of derived.property.<name> values feed into the API call:
"derived.property.orderNo": os.environ.get("REST_ORDER_NO", "12345"),
},
)
df = spark.read.format(AIDP_FORMAT).options(**opts).load()
df.show(5)
The manifest describes:
apis — the named API operations (e.g. getOrdersByOrderID)parameters — what the connector should send (path/query/body)responseSchema — the Spark schema the connector should inferIf you don't have a manifest URL, this connector won't work — fall back to the requests-based pattern in aidp-fusion-rest and adapt for your API.
Pass each as a separate extra={} key:
extra={
"base.url": "...",
"manifest.url": "...",
"auth.type": "basic",
"api": "searchOrders",
"derived.property.fromDate": "2025-01-01",
"derived.property.toDate": "2025-12-31",
"derived.property.status": "OPEN",
}
manifest.path)If the manifest is a static file you've uploaded to your AIDP workspace or a Volume — instead of being served over HTTP — use manifest.path instead of manifest.url. Same shape, different source. Useful when the manifest is hand-authored or version-pinned alongside your notebook.
opts = aidataplatform_options(
type="GENERIC_REST",
user=os.environ["REST_USER"],
password=os.environ["REST_PASSWORD"],
schema="default",
extra={
"base.url": os.environ["REST_BASE_URL"],
"manifest.path": "/Volumes/myvol/manifests/orders_api.json",
"auth.type": "basic",
"api": "searchOrders",
"derived.property.status": "OPEN",
},
)
df = spark.read.format(AIDP_FORMAT).options(**opts).load()
The path can be:
/Volumes/<catalog>/<schema>/<volume>/path/to/manifest.json (AIDP Volume)/Workspace/Shared/.../manifest.json (workspace file — works but FUSE-flaky)Volume paths are the preferred location.
auth.type=basic only. If the API uses OAuth / API key headers / mTLS, this connector won't help — use the Python requests path.schema option is the AIDP/Spark logical schema for the resulting DataFrame, not a server-side one. Use default if unsure.maxPageSize, the connector batches automatically.原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。