Get a hug bundle file
Returns one file of a stored hug bundle — its bytes, with its content type, cached for a year
(a bundle never changes: it is named by its hash). Public: a bundle is a hug’s built page and
holds no Hug data. The Hub serves hug pages from its content host at /hb/<sha256>/<path>
through this endpoint.
No authentication: anyone can call this.
POST
/
v1
/
hug_bundles
/
get_file
Get a hug bundle file
curl --request POST \
--url https://{host}/v1/hug_bundles/get_file \
--header 'Content-Type: application/json' \
--data '
{
"sha256": "9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b",
"path": "index.html"
}
'import requests
url = "https://{host}/v1/hug_bundles/get_file"
payload = {
"sha256": "9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b",
"path": "index.html"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
sha256: '9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b',
path: 'index.html'
})
};
fetch('https://{host}/v1/hug_bundles/get_file', 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}/v1/hug_bundles/get_file",
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([
'sha256' => '9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b',
'path' => 'index.html'
]),
CURLOPT_HTTPHEADER => [
"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}/v1/hug_bundles/get_file"
payload := strings.NewReader("{\n \"sha256\": \"9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b\",\n \"path\": \"index.html\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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}/v1/hug_bundles/get_file")
.header("Content-Type", "application/json")
.body("{\n \"sha256\": \"9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b\",\n \"path\": \"index.html\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/v1/hug_bundles/get_file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"sha256\": \"9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b\",\n \"path\": \"index.html\"\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"data": "<!doctype html><html>…</html>"
}{
"ok": false,
"error": "Bundle file not found",
"code": "not_found"
}{
"ok": false,
"error": "sha256: Required",
"code": "invalid_params"
}{
"ok": false,
"error": "Internal server error",
"code": "internal_error"
}⌘I
Get a hug bundle file
curl --request POST \
--url https://{host}/v1/hug_bundles/get_file \
--header 'Content-Type: application/json' \
--data '
{
"sha256": "9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b",
"path": "index.html"
}
'import requests
url = "https://{host}/v1/hug_bundles/get_file"
payload = {
"sha256": "9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b",
"path": "index.html"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
sha256: '9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b',
path: 'index.html'
})
};
fetch('https://{host}/v1/hug_bundles/get_file', 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}/v1/hug_bundles/get_file",
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([
'sha256' => '9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b',
'path' => 'index.html'
]),
CURLOPT_HTTPHEADER => [
"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}/v1/hug_bundles/get_file"
payload := strings.NewReader("{\n \"sha256\": \"9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b\",\n \"path\": \"index.html\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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}/v1/hug_bundles/get_file")
.header("Content-Type", "application/json")
.body("{\n \"sha256\": \"9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b\",\n \"path\": \"index.html\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/v1/hug_bundles/get_file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"sha256\": \"9f2c4e1a7b3d5f6e8a0c2e4f6a8b0d2c4e6f8a0b2c4d6e8f0a1b3c5d7e9f1a2b\",\n \"path\": \"index.html\"\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"data": "<!doctype html><html>…</html>"
}{
"ok": false,
"error": "Bundle file not found",
"code": "not_found"
}{
"ok": false,
"error": "sha256: Required",
"code": "invalid_params"
}{
"ok": false,
"error": "Internal server error",
"code": "internal_error"
}