curl --request POST \
--url https://{host}/api/datasets/imports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ref": "<string>",
"name": "<string>",
"owner": ""
}
'import requests
url = "https://{host}/api/datasets/imports"
payload = {
"ref": "<string>",
"name": "<string>",
"owner": ""
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({ref: '<string>', name: '<string>', owner: ''})
};
fetch('https://{host}/api/datasets/imports', 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://{host}/api/datasets/imports",
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([
'ref' => '<string>',
'name' => '<string>',
'owner' => ''
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://{host}/api/datasets/imports"
payload := strings.NewReader("{\n \"ref\": \"<string>\",\n \"name\": \"<string>\",\n \"owner\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://{host}/api/datasets/imports")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ref\": \"<string>\",\n \"name\": \"<string>\",\n \"owner\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/datasets/imports")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ref\": \"<string>\",\n \"name\": \"<string>\",\n \"owner\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"hub": "<string>",
"kind": "<string>",
"repo_id": "<string>",
"ref": "<string>",
"dataset": "<string>",
"dest_owner": "<string>",
"dest_name": "<string>",
"status": "<string>",
"requested_by": "<string>",
"revision": "",
"resolved": "",
"dest_version": "",
"files": 0,
"bytes": 0,
"error": "",
"created_at": "<string>",
"started_at": "<string>",
"finished_at": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Queue a copy of an external repository into the dataset registry.
Accepted, not performed: an import is minutes to hours of downloading, and holding the request open for it would lose the work on any restart. The refusals that a requester can act on — a forbidden hub, a destination they may not write, no object storage — happen here rather than in a worker.
curl --request POST \
--url https://{host}/api/datasets/imports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ref": "<string>",
"name": "<string>",
"owner": ""
}
'import requests
url = "https://{host}/api/datasets/imports"
payload = {
"ref": "<string>",
"name": "<string>",
"owner": ""
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({ref: '<string>', name: '<string>', owner: ''})
};
fetch('https://{host}/api/datasets/imports', 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://{host}/api/datasets/imports",
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([
'ref' => '<string>',
'name' => '<string>',
'owner' => ''
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://{host}/api/datasets/imports"
payload := strings.NewReader("{\n \"ref\": \"<string>\",\n \"name\": \"<string>\",\n \"owner\": \"\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://{host}/api/datasets/imports")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ref\": \"<string>\",\n \"name\": \"<string>\",\n \"owner\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/datasets/imports")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ref\": \"<string>\",\n \"name\": \"<string>\",\n \"owner\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"hub": "<string>",
"kind": "<string>",
"repo_id": "<string>",
"ref": "<string>",
"dataset": "<string>",
"dest_owner": "<string>",
"dest_name": "<string>",
"status": "<string>",
"requested_by": "<string>",
"revision": "",
"resolved": "",
"dest_version": "",
"files": 0,
"bytes": 0,
"error": "",
"created_at": "<string>",
"started_at": "<string>",
"finished_at": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
Which repository to copy, and where to put it.
The repository, as hf:namespace/name[@revision] or ms:namespace/name[@revision]. A reference with no hub prefix names a platform dataset and is refused -- there is nothing to import.
Destination dataset name.
Destination owner. Defaults to the requester; writing under somebody else's namespace follows the registry's own rule.
响应
Successful Response