API Documentation
The TPL Tools API gives you programmatic access to the same conversion and utility tools available on the website. It's free for hobby projects, side projects, and reasonable production use.
Authentication
Every request needs an API key. You'll get one when you sign up - the key starts with tpl_. Send it with each request using one of these methods:
| Method | Example |
|---|---|
| Header (recommended) | X-API-Key: tpl_yourkeyhere |
| Bearer token | Authorization: Bearer tpl_yourkeyhere |
| Query string | ?api_key=tpl_yourkeyhere (use the header instead in production) |
Rate Limits
Every API key is capped at 1,000 requests per day by default. The counter resets at midnight UTC. Need more? Hit the contact form from your dashboard - if your use case is real, I'll bump your limit. Free.
Every API response includes these headers so you don't have to guess:
| Header | What it means |
|---|---|
X-RateLimit-Limit | Your daily request cap (1000 by default) |
X-RateLimit-Remaining | How many requests you can still make today |
X-RateLimit-Reset | Seconds until the counter resets at midnight UTC |
When you hit the cap, the API returns HTTP 429 Too Many Requests with a JSON body explaining what happened and a link to request a higher limit.
Error Format
Errors always come back as JSON with the same shape. The HTTP status code tells you the category, and the error + message fields tell you exactly what to fix.
{
"ok": false,
"error": "missing_input",
"message": "Provide either \"svg\" or \"url\".",
"fields": {
"svg": "string (svg markup)",
"url": "string (URL)"
}
}
| Status | What it means |
|---|---|
200 | Success, response data is in the body |
400 | Bad request - check your input fields |
401 | Missing or invalid API key |
403 | Your key was disabled (contact me if you think it's wrong) |
404 | Endpoint doesn't exist |
405 | Wrong HTTP method (most endpoints want POST) |
413 | Input too large (each endpoint has its own limit) |
429 | Rate limit hit - wait until reset or request more |
500 | Something broke on my end - please report it |
Code Examples
The same request, in 6 languages. All examples use the svg-to-tpl endpoint as a reference - the pattern is identical for every other endpoint.
curl -X POST https://svgtotpl.com/api/v1/svg-to-tpl \
-H "X-API-Key: tpl_yourkeyhere" \
-H "Content-Type: application/json" \
-d '{"svg":"<svg width=\"100\"><rect/></svg>","class":"logo"}'
<?php
$ch = curl_init('https://svgtotpl.com/api/v1/svg-to-tpl');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-Key: tpl_yourkeyhere',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'svg' => '<svg width="100"><rect/></svg>',
'class' => 'logo',
]),
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
echo $result['tpl'];
// Browser fetch (note: don't expose your key in frontend code in production)
const response = await fetch('https://svgtotpl.com/api/v1/svg-to-tpl', {
method: 'POST',
headers: {
'X-API-Key': 'tpl_yourkeyhere',
'Content-Type': 'application/json'
},
body: JSON.stringify({
svg: '<svg width="100"><rect/></svg>',
class: 'logo'
})
});
const data = await response.json();
console.log(data.tpl);
import requests
response = requests.post(
'https://svgtotpl.com/api/v1/svg-to-tpl',
headers={'X-API-Key': 'tpl_yourkeyhere'},
json={
'svg': '<svg width="100"><rect/></svg>',
'class': 'logo'
}
)
data = response.json()
print(data['tpl'])
// Node.js (built-in fetch in Node 18+, or use 'node-fetch' for older)
const response = await fetch('https://svgtotpl.com/api/v1/svg-to-tpl', {
method: 'POST',
headers: {
'X-API-Key': process.env.TPL_API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
svg: '<svg width="100"><rect/></svg>',
class: 'logo'
})
});
const data = await response.json();
console.log(data.tpl);
require 'net/http'
require 'json'
uri = URI('https://svgtotpl.com/api/v1/svg-to-tpl')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['X-API-Key'] = 'tpl_yourkeyhere'
request['Content-Type'] = 'application/json'
request.body = {
svg: '<svg width="100"><rect/></svg>',
class: 'logo'
}.to_json
response = http.request(request)
data = JSON.parse(response.body)
puts data['tpl']
Endpoints
The endpoints listed below are currently live. New endpoints are added as new tools come online - bookmark this page and check back, or watch the announcements section.
Currently live: 1 endpoint
Converts an SVG (or PNG) into an OpenCart-style .tpl image declaration.
Request Body
{
// "svg": "<svg>...</svg>", // required (or "url")
// "url": "https://...", // alternative to "svg"
// "alt": "logo", // optional, alt text
// "class": "site-logo", // optional, CSS class
// "strip_styles": true // optional, remove inline styles
// }
Response
{ "ok": true, "tpl": "...", "format": "svg" }
Need More?
Hit a wall? Drop me a message. If you need a higher daily limit, a new endpoint, or you found a bug - I read every message.