STACKIT IaaS API - Correct API Structure
Key Discovery from the Guide:
The API endpoints require the project ID in the path:
https://iaas.api.eu01.stackit.cloud/v1alpha1/projects/{projectID}/images
This explains why all previous attempts returned 404 - they were missing the project ID!
API URL Pattern:
# Pattern for project-specific resources:
https://iaas.api.eu01.stackit.cloud/{version}/projects/{projectID}/{resource}
# Example from the guide:
stackit curl https://iaas.api.eu01.stackit.cloud/v1alpha1/projects/$PROJECTID/images
# For volumes:
https://iaas.api.eu01.stackit.cloud/v1beta1/projects/{projectID}/volumes
Solution: Finding Block Storage Pricing
The correct approach:
- Performance Classes are in the IaaS API (with project ID)
- Pricing is in the PIM API (already working)
- Need to match the performance class names between both APIs
Working Solution Code:
<?php
// 1. Get performance classes from IaaS API (requires auth)
$projectId = "your-project-id";
$token = "your-auth-token";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://iaas.api.eu01.stackit.cloud/v1beta1/projects/$projectId/volume-performance-classes",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer $token",
"Accept: application/json"
),
// ... other options
));
$performanceClasses = json_decode(curl_exec($curl), true);
// 2. Get pricing from PIM API (no auth needed)
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://pim.api.eu01.stackit.cloud/v1/skus?region=eu01&category=Storage",
// ... other options
));
$pricing = json_decode(curl_exec($curl), true);
// 3. Match performance class with pricing
foreach ($pricing["services"] as $service) {
if ($service["attributes"]["class"] == "storage_premium_perf0" &&
$service["unitBilling"] == "per GB/hour") {
$pricePerGB = $service["monthlyPrice"];
$price64GB = $pricePerGB * 64;
echo "Found: " . $service["name"] . "\n";
echo "Price for 64 GB: " . $price64GB . " EUR\n";
}
}
?>
Alternative: Search in PIM API for the Exact Price
<?php
// Since we know the portal shows 5.95 EUR for 64 GB
$targetPricePerGB = 5.95 / 64; // 0.09296875
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://pim.api.eu01.stackit.cloud/v1/skus?region=eu01",
CURLOPT_RETURNTRANSFER => true,
// ... other options
));
$data = json_decode(curl_exec($curl), true);
foreach ($data["services"] as $service) {
if (isset($service["unitBilling"]) &&
$service["unitBilling"] == "per GB/hour" &&
isset($service["monthlyPrice"])) {
$diff = abs($service["monthlyPrice"] - $targetPricePerGB);
if ($diff < 0.0001) {
echo "FOUND MATCH!\n";
echo "Service: " . $service["name"] . "\n";
echo "Class: " . $service["attributes"]["class"] . "\n";
echo "Price per GB: " . $service["monthlyPrice"] . "\n";
echo "64 GB Total: " . ($service["monthlyPrice"] * 64) . " EUR\n";
// This is likely your storage_premium_perf0
break;
}
}
}
?>
Key Takeaways:
- IaaS API endpoints require authentication and project ID
- The
storage_premium_perf0 class exists but might be named differently in the PIM API
- Search the PIM API for a service with price = 5.95/64 = 0.09296875 EUR per GB
- The performance class in the portal might map to a different name in the API