開発ユーティリティ

Distance

2地点間の距離を計算します。

MCPツール名: calculate_distance

GET /v1/distance

パラメータ:

パラメータ必須説明
p1string地点1の緯度,経度(例: 35.681236,139.767125)
p2string地点2の緯度,経度(例: 34.702485,135.495951)

リクエスト例:

curl "https://api.thousand-api.com/v1/distance?p1=35.681236,139.767125&p2=34.702485,135.495951" \
  -H "x-api-key: YOUR_API_KEY"

レスポンス例:

{
  "p1": { "lat": 35.681236, "lon": 139.767125 },
  "p2": { "lat": 34.702485, "lon": 135.495951 },
  "distance_km": 402.3
}

座標系変換

WGS84(GPS)・東京測地系(旧日本測地系)・JGD2011(測地成果2011)間の座標変換、および国土地理院タイル座標(XYZ)への変換を行います。外部ライブラリ不要・Molodensky近似パラメータを使用します。

MCPツール名: convert_coordinates

WGS84はGPS端末の標準座標系です。東京測地系(tokyo)は国土地理院の旧地図や行政システムで使われていた座標系で、WGS84と最大約450mずれます。JGD2011(jgd2011)は測地成果2011で、WGS84と実用上ほぼ同一ですが、API上は別座標系として指定できます。タイル変換(to=tile)時は内部でWGS84に統一してからWebメルカトル投影のXYZタイル座標を計算します。

GET /v1/geo/convert

パラメータ:

パラメータ必須説明
latnumber緯度(-90〜90)
lngnumber経度(-180〜180)
fromstring変換元座標系: wgs84 / tokyo / jgd2011
tostring変換先座標系: wgs84 / tokyo / jgd2011 / tile
zoominteger-to=tile のとき必須。ズームレベル(0〜25の整数)

レスポンスフィールド:

座標変換時(to が wgs84 / tokyo / jgd2011)の output

パラメータ説明
lat変換後の緯度(小数第8位まで)
lng変換後の経度(小数第8位まで)

タイル変換時(to が tile)の output

パラメータ説明
zoomリクエストで指定したズームレベル
xタイルのX座標(経度方向・0始まり)
yタイルのY座標(緯度方向・北が小さい値)

リクエスト例:

例1: WGS84 → 東京測地系(GPSデータを旧日本測地系に変換)

curl "https://api.thousand-api.com/v1/geo/convert?lat=35.6812&lng=139.7671&from=wgs84&to=tokyo" \
  -H "x-api-key: YOUR_API_KEY"
{
  "from": "wgs84",
  "to": "tokyo",
  "input": { "lat": 35.6812, "lng": 139.7671 },
  "output": { "lat": 35.68109304, "lng": 139.76727453 }
}

例2: 東京測地系 → WGS84(旧システムのデータをGPS座標に変換)

curl "https://api.thousand-api.com/v1/geo/convert?lat=35.68109304&lng=139.76727453&from=tokyo&to=wgs84" \
  -H "x-api-key: YOUR_API_KEY"
{
  "from": "tokyo",
  "to": "wgs84",
  "input": { "lat": 35.68109304, "lng": 139.76727453 },
  "output": { "lat": 35.6812, "lng": 139.7671 }
}

例3: WGS84 → タイル座標(zoom=15・国土地理院タイル)

curl "https://api.thousand-api.com/v1/geo/convert?lat=35.6812&lng=139.7671&from=wgs84&to=tile&zoom=15" \
  -H "x-api-key: YOUR_API_KEY"
{
  "from": "wgs84",
  "to": "tile",
  "input": { "lat": 35.6812, "lng": 139.7671 },
  "output": { "zoom": 15, "x": 29105, "y": 12903 }
}

カラーパレット生成

基準カラーコードから補色・類似色などのカラーパレットを生成します。外部依存なし・HSL色空間で数学的に正確な計算を行います。

MCPツール名: generate_color_palette

