Convert

Find the content type of a file name or an extension

POST/v1/convert/string/extension/to/content_type

View as Markdown

Give a file name (backup.tar.gz resolves as a double extension, upper case is fine) or an extension with or without the dot. An unknown or missing extension is not an error: known is false so the flow can branch. The response says where the reference data comes from and when it was compiled.

Request body

Name Type Required Description
file_name string no A file name such as report.PDF or backup.tar.gz
extension string no An extension, with or without the dot

Example request

A request body that works, as JSON.

{
  "extension": "xlsx"
}

Code samples

Replace YOUR_TOKEN with your access token.

curl

curl -X POST 'https://api.skillfulsardine.com/v1/convert/string/extension/to/content_type' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "extension": "xlsx"
}'

PowerShell

$body = @'
{
  "extension": "xlsx"
}
'@
$response = Invoke-RestMethod -Method Post -Uri 'https://api.skillfulsardine.com/v1/convert/string/extension/to/content_type' `
  -Headers @{ Authorization = 'Bearer YOUR_TOKEN' } `
  -ContentType 'application/json; charset=utf-8' `
  -Body ([System.Text.Encoding]::UTF8.GetBytes($body))
$response | ConvertTo-Json -Depth 10

Python

import requests

payload = {
    "extension": "xlsx",
}

response = requests.post(
    "https://api.skillfulsardine.com/v1/convert/string/extension/to/content_type",
    headers={"Authorization": "Bearer YOUR_TOKEN"},
    json=payload,
    timeout=30,
)
print(response.json())

JavaScript

const response = await fetch("https://api.skillfulsardine.com/v1/convert/string/extension/to/content_type", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "extension": "xlsx"
}),
});
const result = await response.json();
console.log(result);

Node

// Node 18 or later. Save as call.mjs and run: API_TOKEN=... node call.mjs
const token = process.env.API_TOKEN;

const response = await fetch("https://api.skillfulsardine.com/v1/convert/string/extension/to/content_type", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${token}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "extension": "xlsx"
}),
});
const result = await response.json();
console.log(result);

Rust

// Cargo.toml: reqwest = { version = "0.12", features = ["blocking", "json"] }, serde_json = "1"
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let body: serde_json::Value = serde_json::from_str(r#"{
  "extension": "xlsx"
}"#)?;
    let response = reqwest::blocking::Client::new()
        .post("https://api.skillfulsardine.com/v1/convert/string/extension/to/content_type")
        .bearer_auth("YOUR_TOKEN")
        .json(&body)
        .send()?;
    println!("{}", response.text()?);
    Ok(())
}

Swift

import Foundation

var request = URLRequest(url: URL(string: "https://api.skillfulsardine.com/v1/convert/string/extension/to/content_type")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = Data(#"""
{
  "extension": "xlsx"
}
"""#.utf8)

let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))

Response

The fields inside data of a successful response.

Name Type Required Description
extension string yes The extension used, lower case without a dot (tar.gz for double extensions)
content_type string yes The content type, null when unknown
known boolean yes False when the extension is missing or not in the reference data
data_source string yes Where the reference data comes from
data_compiled string yes When the reference data was compiled

Example response

A real answer from the operation, as JSON. The fields in the table above are inside data.

{
  "data": {
    "extension": "xlsx",
    "content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
    "known": true,
    "data_source": "Curated subset of the IANA media types registry (https://www.iana.org/assignments/media-types/) plus the de-facto types used by Microsoft 365 and common web tools",
    "data_compiled": "2026-10-16"
  },
  "errors": null,
  "meta": {
    "request_id": "b86cb6cb-6f20-4f6f-91df-f9a36d3dcdcb",
    "timestamp": "2026-10-27T07:19:42.031329Z",
    "version": "2026-03-26"
  },
  "pagination": null
}

Responses

Status When it happens
200 Successful Response
400 The body respects the operation schema, but the use case rejected it. Each problem is one ApiError entry
413 The request is larger than the request size limit of the API allows
422 The body does not respect the operation schema. Each problem is one ApiError entry with the code validation_error
500 Something failed inside the server and was not an input problem. The same envelope, errors may be empty