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
string
required
Your API key for authentication.
string
required
The unique identifier of the template to retrieve.
integer
Optional specific version of the template to retrieve. If not specified, the latest version will be returned.
Response
string
The unique identifier for the template.
string
The name of the template.
string
The description of the template.
string
The category of the template.
array
The tags associated with the template.
integer
The number of times this template has been used.
array
The field definitions for the template. Each field follows the same structure as described in the suggest-fields response.
boolean
Whether the template is public or private.
string
The ID of the user who owns this template (for private templates).
string
When the template was created (ISO 8601 format).
string
When the template was last updated (ISO 8601 format).
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 |
⌘I