Convert a File
curl --request POST \
--url https://api.snipp.gg/convert \
--header 'Content-Type: multipart/form-data' \
--header 'api-key: <api-key>' \
--header 'convert-target: <convert-target>' \
--form file=@example-fileimport requests
url = "https://api.snipp.gg/convert"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {
"convert-target": "<convert-target>",
"api-key": "<api-key>"
}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {
method: 'POST',
headers: {'convert-target': '<convert-target>', 'api-key': '<api-key>'}
};
options.body = form;
fetch('https://api.snipp.gg/convert', 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.snipp.gg/convert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"api-key: <api-key>",
"convert-target: <convert-target>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.snipp.gg/convert"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("convert-target", "<convert-target>")
req.Header.Add("api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.snipp.gg/convert")
.header("convert-target", "<convert-target>")
.header("api-key", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.snipp.gg/convert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["convert-target"] = '<convert-target>'
request["api-key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body"<string>"{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}Uploads
Convert a File
Convert one image or video and get the converted bytes back. Nothing is stored.
POST
/
convert
Convert a File
curl --request POST \
--url https://api.snipp.gg/convert \
--header 'Content-Type: multipart/form-data' \
--header 'api-key: <api-key>' \
--header 'convert-target: <convert-target>' \
--form file=@example-fileimport requests
url = "https://api.snipp.gg/convert"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {
"convert-target": "<convert-target>",
"api-key": "<api-key>"
}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {
method: 'POST',
headers: {'convert-target': '<convert-target>', 'api-key': '<api-key>'}
};
options.body = form;
fetch('https://api.snipp.gg/convert', 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.snipp.gg/convert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"api-key: <api-key>",
"convert-target: <convert-target>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.snipp.gg/convert"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("convert-target", "<convert-target>")
req.Header.Add("api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.snipp.gg/convert")
.header("convert-target", "<convert-target>")
.header("api-key", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.snipp.gg/convert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["convert-target"] = '<convert-target>'
request["api-key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body"<string>"{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"username": "<string>",
"quota": 123,
"used": 123,
"resets_at": "2023-11-07T05:31:56Z",
"failed": [
{
"index": 123,
"error": "<unknown>"
}
]
}
}Convert one image or video to another format and get the converted file back. Nothing is stored, no post is created, and no quota is used.
On failure the body is JSON:
Headers
| Header | Required | Description |
|---|---|---|
api-key | Yes | Your API key, or a team access key |
convert-target | Yes | png, jpeg, webp, avif, gif, mp4 or mp3 |
Behavior
- Send the file as
multipart/form-datain thefilefield. Only the first file is read. - On success the body is the converted file itself, sent as an attachment, not JSON. Errors are JSON like every other endpoint.
- The source type is detected from the file’s bytes, not its name.
- What converts to what: PNG, JPG and WebP convert to
png,jpeg,webp,aviforgif. GIF converts topng,jpeg,webp,aviformp4. MP4, MOV and MKV convert tomp4,giformp3. - Video to GIF requires Plus. It uses the first 10 seconds at 15 fps and 480 px wide.
- MP4 output is remuxed with
+faststartwhen the source is already H.264, and transcoded otherwise. - Metadata is always stripped. JPG orientation is applied to the pixels first, so photos stay upright.
- Files are capped at 50 MB on Free, 20 GB on Plus, and 50 GB on Ultra and team keys. Converting does not count toward your weekly quota.
- Conversion runs inside the request, so a large video can take a while.
- To host the result, upload it with
POST /upload. AVIF and MP3 are not upload types, so those are download-only. - Rate limited to 10 conversions per minute.
Examples
curl -X POST "https://api.snipp.gg/convert" \
-H "api-key: YOUR_API_KEY" \
-H "convert-target: webp" \
-F "file=@screenshot.png" \
-o screenshot.webp
curl -X POST "https://api.snipp.gg/convert" \
-H "api-key: YOUR_API_KEY" \
-H "convert-target: mp3" \
-F "file=@clip.mp4" \
-o clip.mp3
Responses
On success the headers name the file:HTTP/1.1 200 OK
Content-Type: image/webp
Content-Disposition: attachment; filename="screenshot.webp"
Content-Length: 184320
{
"error": {
"type": "unsupported_type",
"message": "That file cannot be converted to this format."
}
}
Errors
| Status | Type | When |
|---|---|---|
400 | invalid_request | Missing or invalid convert-target, or no file |
400 | unsupported_type | The source type is not supported, or cannot become the target |
401 | unauthorized | Missing or invalid key |
403 | plan_required | Video to GIF without Plus |
403 | forbidden | The team’s subscription has lapsed |
413 | file_too_large | The file is over your limit |
429 | rate_limited | More than 10 conversions per minute |
500 | internal | The conversion failed |
Authorizations
Your API key from an app on snipp.gg/settings/apps
Headers
Output format.
Available options:
png, jpeg, webp, avif, gif, mp4, mp3 Body
multipart/form-data
The file to convert.
Response
The converted file, sent as an attachment.
The response is of type file.