変換・フォーマット

QRCode

テキストやURLからQRコードを生成します。

MCPツール名: generate_qrcode_url

GET /v1/qrcode

パラメータ:

パラメータ必須説明
datastringQRコードに埋め込むテキストまたはURL
sizeinteger-画像サイズpx(75〜1000、デフォルト300)
formatstring-出力形式(png / svg、デフォルトpng)

リクエスト例:

curl "https://api.thousand-api.com/v1/qrcode?data=https://example.com&size=300" \
  -H "x-api-key: YOUR_API_KEY"

レスポンス:

PNG画像またはSVGデータをバイナリで返します。

画像変換

HTTPS URL から画像を取得し、WebP / JPEG / PNG / AVIF への変換・リサイズ・圧縮を行います。結果は Base64 文字列で返します。プライベート IP へのリクエストは SSRF 対策のため拒否されます。

MCPツール名: transform_image

POST /v1/image/transform

パラメータ:

パラメータ必須説明
urlstring変換元画像の HTTPS URL
formatstring-出力形式: webp / jpeg / png / avif(デフォルト: webp)
widthinteger-リサイズ後の幅 px(1〜4000)
heightinteger-リサイズ後の高さ px(1〜4000)
qualityinteger-圧縮品質 1〜100(webp/jpeg/avif、デフォルト: 80。png は無視)
fitstring-リサイズ方式: cover / contain / fill / inside / outside(デフォルト: inside)

レスポンスフィールド

パラメータ説明
formatstring変換後のフォーマット
widthnumber変換後の幅(px)
heightnumber変換後の高さ(px)
original_sizenumber変換前のバイト数
converted_sizenumber変換後のバイト数
reduction_ratenumber削減率(0.6 = 60%削減)
datastringBase64 エンコードされた画像データ
mime_typestringMIME タイプ(例: image/webp)

WebP 変換のみ

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/image/transform" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/photo.png"
  }'

レスポンス例:

{
  "format": "webp",
  "width": 1200,
  "height": 800,
  "original_size": 245760,
  "converted_size": 98304,
  "reduction_rate": 0.6,
  "data": "UklGRi4AAABXRUJQVlA4...",
  "mime_type": "image/webp"
}

リサイズ + JPEG + quality

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/image/transform" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/photo.png",
    "format": "jpeg",
    "width": 800,
    "height": 600,
    "quality": 85,
    "fit": "cover"
  }'

レスポンス例:

{
  "format": "jpeg",
  "width": 800,
  "height": 600,
  "original_size": 245760,
  "converted_size": 112640,
  "reduction_rate": 0.5417,
  "data": "/9j/4AAQSkZJRg...",
  "mime_type": "image/jpeg"
}

fit パラメータ

パラメータ説明
cover指定サイズを覆うようにクロップ(アスペクト比維持)
contain指定サイズ内に全体が収まるよう縮小
fill指定サイズに引き伸ばし(アスペクト比無視)
inside縦横比を維持しつつ、指定サイズ以内に収める(拡大しない)
outside縦横比を維持しつつ、指定サイズを覆う最小サイズ(拡大しない)

HTML や CSS で使う場合は data:image/webp;base64,{data} の形式で埋め込めます。

Markdown→HTML変換

MarkdownテキストをHTMLに変換します。GitHub Flavored Markdown(GFM)対応・XSSサニタイズ対応。

MCPツール名: convert_markdown

POST /v1/convert/markdown

パラメータ:

パラメータ必須説明
markdownstring変換するMarkdownテキスト(最大100KB)
sanitizeboolean-HTMLをサニタイズ(デフォルトtrue)

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/convert/markdown" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "markdown": "# Hello\n\nThis is **bold** text.",
    "sanitize": true
  }'

レスポンス例:

{
  "html": "<h1>Hello</h1>\n<p>This is <strong>bold</strong> text.</p>"
}

レスポンスフィールド:

パラメータ説明
html変換後のHTML文字列

レスポンス:

GFM(テーブル・タスクリスト・取り消し線・コードブロック)に対応。sanitize: false はサーバー側で信頼済みのMarkdownのみに使用してください。ユーザー入力には sanitize: true(デフォルト)を推奨します。

単位変換

長さ・重さ・温度・面積・体積・速度・データ量の単位変換を行います。外部APIへの依存なし・mathjsによる正確な計算。

MCPツール名: convert_unit

対応カテゴリ: 長さ(m, km, mile, foot, inch 等)、重さ(kg, g, lb, oz 等)、温度(celsius, fahrenheit, kelvin)、面積(m2, ha, acre, sqft 等)、体積(l, ml, gallon, cup 等)、速度(m/s, km/h, mph, knot 等)、データ量(byte, KB, MB, GB, TB, KiB, MiB 等)

