Convert, merge, and protect files — all via a REST API call.
curl -X POST https://app.way2api.com/api/v1/media/convert \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: multipart/form-data" \ -F "action=jpg_to_pdf" -F "[email protected]"
<?php
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => "https://app.way2api.com/api/v1/media/convert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: multipart/form-data"
],
CURLOPT_POSTFIELDS => '-F \"action=jpg_to_pdf\" -F \"[email protected]\"'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);
const formData = new FormData();
formData.append("action", "jpg_to_pdf");
formData.append("file", fileInput.files[0]); // from <input type="file">
const response = await fetch("https://app.way2api.com/api/v1/media/convert", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY"
// Content-Type is set automatically with boundary by browser
},
body: formData
});
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
const data = await response.json();
console.log(data);
import requests
with open("image.jpg", "rb") as f:
response = requests.post(
"https://app.way2api.com/api/v1/media/convert",
headers={
"Authorization": "Bearer YOUR_API_KEY"
},
files={"file": f},
data={"action": "jpg_to_pdf"}
)
print(response.status_code)
print(response.json())
{
"status": "success",
"download_url": "https://app.way2api.com/files/output_xyz.pdf",
"expires_in": 3600,
"file_size_kb": 245
}
| Code | Meaning |
|---|---|
| 200 | OK — Request successful |
| 400 | Bad Request — Missing or invalid parameters |
| 401 | Unauthorized — Invalid or missing API key |
| 429 | Too Many Requests — Rate limit exceeded |
| 500 | Server Error — Try again later |
Start with free trial API calls. No credit card required.
Get API Key — Free Browse All APIs