Apache Iceberg REST catalog API
The MaxCompute Iceberg REST Catalog provides a query interface compatible with the Apache Iceberg REST Catalog. This interface lets you discover service capabilities, query MaxCompute schema, read metadata for Iceberg tables (beta), and retrieve storage credentials. The current interface version is v1alpha and includes eight API operations: configuration discovery, namespace query, table query, and storage credential retrieval.
For the complete API documentation and spec, see the Apache Iceberg REST Catalog Spec.
API
The service endpoint is available only in the China (Shanghai) region. All projects, regardless of their region, must use this endpoint.
Request URIs are relative to this service endpoint.
project_idis the MaxCompute project name.namespaceis the MaxCompute schema name. Only single-level namespaces are supported.
The service endpoint for the China (Shanghai) region is as follows:
https://catalogapi.cn-shanghai.maxcompute.aliyun-inc.com/api/iceberg/v1alpha/restcatalogAPI overview
API | HTTP method | URI | Permissions |
GetConfig | GET |
| No MaxCompute resource permission required. |
ListNamespaces | GET |
| project-level |
GetNamespace | GET |
| schema-level |
NamespaceExists | HEAD |
| project-level |
ListTables | GET |
| schema-level or project-level |
LoadTable | GET |
| table-level |
TableExists | HEAD |
| schema-level or project-level |
GetTableCredentials | GET |
| table-level |
The endpoints field in the GetConfig response specifies the supported data operations.
API list
GetConfig - Get catalog configuration
Retrieves the catalog configuration specified by the server. The Iceberg REST client should call this API first to obtain defaults, overrides, and the endpoints supported by the server.
Authorization
No MaxCompute resource permission is required.
Request syntax
GET /v1/config?warehouse=projects/my_project HTTP/1.1Request parameters
Parameter | Location | Type | Required | Description | Example value |
warehouse | Query | string | Yes | The warehouse identifier must be |
|
Response parameters
Parameter | Type | Description | Example value |
defaults | object | Default properties that apply if the client does not explicitly configure them. |
|
overrides | object | The server properties that override the client configuration, including |
|
endpoints | array[string] | A data operation supported by the server is in the format |
|
Success response example
{
"defaults": {
"format-version": "2"
},
"overrides": {
"prefix": "projects/my_project",
"warehouse": "projects/my_project"
},
"endpoints": [
"GET /v1/{prefix}/namespaces",
"GET /v1/{prefix}/namespaces/{namespace}",
"HEAD /v1/{prefix}/namespaces/{namespace}",
"GET /v1/{prefix}/namespaces/{namespace}/tables",
"GET /v1/{prefix}/namespaces/{namespace}/tables/{table}",
"HEAD /v1/{prefix}/namespaces/{namespace}/tables/{table}",
"GET /v1/{prefix}/namespaces/{namespace}/tables/{table}/credentials"
]
}ListNamespaces
Lists the single-level namespaces (which are MaxCompute schemas) in a project.
Authorization
You must have the project-level List permission. For details on granting permissions, see Manage user permissions by using commands or Manage user permissions by using the console.
Request syntax
GET /v1/projects/{project_id}/namespaces?pageToken={pageToken}&pageSize={pageSize} HTTP/1.1Request parameters
Parameter | Location | Type | Required | Description | Example value |
project_id | Path | string | Yes | The name of the MaxCompute project. |
|
pageToken | Query | string | No | An opaque pagination token. Leave this parameter empty for the first request. For subsequent requests, use the |
|
pageSize | Query | integer | No | The maximum number of results to return per page. This value must be greater than 0. |
|
Response parameters
Parameter | Type | Description | Example value |
namespaces | array[array[string]] | A list of namespaces. Each namespace is an array that contains a single schema name. |
|
next-page-token | string | A token for retrieving the next page of results. If this parameter is absent from the response, all results have been returned. |
|
Successful response
{
"namespaces": [
["schema_a"],
["schema_b"]
],
"next-page-token": "schema_b!"
}GetNamespace - Get namespace metadata
Retrieves the identifier and properties of a specified namespace.
Permissions
To grant permissions, see Manage user permissions by using commands or Manage user permissions by using the console.
Request syntax
GET /v1/projects/{project_id}/namespaces/{namespace} HTTP/1.1Request parameters
Parameter | In | Type | Required | Description | Example value |
project_id | Path | string | Yes | The name of the MaxCompute project. |
|
namespace | Path | string | Yes | The name of the schema, which functions as a single-level namespace. |
|
Response parameters
Parameter | Type | Description | Example value |
namespace | array[string] | The namespace identifier, an array that contains a single schema name. |
|
properties | object | The properties of the namespace. This object may be empty. |
|
Success response
{
"namespace": ["schema_a"],
"properties": {}
}NamespaceExists
Checks if the specified namespace exists. The response body is empty.
Permissions
This operation requires the project-level List permission. For more information, see Manage user permissions by using commands or Manage user permissions by using the console.
Request syntax
HEAD /v1/projects/{project_id}/namespaces/{namespace} HTTP/1.1Request parameters
Parameter | Position | Type | Required | Description | Example |
project_id | Path | string | Yes | The name of the MaxCompute project. |
|
namespace | Path | string | Yes | The name of the schema, which is a single-level namespace. |
|
Response parameters
The response body is empty.
Success response example
HTTP/1.1 204 No ContentListTables
Lists managed Iceberg tables in a specified namespace.
Permissions
This operation requires the List permission. If your project supports a schema layer, this permission is required at the schema level. Otherwise, it is required at the project level. To learn how to grant permissions, see Manage user permissions by using commands or Manage user permissions by using the console.
Request syntax
GET /v1/projects/{project_id}/namespaces/{namespace}/tables?pageToken={pageToken}&pageSize={pageSize} HTTP/1.1Request parameters
Parameter | Location | Type | Required | Description | Sample value |
project_id | Path | string | Yes | The name of the MaxCompute project. |
|
namespace | Path | string | Yes | The name of the schema. For projects without a schema layer, you must use the default schema. |
|
pageToken | Query | string | No | An opaque pagination token. |
|
pageSize | Query | integer | No | The maximum number of results to return per page. The value must be greater than 0. |
|
Response parameters
Parameter | Parent | Type | Description | Sample value |
identifiers | Top level |
| A list of table identifiers. Each element represents a table. | See the example below. |
namespace | identifiers element |
| The schema (namespace) to which the table belongs. MaxCompute supports only single-level namespaces, so this array contains only one value. |
|
name | identifiers element |
| The table name. |
|
next-page-token | Top level |
| The token for the next page of results. If this field is not returned, you have reached the last page. |
|
Example response
{
"identifiers": [
{"namespace": ["schema_a"], "name": "table_1"},
{"namespace": ["schema_a"], "name": "table_2"}
],
"next-page-token": "table_2!"
}LoadTable
Retrieves the complete metadata for an Iceberg table, including the metadata file location, table-level configuration, and available storage access credentials.
Permissions
This operation requires table-level Describe and Select permissions. For details on granting permissions, see Manage User Permissions by Using Commands or Manage User Permissions by Using the Console.
This operation also requires the Use permission for the connection. For more information, see Grant Permissions on a Connection.
Request syntax
GET /v1/projects/{project_id}/namespaces/{namespace}/tables/{table} HTTP/1.1Request parameters
Parameter | Location | Type | Required | Description | Example |
project_id | Path | string | Yes | The name of the MaxCompute project. |
|
namespace | Path | string | Yes | The name of the schema. For projects that do not have a schema layer, you must use the default schema. |
|
table | Path | string | Yes | The name of the table. |
|
Response parameters
Parameter | Level | Type | Description | Example |
metadata-location | Top-level |
| The location of the Iceberg table metadata JSON file. This value can be null. |
|
metadata | Top-level |
| This object follows the Iceberg metadata JSON format. | See the example below. |
config | Top-level |
| Table-level client configuration. This can include S3-compatible settings. |
|
storage-credentials | Top-level |
| A list of storage access credentials. | See the example below. |
prefix | storage-credentials element |
| The storage path prefix to which the credential applies. If multiple credentials match a path, the system selects the one with the longest prefix. |
|
config | storage-credentials element |
| Configuration for the credential, including details such as the access key, secret, session token, and expiration time. | See the example below. |
Success response example
The credentials in the following example are placeholders.
{
"metadata-location": "oss://bucket/path/metadata/00001.metadata.json",
"metadata": {
"format-version": 2,
"table-uuid": "2f1d1d1e-1111-4444-8888-123456789abc",
"location": "oss://bucket/path",
"last-updated-ms": 1784275200000,
"current-schema-id": 0,
"schemas": [{"type": "struct", "schema-id": 0, "fields": [ ]}],
"properties": {}
},
"config": {
"s3.access-key-id": "AKIDEXAMPLE",
"s3.secret-access-key": "SECRETEXAMPLE",
"s3.session-token": "TOKENEXAMPLE",
"s3.session-token-expires-at-ms": "1784318400000"
},
"storage-credentials": [{
"prefix": "oss://bucket/path",
"config": {
"s3.access-key-id": "AKIDEXAMPLE",
"s3.secret-access-key": "SECRETEXAMPLE",
"s3.session-token": "TOKENEXAMPLE",
"s3.session-token-expires-at-ms": "1784318400000"
}
}]
}TableExists
Checks if a specified table exists and is visible to the REST Catalog. The response body is empty.
Permissions
For projects that support schemas, schema-level List permission is required. Otherwise, project-level List permission is required. To grant permissions, see Manage user permissions by using commands or Manage user permissions in the MaxCompute console.
Request syntax
HEAD /v1/projects/{project_id}/namespaces/{namespace}/tables/{table} HTTP/1.1Request parameters
Parameter | Location | Type | Required | Description | Example |
project_id | Path | string | Yes | The name of the MaxCompute project. |
|
namespace | Path | string | Yes | The schema name. For projects that do not support schemas, you must use the default schema. |
|
table | Path | string | Yes | The table name. |
|
Response parameters
The response body is empty.
Success response example
HTTP/1.1 204 No ContentGetTableCredentials
Retrieves the credentials to access a specified table storage location.
Authorization
This operation requires the table-level Describe and Select permissions. To grant these permissions, see Manage User Permissions by Using Commands or Manage User Permissions by Using the console.
This operation also requires the Use permission on the connection. For more information, see Grant Permissions on a Connection.
Request syntax
GET /v1/projects/{project_id}/namespaces/{namespace}/tables/{table}/credentials HTTP/1.1Request parameters
Parameter | Location | Type | Required | Description | Example |
project_id | Path | string | Yes | The name of the MaxCompute project. |
|
namespace | Path | string | Yes | The schema name. For projects with a two-level model, you must use the default schema. |
|
table | Path | string | Yes | The table name. |
|
Response parameters
Parameter | Parent | Type | Description | Example |
storage-credentials | Top level |
| A list of storage credentials. Returns an empty array if no credentials are available. | See the example below. |
prefix | storage-credentials element |
| The storage path prefix that the credential applies to. |
|
config | storage-credentials element |
| S3-compatible credential configuration. | See the example below. |
s3.access-key-id | config field |
| The AccessKey ID. |
|
s3.secret-access-key | config field |
| The AccessKey Secret. |
|
s3.session-token | config field |
| The STS session token. This parameter is omitted when using static Access Keys. |
|
s3.session-token-expires-at-ms | config field |
| The expiration time of the STS credential, as a Unix timestamp in milliseconds. This parameter is omitted when using static Access Keys. |
|
Successful response example
The credentials in the following example are placeholders.
{
"storage-credentials": [{
"prefix": "oss://bucket/path",
"config": {
"s3.access-key-id": "AKIDEXAMPLE",
"s3.secret-access-key": "SECRETEXAMPLE",
"s3.session-token": "TOKENEXAMPLE",
"s3.session-token-expires-at-ms": "1784318400000"
}
}]
}Usage examples
Postman example
Enter the request URL. This example uses the China (Shanghai) region.
https://catalogapi.cn-shanghai.maxcompute.aliyun-inc.com/api/iceberg/v1alpha/restcatalogConfigure the pre-request script.
We recommend that you use STS temporary credentials to avoid leaking your AccessKey pair.
// ODPS standard signature Pre-request Script (supports STS temporary credentials) // Long-term AK: ODPS_AK_ID, ODPS_AK_SECRET // STS temporary credentials: ODPS_AK_ID, ODPS_AK_SECRET (temporary), ODPS_STS_TOKEN const accessKeyId = pm.environment.get("ODPS_AK_ID"); const accessKeySecret = pm.environment.get("ODPS_AK_SECRET"); const stsToken = pm.environment.get("ODPS_STS_TOKEN"); // leave empty / unset if not used const method = pm.request.method; // GET / HEAD const contentType = ""; // empty when there is no body const contentMD5 = ""; // empty when there is no body const date = new Date().toUTCString(); // GMT, e.g. "Wed, 15 Jul 2026 06:00:00 GMT" // CanonicalizedResource: path + query sorted by parameter name const url = pm.request.url; let resource = "/" + url.getPath().replace(/^\/+/, ""); const params = (url.query && url.query.all() ? url.query.all() : []) .filter(p => p && p.key && !p.disabled) .map(p => [p.key, p.value == null ? "" : p.value]) .sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0); if (params.length) { resource += "?" + params.map(([k, v]) => v === "" ? k : `${k}=${v}`).join("&"); } // StringToSign (CanonicalizedHeaders is empty when there are no x-odps- headers) const stringToSign = method + "\n" + contentMD5 + "\n" + contentType + "\n" + date + "\n" + resource; const signature = CryptoJS.HmacSHA1(stringToSign, accessKeySecret) .toString(CryptoJS.enc.Base64); pm.request.headers.upsert({ key: "Date", value: date }); pm.request.headers.upsert({ key: "Authorization", value: "ODPS " + accessKeyId + ":" + signature }); // STS temporary credentials: attach the SecurityToken header; skipped automatically // when the variable is empty (long-term AK mode) if (stsToken) { pm.request.headers.upsert({ key: "authorization-sts-token", value: stsToken }); } else { pm.request.headers.remove("authorization-sts-token"); }Confirm your current environment settings.
Spark example
This section shows how to use the REST Catalog API to access data and metadata from MaxCompute-managed Iceberg tables in a Spark environment. The process is fully compatible with open-source standards.
Prerequisites
Ensure that your project has been approved for the beta trial and you can use Iceberg tables managed by MaxCompute (beta).
Upload the following JAR files to your Spark environment:
iceberg-odps-1.12.0-SNAPSHOT.jar
This file contains the OdpsAuthManager implementation and must be uploaded.
iceberg-spark-runtime-3.5_2.12-1.10.1.jar
This file contains all dependencies required for Iceberg to run on Spark. If your environment already includes this JAR file, you can skip this upload.
This file contains the dependencies required for Iceberg to interact with S3- and OSS-compatible services. If your environment already includes this JAR file, you can skip this upload.
Upgrade your Spark 3 service to JDK 17. If you use an E-MapReduce (EMR) instance, follow the instructions in Use JDK 11 with Spark 3, but replace java-11 with java-17 in the commands.
Configure and start spark-sql
The following command starts spark-sql. Run it on your Spark client node, such as the master node of an EMR cluster or a local environment with Spark configured.
Start spark-sql
export AWS_REGION=cn-shanghai
spark-sql \
--jars /root/iceberg/iceberg-spark-runtime-3.5_2.12-1.10.1.jar,/root/iceberg/iceberg-aws-bundle-1.10.1.jar,/root/iceberg/iceberg-odps-1.12.0-SNAPSHOT.jar \
--conf spark.driver.extraClassPath=/root/iceberg/* \
--conf spark.executor.extraClassPath=/root/iceberg/* \
--conf spark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions \
--conf spark.sql.catalog.odps=org.apache.iceberg.spark.SparkCatalog \
--conf spark.sql.catalog.odps.catalog-impl=org.apache.iceberg.rest.RESTCatalog \
--conf spark.sql.catalog.odps.uri=https://catalogapi.cn-shanghai.maxcompute.aliyun-inc.com/api/iceberg/v1alpha/restcatalog/ \
--conf spark.sql.catalog.odps.warehouse=projects/project_name \
--conf spark.sql.catalog.odps.io-impl=org.apache.iceberg.aws.s3.S3FileIO \
--conf spark.sql.catalog.odps.rest.auth.type=org.apache.iceberg.odps.auth.OdpsAuthManager \
--conf spark.sql.catalog.odps.odps.auth.access-key-id=<your_access_key_id> \
--conf spark.sql.catalog.odps.odps.auth.access-key-secret=<your_access_key_secret> \
--conf spark.sql.catalog.odps.s3.endpoint=https://oss-cn-shanghai.aliyuncs.com \
--conf spark.sql.catalog.odps.client.region=cn-shanghai \
--conf spark.sql.catalogImplementation=in-memory \
--conf spark.hadoop.javax.jdo.option.ConnectionURL="jdbc:derby:/tmp/metastore_db;create=true"Run spark-sql
After you start spark-sql, use the appropriate syntax to access MaxCompute Iceberg tables based on whether your project has schema-level hierarchy enabled.
Projects with schema-level hierarchy
When schema-level hierarchy is enabled, a project supports a table-schema-project hierarchy and schema-related operations. The schema level maps to the namespace level of the Iceberg catalog. The REST Catalog API uses the catalog.namespace.table syntax. For more information, see Schema operations.
List the namespaces in the project. This syntax is supported only for projects with schema-level hierarchy enabled.
show namespaces in odps;List the tables in a namespace.
-- List tables in the 'default' namespace. show tables in odps.default; -- List tables in the 'test01' namespace. Replace 'test01' with another schema name. show tables in odps.test01;Query a table in a namespace.
-- Query a table in the 'default' namespace. select * from odps.default.table_name; -- Query a table in the 'test01' namespace. Replace 'test01' with another schema name. select * from odps.test01.table_name;View table details.
-- View details for a table in the 'default' namespace. desc odps.default.table_name; -- View details for a table in the 'test01' namespace. Replace 'test01' with another schema name. desc odps.test01.table_name;
Projects without schema-level hierarchy
If a project does not have schema-level hierarchy enabled, it supports a table-project hierarchy, and schema-related operations are not supported. The REST Catalog API uses the project.default.table syntax. For more information, see Schema operations.
List the tables in a namespace.
show tables in odps.default;Query a table in a namespace.
select * from odps.default.table_name;View table details.
desc odps.default.table_name;
Usage example
The following example demonstrates the complete process using an EMR cluster, a RAM role, and a project that supports schema-level hierarchy.
Prepare data
Create a connection
Log in to the MaxCompute console and select a region in the upper-left corner.
In the left-side navigation pane, choose .
On the Data Lake Connection (CONNECTION) page, click Create Data Lake Connection.
In the Create Data Lake Connection dialog box, configure the parameters and click OK.
Parameter
Description
Data lake connection parameter
The name of the data lake connection. The name must be unique within the tenant.
RAMRoleARN
The ARN of a RAM role that has permissions to access OSS.
You can also create a custom role and specify its RAM role ARN. For more information, see Authorization for accessing external data sources.
Data lake connection description
A description of the data lake connection.
On the Data Lake Connection (CONNECTION) page, in the Operation column for the desired CONNECTION, click Add Authorization.
In the Data Lake Connection Authorization dialog box, add the users you want to authorize and click OK.
Create a managed Iceberg table and write test data
Create a MaxCompute-managed Iceberg table and insert test data into it.
SET odps.namespace.schema=true; CREATE ICEBERG TABLE default.mc_iceberg_table_rest_catalog ( emp_id BIGINT COMMENT 'Employee ID', emp_name STRING COMMENT 'Employee Name', department STRING COMMENT 'Department', salary DOUBLE COMMENT 'Salary', hire_date DATE COMMENT 'Hire Date', ds STRING COMMENT 'Partition Date' ) PARTITIONED BY (ds) WITH CONNECTION <YOUR CONNECTION> OPTIONS( location='oss://<oss bucket>/rest_catalog/' ); -- Write data to the table. SET odps.namespace.schema=true; INSERT INTO TABLE default.mc_iceberg_table_rest_catalog VALUES (1001, 'Alice', 'Tech', 15000.00, date '2020-03-15','2024-01-01'); INSERT INTO TABLE default.mc_iceberg_table_rest_catalog VALUES (1002, 'Bob', 'Tech', 18000.00, date '2019-07-22','2024-01-01'); INSERT INTO TABLE default.mc_iceberg_table_rest_catalog VALUES (1003, 'Charlie', 'Product', 16000.00, date '2021-01-10','2024-01-01'); -- Confirm that you can read the table by using SQL. SET odps.namespace.schema=true; SELECT * FROM default.mc_iceberg_table_rest_catalog; +------------+------------+------------+------------+------------+------------+ | emp_id | emp_name | department | salary | hire_date | ds | +------------+------------+------------+------------+------------+------------+ | 1003 | Charlie | Product | 16000.0 | 2021-01-10 | 2024-01-01 | | 1001 | Alice | Tech | 15000.0 | 2020-03-15 | 2024-01-01 | | 1002 | Bob | Tech | 18000.0 | 2019-07-22 | 2024-01-01 | +------------+------------+------------+------------+------------+------------+
Start spark-sql
The following command starts spark-sql on an EMR cluster with VPC internal network access. It is configured to use a RAM role to access a MaxCompute project where schema-level hierarchy is enabled. If you are using a RAM user, remove the spark.sql.catalog.odps.odps.auth.sts-token parameter.
export AWS_REGION=cn-shanghai
spark-sql \
--jars /root/iceberg/iceberg-spark-runtime-3.5_2.12-1.10.1.jar,/root/iceberg/iceberg-aws-bundle-1.10.1.jar,/root/iceberg/iceberg-odps-1.12.0-SNAPSHOT.jar \
--conf spark.driver.extraClassPath=/root/iceberg/* \
--conf spark.executor.extraClassPath=/root/iceberg/* \
--conf spark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions \
--conf spark.sql.catalog.odps=org.apache.iceberg.spark.SparkCatalog \
--conf spark.sql.catalog.odps.catalog-impl=org.apache.iceberg.rest.RESTCatalog \
--conf spark.sql.catalog.odps.uri=https://catalogapi.cn-shanghai-vpc.maxcompute.aliyun-inc.com/api/iceberg/v1alpha/restcatalog/ \
--conf spark.sql.catalog.odps.warehouse=projects/<projectname> \
--conf spark.sql.catalog.odps.io-impl=org.apache.iceberg.aws.s3.S3FileIO \
--conf spark.sql.catalog.odps.rest.auth.type=org.apache.iceberg.odps.auth.OdpsAuthManager \
--conf spark.sql.catalog.odps.odps.auth.access-key-id=STS.*** \
--conf spark.sql.catalog.odps.odps.auth.access-key-secret=*** \
--conf spark.sql.catalog.odps.odps.auth.sts-token=*** \
--conf spark.sql.catalog.odps.s3.endpoint=https://oss-cn-shanghai-internal.aliyuncs.com \
--conf spark.sql.catalog.odps.client.region=cn-shanghai \
--conf spark.sql.catalogImplementation=in-memory \
--conf spark.hadoop.javax.jdo.option.ConnectionURL="jdbc:derby:/tmp/metastore_db;create=true"Run spark-sql queries
List the namespaces in the project.
spark-sql (default)> show namespaces in odps; default test01 Time taken: 1.676 seconds, Fetched 2 row(s)List the tables in a namespace.
spark-sql (default)> show tables in odps.default; mc_iceberg_table_test1 mc_iceberg_table_test2 mc_iceberg_table_test3 mc_iceberg_table_rest_catalog Time taken: 0.276 seconds, Fetched 4 row(s)Query a table in a namespace.
spark-sql (default)> select * from odps.default.mc_iceberg_table_rest_catalog; 1003 Charlie Product 16000.0 2021-01-10 2024-01-01 1002 Bob Tech 18000.0 2019-07-22 2024-01-01 1001 Alice Tech 15000.0 2020-03-15 2024-01-01 Time taken: 5.403 seconds, Fetched 3 row(s)View table details.
spark-sql (default)> desc odps.test01.mc_iceberg_table_rest_catalog; emp_id bigint Employee ID emp_name string Employee Name department string Department salary double Salary hire_date date Hire Date ds string Partition Date # Partition Information # col_name data_type comment ds string Partition Date Time taken: 0.78 seconds, Fetched 9 row(s)