GET /v1/unit/convert

パラメータ:

パラメータ必須説明
valuenumber変換する数値
fromstring変換元単位
tostring変換先単位

リクエスト例:

curl "https://api.thousand-api.com/v1/unit/convert?value=1&from=km&to=mile" \
  -H "x-api-key: YOUR_API_KEY"

レスポンス例:

{
  "value": 1,
  "from": "km",
  "to": "mile",
  "result": 0.621371,
  "formula": "1 km = 0.621371 mile"
}

Base64エンコード/デコード

文字列のBase64エンコード/デコードを行います。URL-safe形式・UTF-8/hex/base64入力エンコーディングに対応。Node.js標準Bufferのみ使用・外部依存なし。

MCPツール名: convert_base64

url_safe: true の場合、encode時は + → -、/ → _ に変換し末尾の = パディングを除去します。decode時は - → +、_ → / に変換してからパディングを補完してデコードします。JWTペイロードなどURL-safe Base64の解析に使えます。

POST /v1/encode/base64

パラメータ:

パラメータ必須説明
datastringエンコード/デコード対象の文字列(最大512KB)
directionstringencode / decode
url_safeboolean-URL-safe Base64を使用するか(デフォルト: false)
input_encodingstring-encode時のdataの文字エンコーディング: utf8 / hex / base64(デフォルト: utf8)

レスポンスフィールド:

パラメータ説明
directionstring処理方向(encode / decode)
inputstringリクエストの data をそのまま返す
outputstringエンコード/デコード結果
url_safeboolean使用した url_safe の値
byte_lengthnumberinput のバイト数(Buffer.byteLength)

エンコード例:

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/encode/base64" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "data": "こんにちは",
    "direction": "encode"
  }'

レスポンス例:

{
  "direction": "encode",
  "input": "こんにちは",
  "output": "44GT44KT44Gr44Gh",
  "url_safe": false,
  "byte_length": 15
}

デコード例:

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/encode/base64" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "data": "44GT44KT44Gr44Gh",
    "direction": "decode"
  }'

レスポンス例:

{
  "direction": "decode",
  "input": "44GT44KT44Gr44Gh",
  "output": "こんにちは",
  "url_safe": false,
  "byte_length": 16
}

CSV↔JSON変換

CSVとJSONを相互変換します。ヘッダー有無・区切り文字のカスタマイズに対応。

MCPツール名: convert_csv

タブ区切り(TSV)にも対応します。delimiter に "\t" を指定してください。

POST /v1/convert/csv

パラメータ:

パラメータ必須説明
inputstring変換するデータ(最大1MB)
fromstringcsv / json
tostringcsv / json
has_headerboolean-CSVのヘッダー行の有無(デフォルト: true)
delimiterstring-CSVの区切り文字(デフォルト: ,)

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/convert/csv" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "name,age\nAlice,30\nBob,25",
    "from": "csv",
    "to": "json"
  }'

レスポンス例:

{
  "from": "csv",
  "to": "json",
  "result": [
    { "name": "Alice", "age": "30" },
    { "name": "Bob",   "age": "25" }
  ],
  "rows": 2,
  "columns": 2
}

YAML↔JSON変換

YAMLとJSONを相互変換します。JSON出力時はインデント幅を指定できます。

MCPツール名: convert_yaml

POST /v1/convert/yaml

パラメータ:

パラメータ必須説明
inputstring変換するデータ(最大1MB)
fromstringyaml / json
tostringyaml / json
indentinteger-JSON出力時のインデント数(0〜10・デフォルト: 2)

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/convert/yaml" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "name: Alice\nage: 30",
    "from": "yaml",
    "to": "json",
    "indent": 2
  }'

レスポンス例:

{
  "from": "yaml",
  "to": "json",
  "result": "{\n  \"name\": \"Alice\",\n  \"age\": 30\n}",
  "indent": 2
}

TOML↔JSON変換

TOMLとJSONを相互変換します。pyproject.toml・Cargo.toml などの設定ファイルの読み書きに使えます。テーブル配列([[...]])やネストテーブル([section])に対応します。

MCPツール名: convert_toml

POST /v1/convert/toml — direction: to_json

パラメータ:

パラメータ必須説明
inputstring変換する TOML 文字列(最大1MB)
directionstringto_json
indentinteger-JSON 出力時のインデント幅(0〜8・デフォルト: 2)

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/convert/toml" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "[package]\nname = \"my-crate\"\nversion = \"0.1.0\"\n\n[dependencies]\nserde = \"1.0\"",
    "direction": "to_json",
    "indent": 2
  }'

レスポンス例:

