API Documentation
Integrate TempConvert's powerful temperature conversion capabilities into your applications.
API Coming Soon
We're working on launching our public API. Sign up below to be notified when it's available, or use our JavaScript library for client-side integration.
Quick Start
Client-Side JavaScript Library
Use our lightweight JavaScript library for instant temperature conversions in your web applications.
// Install via npm
npm install @tempconvert/core
// Or use via CDN
<script src="https://cdn.tempconvert.io/v1/tempconvert.min.js"></script>
// Usage example
import { convert } from '@tempconvert/core';
const result = convert(25, 'celsius', 'fahrenheit');
console.log(result); // 77
// Batch conversions
const temps = convert.batch([0, 25, 100], 'celsius', 'fahrenheit');
console.log(temps); // [32, 77, 212]API Endpoints (Preview)
/api/v1/convertConvert a temperature value from one scale to another.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| value | number | Yes | Temperature value to convert |
| from | string | Yes | Source scale: celsius, fahrenheit, kelvin, rankine |
| to | string | Yes | Target scale: celsius, fahrenheit, kelvin, rankine |
Example Request
GET https://api.tempconvert.io/v1/convert?value=25&from=celsius&to=fahrenheit
Example Response
{
"success": true,
"data": {
"value": 25,
"from": "celsius",
"to": "fahrenheit",
"result": 77,
"formula": "(25 × 9/5) + 32 = 77"
}
}/api/v1/convert/batchConvert multiple temperature values in a single request.
Request Body
{
"values": [0, 25, 100],
"from": "celsius",
"to": "fahrenheit"
}Example Response
{
"success": true,
"data": {
"from": "celsius",
"to": "fahrenheit",
"conversions": [
{ "input": 0, "output": 32 },
{ "input": 25, "output": 77 },
{ "input": 100, "output": 212 }
]
}
}Rate Limits
Authentication
API requests require an API key passed in the X-API-Key header.
curl -H "X-API-Key: your_api_key_here" \
https://api.tempconvert.io/v1/convert?value=25&from=celsius&to=fahrenheitWebhooks & Callbacks
Configure webhooks to receive real-time notifications about conversion events, API usage, or custom triggers.
Webhook Events
conversion.completed
Triggered when a conversion is successfully completed via API
batch.completed
Triggered when a batch conversion job is finished
quota.warning
Triggered when API usage reaches 80% of daily quota
quota.exceeded
Triggered when daily API quota is exceeded
Webhook Payload
{
"event": "conversion.completed",
"timestamp": "2025-11-04T12:34:56Z",
"data": {
"id": "conv_1234567890",
"value": 25,
"from": "celsius",
"to": "fahrenheit",
"result": 77,
"api_key": "ak_************",
"ip": "192.0.2.1"
},
"signature": "sha256_signature_here"
}Configuring Webhooks
Configure webhook endpoints through the developer dashboard (coming soon). Each webhook will include a signature header for verification.
// Example webhook verification (Node.js)
const crypto = require('crypto');
function verifyWebhook(payload, signature, secret) {
const hash = crypto
.createHmac('sha256', secret)
.update(JSON.stringify(payload))
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(hash)
);
}
// Express.js webhook handler
app.post('/webhooks/tempconvert', (req, res) => {
const signature = req.headers['x-tempconvert-signature'];
const isValid = verifyWebhook(req.body, signature, process.env.WEBHOOK_SECRET);
if (!isValid) {
return res.status(401).send('Invalid signature');
}
// Process webhook event
const { event, data } = req.body;
console.log(`Received ${event}:`, data);
res.status(200).send('OK');
});Callback URLs
For single conversion requests, you can optionally provide a callback URL that will be called upon completion.
// Async conversion with callback
POST https://api.tempconvert.io/v1/convert
Content-Type: application/json
{
"value": 25,
"from": "celsius",
"to": "fahrenheit",
"callback_url": "https://your-app.com/api/conversion-complete"
}
// Your callback will receive:
POST https://your-app.com/api/conversion-complete
{
"request_id": "req_abc123",
"result": 77,
"completed_at": "2025-11-04T12:34:56Z"
}Code Examples & Integration Guides
JavaScript / Node.js
Basic Usage
// Import the library
import { convert, convertBatch } from '@tempconvert/core';
// Single conversion
const result = convert(25, 'celsius', 'fahrenheit');
console.log(`25°C = ${result}°F`); // 25°C = 77°F
// Batch conversion
const temps = [0, 10, 20, 30, 40];
const converted = convertBatch(temps, 'celsius', 'fahrenheit');
console.log(converted); // [32, 50, 68, 86, 104]Express.js API Endpoint
const express = require('express');
const { convert } = require('@tempconvert/core');
const app = express();
app.use(express.json());
app.get('/convert', (req, res) => {
const { value, from, to } = req.query;
if (!value || !from || !to) {
return res.status(400).json({ error: 'Missing parameters' });
}
try {
const result = convert(parseFloat(value), from, to);
res.json({
success: true,
data: { value, from, to, result }
});
} catch (error) {
res.status(400).json({ error: error.message });
}
});
app.listen(3000, () => {
console.log('Temperature API running on port 3000');
});React
import { useState } from 'react';
import { convert } from '@tempconvert/core';
function TemperatureConverter() {
const [celsius, setCelsius] = useState(0);
const [fahrenheit, setFahrenheit] = useState(32);
const handleCelsiusChange = (e) => {
const value = parseFloat(e.target.value) || 0;
setCelsius(value);
setFahrenheit(convert(value, 'celsius', 'fahrenheit'));
};
const handleFahrenheitChange = (e) => {
const value = parseFloat(e.target.value) || 0;
setFahrenheit(value);
setCelsius(convert(value, 'fahrenheit', 'celsius'));
};
return (
<div>
<input
type="number"
value={celsius}
onChange={handleCelsiusChange}
placeholder="Celsius"
/>
<span>°C =</span>
<input
type="number"
value={fahrenheit}
onChange={handleFahrenheitChange}
placeholder="Fahrenheit"
/>
<span>°F</span>
</div>
);
}Vue.js / Nuxt.js
<template>
<div class="converter">
<input
v-model.number="celsius"
type="number"
@input="updateFahrenheit"
placeholder="Celsius"
/>
<span>°C =</span>
<input
v-model.number="fahrenheit"
type="number"
@input="updateCelsius"
placeholder="Fahrenheit"
/>
<span>°F</span>
</div>
</template>
<script setup>
import { ref } from 'vue';
import { convert } from '@tempconvert/core';
const celsius = ref(0);
const fahrenheit = ref(32);
const updateFahrenheit = () => {
fahrenheit.value = convert(celsius.value, 'celsius', 'fahrenheit');
};
const updateCelsius = () => {
celsius.value = convert(fahrenheit.value, 'fahrenheit', 'celsius');
};
</script>Python
While the core library is JavaScript-based, here's an equivalent Python implementation:
import requests
# Using the REST API
def convert_temperature(value, from_scale, to_scale):
response = requests.get(
'https://api.tempconvert.io/v1/convert',
params={'value': value, 'from': from_scale, 'to': to_scale},
headers={'X-API-Key': 'your_api_key_here'}
)
return response.json()['data']['result']
# Example usage
celsius = 25
fahrenheit = convert_temperature(celsius, 'celsius', 'fahrenheit')
print(f"{celsius}°C = {fahrenheit}°F") # 25°C = 77°FBrowser / CDN Usage (No Build Step)
<!DOCTYPE html>
<html>
<head>
<title>Temperature Converter</title>
<script src="https://cdn.tempconvert.io/v1/tempconvert.min.js"></script>
</head>
<body>
<h1>Temperature Converter</h1>
<input id="celsius" type="number" placeholder="Celsius">
<button onclick="convertTemp()">Convert</button>
<p id="result"></p>
<script>
function convertTemp() {
const celsius = parseFloat(document.getElementById('celsius').value);
const fahrenheit = TempConvert.convert(celsius, 'celsius', 'fahrenheit');
document.getElementById('result').textContent =
`${celsius}°C = ${fahrenheit}°F`;
}
</script>
</body>
</html>You might also likeProofPointto strengthen business writing.
Get Notified When API Launches
Be the first to know when our API goes live. No spam, just updates.
Contact us at api@tempconvert.io to join the waitlist