GET /v1/color/palette

パラメータ:

パラメータ必須説明
colorstring基準カラーコード(#RRGGBB形式)
typestring-complementary / analogous / triadic / tetradic / shades

リクエスト例:

curl "https://api.thousand-api.com/v1/color/palette?color=%231976D2&type=complementary" \
  -H "x-api-key: YOUR_API_KEY"

レスポンス例:

{
  "base": "#1976D2",
  "type": "complementary",
  "palette": [
    {
      "hex": "#1976D2",
      "rgb": "rgb(25, 118, 210)",
      "hsl": "hsl(211, 79%, 46%)",
      "name": "base"
    },
    {
      "hex": "#D27619",
      "rgb": "rgb(210, 118, 25)",
      "hsl": "hsl(31, 79%, 46%)",
      "name": "complement"
    }
  ]
}

WCAGコントラスト比

前景色と背景色のWCAG 2.1コントラスト比を計算し、AA/AAAの適合判定と推奨メッセージを返します。外部依存なし・公式の相対輝度アルゴリズムを使用します。

MCPツール名: calc_color_contrast

WCAG 2.1 基準: AA 通常テキスト 4.5:1、AA 大テキスト・UI 3:1、AAA 通常テキスト 7:1、AAA 大テキスト 4.5:1。大テキストは 18pt 以上、または 14pt 以上の太字を指します。

generate_color_palette で得た palette 内の各 hex を foreground / background の組み合わせで本APIに渡すと、アクセシブルな配色候補だけをエージェント側でフィルタできます。

GET /v1/color/contrast

パラメータ:

パラメータ必須説明
foregroundstring前景色HEX(#RRGGBB、RRGGBB、3桁短縮可)
backgroundstring背景色HEX(#RRGGBB、RRGGBB、3桁短縮可)

リクエスト例:

curl "https://api.thousand-api.com/v1/color/contrast?foreground=%23FFFFFF&background=%231976D2" \
  -H "x-api-key: YOUR_API_KEY"

レスポンス例:

例1: 十分なコントラスト(#FFFFFF / #1976D2)

{
  "foreground": "#FFFFFF",
  "background": "#1976D2",
  "contrast_ratio": 4.6,
  "wcag_aa_normal": true,
  "wcag_aa_large": true,
  "wcag_aaa_normal": false,
  "wcag_aaa_large": true,
  "recommendation": "AA normal + AAA large: good for most use cases (ratio: 4.6:1)"
}

例2: コントラスト不足(Fail判定)

{
  "foreground": "#777777",
  "background": "#888888",
  "contrast_ratio": 1.26,
  "wcag_aa_normal": false,
  "wcag_aa_large": false,
  "wcag_aaa_normal": false,
  "wcag_aaa_large": false,
  "recommendation": "Fail: insufficient contrast for any WCAG level (ratio: 1.26:1)"
}

レスポンスフィールド:

パラメータ説明
foreground正規化済み前景色(大文字 #RRGGBB)
background正規化済み背景色(大文字 #RRGGBB)
contrast_ratioWCAGコントラスト比(小数第2位まで)
wcag_aa_normalAA 通常テキスト適合(4.5:1 以上)
wcag_aa_largeAA 大テキスト・UI適合(3:1 以上)
wcag_aaa_normalAAA 通常テキスト適合(7:1 以上)
wcag_aaa_largeAAA 大テキスト適合(4.5:1 以上)
recommendation最高適合レベルの説明文(英語)

数式評価

数式・計算式を安全に評価します。四則演算・三角関数・統計・単位変換・変数バインディングに対応。JavaScript の eval は使用せず、mathjs のサンドボックス実行で危険な関数(import・parse 等)を無効化しています。100ms のタイムアウトで過大な計算も遮断します。

MCPツール名: calc_expression

POST /v1/math/eval

パラメータ:

パラメータ必須説明
expressionstring必須評価する数式文字列(最大500文字)
variablesobject-変数バインディング(値は number / string / boolean)
precisioninteger-小数点以下の桁数(0〜15、省略時は制限なし)

レスポンスフィールド:

パラメータ説明
expression入力した数式をそのまま返す
variables使用した変数(未指定時は null)
result評価結果(number / string / boolean)
result_strresult を文字列化したもの
precision使用した precision(未指定時は null)

税込計算の例:

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/math/eval" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "expression": "(100000 + 50000) * 1.1"
  }'

レスポンス例:

{
  "expression": "(100000 + 50000) * 1.1",
  "variables": null,
  "result": 165000,
  "result_str": "165000",
  "precision": null
}

変数バインディングを使った複利計算の例:

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/math/eval" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "expression": "principal * (1 + rate)^years",
    "variables": {
      "principal": 1000000,
      "rate": 0.05,
      "years": 10
    },
    "precision": 0
  }'

レスポンス例:

{
  "expression": "principal * (1 + rate)^years",
  "variables": {
    "principal": 1000000,
    "rate": 0.05,
    "years": 10
  },
  "result": 1628895,
  "result_str": "1628895",
  "precision": 0
}

数学関数(ピタゴラスの定理)の例:

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/math/eval" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "expression": "sqrt(x^2 + y^2)",
    "variables": {
      "x": 3,
      "y": 4
    }
  }'

レスポンス例:

{
  "expression": "sqrt(x^2 + y^2)",
  "variables": {
    "x": 3,
    "y": 4
  },
  "result": 5,
  "result_str": "5",
  "precision": null
}

Semverバージョン比較

セマンティックバージョン(semver)の比較・ソート・レンジ判定を行います。1.10.0 > 1.9.0 のように文字列比較では誤るケースを正しく処理します。prerelease版や ^1.0.0 などのレンジ指定にも対応。

MCPツール名: compare_versions

POST /v1/version/compare

パラメータ:

パラメータ必須説明
versionsstring[]-ソート・latest取得対象のバージョン一覧(最大100件)
comparestring-比較元バージョン(against とセットで指定)
againststring-比較先バージョン(compare とセットで指定)
include_prereleaseboolean-sorted/latest に prerelease を含めるか(デフォルト: false)
satisfiesobject-レンジパターンとチェック対象バージョンのマップ(キー=range、値=version)

レスポンスフィールド:

パラメータ説明
comparestringリクエストの compare(指定時のみ)
againststringリクエストの against(指定時のみ)
resultnumber比較結果: 1=compareが新しい / 0=同じ / -1=compareが古い(指定時のみ)
result_labelstringresult の文字列表現: greater / equal / less(指定時のみ)
sortedstring[]versions を昇順ソートした結果(versions 指定時のみ)
latest_stablestring | null最も新しい安定版(versions 指定時のみ)
satisfiesobject各 range を満たすかの判定結果(satisfies 指定時のみ)

2バージョンの大小比較:

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/version/compare" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "compare": "1.10.0",
    "against": "1.9.0"
  }'

レスポンス例:

{
  "compare": "1.10.0",
  "against": "1.9.0",
  "result": 1,
  "result_label": "greater"
}

ソート・比較・レンジ判定の複合例:

リクエスト例:

curl -X POST "https://api.thousand-api.com/v1/version/compare" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "versions": ["1.9.0", "1.10.0", "2.0.0-beta.1", "2.0.0"],
    "compare": "2.0.0",
    "against": "1.10.0",
    "include_prerelease": false,
    "satisfies": {
      "^1.9.0": "1.10.0",
      ">=2.0.0": "2.0.0-beta.1"
    }
  }'

レスポンス例:

{
  "compare": "2.0.0",
  "against": "1.10.0",
  "result": 1,
  "result_label": "greater",
  "sorted": ["1.9.0", "1.10.0", "2.0.0"],
  "latest_stable": "2.0.0",
  "satisfies": {
    "^1.9.0": true,
    ">=2.0.0": false
  }
}