Copy-ready code snippets for the most common operations in cURL, Python, and JavaScript.
curl -X POST https://your-domain.com/api/v1/users/register \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "securePassword123"}'curl -X POST https://your-domain.com/api/v1/files/upload \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@/path/to/your/file.pdf"curl https://your-domain.com/api/v1/files/retrieve/bafkreih5... \
-H "X-API-Key: YOUR_API_KEY" \
-o downloaded_file.pdfcurl https://your-domain.com/api/v1/files \
-H "X-API-Key: YOUR_API_KEY"curl -X DELETE https://your-domain.com/api/v1/files/bafkreih5... \
-H "X-API-Key: YOUR_API_KEY"import requests
url = "https://your-domain.com/api/v1/users/register"
payload = {"email": "user@example.com", "password": "securePassword123"}
response = requests.post(url, json=payload)
data = response.json()
print("API Key:", data["data"]["api_key"]) # save this!import requests
url = "https://your-domain.com/api/v1/files/upload"
headers = {"X-API-Key": "YOUR_API_KEY"}
with open("/path/to/file.pdf", "rb") as f:
response = requests.post(url, headers=headers, files={"file": f})
data = response.json()
cid = data["data"]["cid"]
print("CID:", cid)import requests
cid = "bafkreih5..."
url = f"https://your-domain.com/api/v1/files/retrieve/{cid}"
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers)
with open("downloaded_file.pdf", "wb") as f:
f.write(response.content)import requests
url = "https://your-domain.com/api/v1/files"
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers)
files = response.json()["data"]
for file in files:
print(file["cid"], file["original_filename"])import requests
cid = "bafkreih5..."
url = f"https://your-domain.com/api/v1/files/{cid}"
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.delete(url, headers=headers)
print(response.json()["message"])const response = await fetch("https://your-domain.com/api/v1/users/register", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
email: "user@example.com",
password: "securePassword123",
}),
});
const data = await response.json();
const apiKey = data.data.api_key; // save this!
console.log("API Key:", apiKey);const file = document.querySelector('input[type="file"]').files[0];
const formData = new FormData();
formData.append("file", file);
const response = await fetch("https://your-domain.com/api/v1/files/upload", {
method: "POST",
headers: { "X-API-Key": "YOUR_API_KEY" },
body: formData,
});
const data = await response.json();
console.log("CID:", data.data.cid);const cid = "bafkreih5...";
const response = await fetch(
`https://your-domain.com/api/v1/files/retrieve/${cid}`,
{ headers: { "X-API-Key": "YOUR_API_KEY" } },
);
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "downloaded_file";
a.click();const response = await fetch("https://your-domain.com/api/v1/files", {
headers: { "X-API-Key": "YOUR_API_KEY" },
});
const { data } = await response.json();
data.forEach((file) => {
console.log(file.cid, file.original_filename);
});const cid = "bafkreih5...";
const response = await fetch(
`https://your-domain.com/api/v1/files/${cid}`,
{
method: "DELETE",
headers: { "X-API-Key": "YOUR_API_KEY" },
},
);
const data = await response.json();
console.log(data.message);