Get Template By Id
curl --request GET \
--url https://api.vizapi.ai/v1/templates/{template_id} \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.vizapi.ai/v1/templates/{template_id}"
headers = {"x-api-key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};
fetch('https://api.vizapi.ai/v1/templates/{template_id}', 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://api.vizapi.ai/v1/templates/{template_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.vizapi.ai/v1/templates/{template_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.vizapi.ai/v1/templates/{template_id}")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vizapi.ai/v1/templates/{template_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"description": "<string>",
"category": "<string>",
"tags": [
{}
],
"usage_count": 123,
"fields": [
{}
],
"is_public": true,
"user_id": "<string>",
"created_at": "<string>",
"updated_at": "<string>"
}Templates
Get Template By Id
Retrieves a template by its ID
GET
/
v1
/
templates
/
{template_id}
Get Template By Id
curl --request GET \
--url https://api.vizapi.ai/v1/templates/{template_id} \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.vizapi.ai/v1/templates/{template_id}"
headers = {"x-api-key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};
fetch('https://api.vizapi.ai/v1/templates/{template_id}', 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://api.vizapi.ai/v1/templates/{template_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.vizapi.ai/v1/templates/{template_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.vizapi.ai/v1/templates/{template_id}")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vizapi.ai/v1/templates/{template_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"description": "<string>",
"category": "<string>",
"tags": [
{}
],
"usage_count": 123,
"fields": [
{}
],
"is_public": true,
"user_id": "<string>",
"created_at": "<string>",
"updated_at": "<string>"
}The
/templates/{template_id} endpoint retrieves a template by its unique identifier.
Request
Optional specific version of the template to retrieve. If not specified, the latest version will be returned.
Response
The field definitions for the template. Each field follows the same structure as described in the suggest-fields response.
Examples
Example Request
curl -X GET https://api.vizapi.ai/v1/templates/template_12345 \
-H "x-api-key: YOUR_API_KEY"
curl -X GET https://api.vizapi.ai/v1/templates/template_12345?version=2 \
-H "x-api-key: YOUR_API_KEY"
const fetch = require('node-fetch');
async function getTemplate() {
const response = await fetch('https://api.vizapi.ai/v1/templates/template_12345', {
method: 'GET',
headers: {
'x-api-key': 'YOUR_API_KEY'
}
});
const data = await response.json();
console.log(data);
}
getTemplate();
const fetch = require('node-fetch');
async function getTemplateVersion() {
const response = await fetch('https://api.vizapi.ai/v1/templates/template_12345?version=2', {
method: 'GET',
headers: {
'x-api-key': 'YOUR_API_KEY'
}
});
const data = await response.json();
console.log(data);
}
getTemplateVersion();
import requests
url = "https://api.vizapi.ai/v1/templates/template_12345"
headers = {
"x-api-key": "YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
data = response.json()
print(data)
import requests
url = "https://api.vizapi.ai/v1/templates/template_12345"
params = {
"version": 2
}
headers = {
"x-api-key": "YOUR_API_KEY"
}
response = requests.get(url, params=params, headers=headers)
data = response.json()
print(data)
Example Response
{
"id": "template_12345",
"name": "Plant Disease Detector",
"description": "Template for analyzing plant health and detecting diseases",
"category": "agriculture",
"tags": ["farming", "disease-detection"],
"usage_count": 25,
"fields": [
{
"name": "plant_species",
"type": "string",
"description": "The species of plant being analyzed",
"required": true,
"return_as_list": false,
"subfields": [],
"enum_values": []
},
{
"name": "disease_detected",
"type": "boolean",
"description": "Whether disease is present in the plant",
"required": true,
"return_as_list": false,
"subfields": [],
"enum_values": []
},
{
"name": "severity_level",
"type": "string",
"description": "The severity level of detected disease",
"required": false,
"return_as_list": false,
"subfields": [],
"enum_values": ["mild", "moderate", "severe"]
}
],
"is_public": false,
"user_id": "user_67890",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-20T14:45:00Z"
}
Error Codes
| Status Code | Description |
|---|---|
| 401 | Unauthorized - Invalid or missing API key |
| 404 | Not Found - The requested template was not found |
| 500 | Internal Server Error - An unexpected error occurred on our servers |