{
  "direction": "to_json",
  "output": {
    "package": { "name": "my-crate", "version": "0.1.0" },
    "dependencies": { "serde": "1.0" }
  },
  "output_str": "{\n  \"package\": { \"name\": \"my-crate\", \"version\": \"0.1.0\" },\n  \"dependencies\": { \"serde\": \"1.0\" }\n}",
  "byte_length": 98
}

POST /v1/convert/toml — direction: to_toml

パラメータ:

パラメータ必須説明
inputstring変換する JSON 文字列(最大1MB)
directionstringto_toml

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/convert/toml" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "{\"title\":\"Thousand API\",\"version\":\"1.0.0\"}",
    "direction": "to_toml"
  }'

レスポンス例:

{
  "direction": "to_toml",
  "output": "title = \"Thousand API\"\nversion = \"1.0.0\"",
  "output_str": "title = \"Thousand API\"\nversion = \"1.0.0\"",
  "byte_length": 42
}

レスポンスフィールド

パラメータ説明
directionstring使用した変換方向(to_json / to_toml)
outputanyto_json 時はパース済み JSON オブジェクト、to_toml 時は TOML 文字列
output_strstringto_json 時は JSON.stringify 済み文字列、to_toml 時は TOML 文字列(output と同値)
byte_lengthnumberoutput_str の UTF-8 バイト数

XML↔JSON変換

XMLとJSONを相互変換します。レガシーAPIレスポンス、AWS/GCP設定、SOAP、RSSなどのXMLデータの読み書きに使えます。属性はプレフィックス付きキー(デフォルト @)で表現します。

MCPツール名: convert_xml

XMLの属性は JSON では attribute_prefix(デフォルト @)付きのキーになります。例: <user id="1"> → { "user": { "@id": 1 } }。to_xml では JSON 側でも同じプレフィックス(例: "@id")を使うと属性として出力されます。

POST /v1/convert/xml — direction: to_json

パラメータ:

パラメータ必須説明
inputstring変換する XML 文字列(最大1MB)
directionstringto_json
indentinteger-JSON 出力時のインデント幅(0〜8・デフォルト: 2)
attribute_prefixstring-属性キーのプレフィックス(デフォルト: @)

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/convert/xml" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "<user id=\"1\"><name>Alice</name></user>",
    "direction": "to_json",
    "indent": 2
  }'

レスポンス例:

{
  "direction": "to_json",
  "output": {
    "user": { "@id": 1, "name": "Alice" }
  },
  "output_str": "{\n  \"user\": {\n    \"@id\": 1,\n    \"name\": \"Alice\"\n  }\n}",
  "byte_length": 52
}

POST /v1/convert/xml — direction: to_xml

パラメータ:

パラメータ必須説明
inputstring変換する JSON 文字列(最大1MB)
directionstringto_xml
indentinteger-XML 出力時のインデント幅(0〜8・デフォルト: 2)
attribute_prefixstring-属性キーのプレフィックス(デフォルト: @)

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/convert/xml" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "{\"user\":{\"@id\":1,\"name\":\"Alice\"}}",
    "direction": "to_xml",
    "indent": 2
  }'

レスポンス例:

{
  "direction": "to_xml",
  "output": "<user id=\"1\">\n  <name>Alice</name>\n</user>",
  "output_str": "<user id=\"1\">\n  <name>Alice</name>\n</user>",
  "byte_length": 42
}

レスポンスフィールド

パラメータ説明
directionstring使用した変換方向(to_json / to_xml)
outputanyto_json 時はパース済み JSON オブジェクト、to_xml 時は XML 文字列
output_strstringto_json 時は JSON.stringify 済み文字列、to_xml 時は XML 文字列(output と同値)
byte_lengthnumberoutput_str の UTF-8 バイト数

数値・通貨フォーマット

数値をロケールに合わせてフォーマットします。通貨・パーセント・単位付き表示に対応。Node.js標準のIntl.NumberFormatを使用。

MCPツール名: format_number

GET /v1/format/number

パラメータ:

パラメータ必須説明
valuenumberフォーマットする数値
localestring-ロケール(デフォルト: en-US)
stylestring-decimal / currency / percent / unit
currencystring-通貨コード(style=currency時必須)
unitstring-単位(style=unit時必須)
minimum_fraction_digitsinteger-小数点以下の最小桁数(0〜20)
maximum_fraction_digitsinteger-小数点以下の最大桁数(0〜20)

リクエスト例:

curl "https://api.thousand-api.com/v1/format/number?value=1234567.89&locale=ja-JP&style=currency&currency=JPY" \
  -H "x-api-key: YOUR_API_KEY"

レスポンス例:

{
  "value": 1234567.89,
  "locale": "ja-JP",
  "style": "currency",
  "currency": "JPY",
  "formatted": "¥1,234,568"
}