🖥️

For Developers

POST data

Here are some PUT data examples of how to use Python, cURL, and Golang to interact with the provided API endpoints:
cURL
Python
Golang
curl -X POST 'http://localhost:50000/v0/blob' \
--data-binary @your_data_file \
-H 'Content-Type: application/octet-stream'
import requests
url = 'http://localhost:50000/v0/blob'
data = b'Your binary data here'
response = requests.post(url, data=data, headers={'Content-Type': 'application/octet-stream'})
if response.status_code == 201:
print("Data successfully created. Blob ID:", response.json()['id'])
else:
print("Error:", response.status_code)
package main
import (
"bytes"
"fmt"
"net/http"
)
func main() {
url := "http://localhost:50000/v0/blob"
data := []byte("Your binary data here")
resp, err := http.Post(url, "application/octet-stream", bytes.NewReader(data))
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
if resp.StatusCode == 201 {
fmt.Println("Data successfully created. Blob ID:", resp.Header.Get("id"))
} else {
fmt.Println("Error:", resp.Status)
}
}
Please note that you'll need to replace 'unique-blob-id' and 'your_data_file' with actual values or data when making requests with cURL or the provided code samples.

GET data

Here are some GET data examples of how to use Python, cURL, and Golang to interact with the provided API endpoints:
cURL
Python
Golang
curl -o downloaded_data.bin 'http://localhost:50000/v0/blob/unique-blob-id'
import requests
blob_id = 'unique-blob-id'
url = f'http://localhost:50000/v0/blob/{blob_id}'
response = requests.get(url)
if response.status_code == 200:
# Handle the binary data in response.content
with open('downloaded_data.bin', 'wb') as file:
file.write(response.content)
else:
print("Error:", response.status_code)
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
blobID := "unique-blob-id"
url := fmt.Sprintf("http://localhost:50000/v0/blob/%s", blobID)
resp, err := http.Get(url)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error:", err)
return
}
err = ioutil.WriteFile("downloaded_data.bin", data, 0644)
if err != nil {
fmt.Println("Error:", err)
return
}
} else {
fmt.Println("Error:", resp.Status)
}
}
Please note that you'll need to replace 'unique-blob-id' and 'your_data_file' with actual values or data when making requests with cURL or the provided code samples.

STATUS

Here are some STATUS examples of how to use Python, cURL, and Golang to interact with the provided API endpoints:
cURL
Python
Golang
curl 'http://localhost:50000/v0/blob/unique-blob-id/status'
import requests
url = 'http://localhost:50000/v0/blob'
data = b'Your binary data here'
response = requests.post(url, data=data, headers={'Content-Type': 'application/octet-stream'})
if response.status_code == 201:
print("Data successfully created. Blob ID:", response.json()['id'])
else:
print("Error:", response.status_code)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
blobID := "unique-blob-id"
url := fmt.Sprintf("http://localhost:50000/v0/blob/%s/status", blobID)
resp, err := http.Get(url)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
var statusData map[string]interface{}
err := json.NewDecoder(resp.Body).Decode(&statusData)
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println("Blob ID:", statusData["id"])
replicas := statusData["replicas"].([]interface{})
for _, replica := range replicas {
replicaData := replica.(map[string]interface{})
fmt.Println("Provider:", replicaData["provider"])
fmt.Println("Status:", replicaData["status"])
fmt.Println("Last Verified:", replicaData["lastVerified"])
fmt.Println("Expiration:", replicaData["expiration"])
}
} else {
fmt.Println("Error:", resp.Status)
}
}
Please note that you'll need to replace 'unique-blob-id' and 'your_data_file' with actual values or data when making requests with cURL or the provided code samples.