Create data source without specifying a dataset
curl --request POST \
--url https://app.ai.relyt.cn/app/api/v2/team/datasources \
--header 'Content-Type: application/json' \
--header 'x-pd-api-key: <api-key>' \
--data '
{
"name": "test.csv",
"type": "FILE",
"user_id": "tmm-dafasdfasdfasdf",
"file_object_key": "/tmp/sdgsagdsgsadgasdg"
}
'import requests
url = "https://app.ai.relyt.cn/app/api/v2/team/datasources"
payload = {
"name": "test.csv",
"type": "FILE",
"user_id": "tmm-dafasdfasdfasdf",
"file_object_key": "/tmp/sdgsagdsgsadgasdg"
}
headers = {
"x-pd-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-pd-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'test.csv',
type: 'FILE',
user_id: 'tmm-dafasdfasdfasdf',
file_object_key: '/tmp/sdgsagdsgsadgasdg'
})
};
fetch('https://app.ai.relyt.cn/app/api/v2/team/datasources', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.ai.relyt.cn/app/api/v2/team/datasources",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'test.csv',
'type' => 'FILE',
'user_id' => 'tmm-dafasdfasdfasdf',
'file_object_key' => '/tmp/sdgsagdsgsadgasdg'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-pd-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.ai.relyt.cn/app/api/v2/team/datasources"
payload := strings.NewReader("{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-pd-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.ai.relyt.cn/app/api/v2/team/datasources")
.header("x-pd-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.ai.relyt.cn/app/api/v2/team/datasources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-pd-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"data": {
"id": "datasource-cadsgfsdagasgadsg",
"dataset_id": "dataset-dagasdgasgasg",
"name": "test.csv",
"type": "FILE",
"status": "synching"
}
}数据源
Create data source without specifying a dataset
该接口用于在不指定数据集的情况下,直接创建数据源。
调用此接口时,Relyt AI 会自动为该数据源创建一个数据集。请保存返回中的数据集 ID,便于后续操作,如 关联数据集至任务 进行数据分析与探索。
POST
/
v2
/
team
/
datasources
Create data source without specifying a dataset
curl --request POST \
--url https://app.ai.relyt.cn/app/api/v2/team/datasources \
--header 'Content-Type: application/json' \
--header 'x-pd-api-key: <api-key>' \
--data '
{
"name": "test.csv",
"type": "FILE",
"user_id": "tmm-dafasdfasdfasdf",
"file_object_key": "/tmp/sdgsagdsgsadgasdg"
}
'import requests
url = "https://app.ai.relyt.cn/app/api/v2/team/datasources"
payload = {
"name": "test.csv",
"type": "FILE",
"user_id": "tmm-dafasdfasdfasdf",
"file_object_key": "/tmp/sdgsagdsgsadgasdg"
}
headers = {
"x-pd-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-pd-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'test.csv',
type: 'FILE',
user_id: 'tmm-dafasdfasdfasdf',
file_object_key: '/tmp/sdgsagdsgsadgasdg'
})
};
fetch('https://app.ai.relyt.cn/app/api/v2/team/datasources', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.ai.relyt.cn/app/api/v2/team/datasources",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'test.csv',
'type' => 'FILE',
'user_id' => 'tmm-dafasdfasdfasdf',
'file_object_key' => '/tmp/sdgsagdsgsadgasdg'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-pd-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.ai.relyt.cn/app/api/v2/team/datasources"
payload := strings.NewReader("{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-pd-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.ai.relyt.cn/app/api/v2/team/datasources")
.header("x-pd-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.ai.relyt.cn/app/api/v2/team/datasources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-pd-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"test.csv\",\n \"type\": \"FILE\",\n \"user_id\": \"tmm-dafasdfasdfasdf\",\n \"file_object_key\": \"/tmp/sdgsagdsgsadgasdg\"\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"data": {
"id": "datasource-cadsgfsdagasgadsg",
"dataset_id": "dataset-dagasdgasgasg",
"name": "test.csv",
"type": "FILE",
"status": "synching"
}
}Authorizations
Headers
您本地系统中设置的 Trace ID,至多支持 128 个字符。当请求发生错误时,可以将此 ID 提供给 Relyt AI 团队,协助进行故障排查。
Body
application/json
数据源名称,需包含文件扩展名(例如 example.csv),至多可支持 128 个字符。如超过此限制,名称将被截断展示。
数据源的类型。设置为 FILE。
用户 ID,即您在组织中的唯一身份标识。
文件 URL,用于公网访问该文件。
url 和 file_object_key 之间必须且只能指定其一。
仅支持以下扩展名的文件:.csv、.tsv、.md、.mdx、.json、.txt、.pdf、.pptx、.docx、.xls 或 .xlsx。
您本地上传文件的对象存储路径。
url 和 file_object_key 之间必须且只能指定其一。
支持的文件扩展名包括:.csv、.tsv、.md、.mdx、.json、.txt、.pdf、.pptx、.docx、.xls 或 .xlsx。
如何获取文件的 file_object_key:
当使用 Upload file 接口完成文件上传后,会返回该文件的file_object_key。
⌘I