API
エンドポイントは 4 つ。アップロード URL の発行、拡大タスクの作成、結果の取得、失敗時の再試行。パラメータの規則・タスクの状態・エラー応答もまとめています。
POST
画像アップロード API
/api/img_upload
cURL
curl -X POST https://bigjpg.com/api/img_upload \
-H 'X-API-KEY: YOUR_API_KEY' \
-d 'filename=small.jpg' \
-d 'filetype=image/jpeg'
# Use url from the response to upload the file to R2.
curl -X PUT --upload-file small.jpg \
-H 'Content-Type: image/jpeg' \
'UPLOAD_URL'
Python
import requests
filename = 'small.jpg'
filetype = 'image/jpeg'
r = requests.post(
url='https://bigjpg.com/api/img_upload',
headers={'X-API-KEY': 'YOUR_API_KEY'},
data={'filename': filename, 'filetype': filetype}
)
upload = r.json()
with open(filename, 'rb') as image:
requests.put(
url=upload['url'],
data=image,
headers={'Content-Type': filetype}
)
print(upload['fileurl']) # use as input in the enlarge API
- 有料会員は API を利用できます
- APIキーでこのエンドポイントを呼び出し、一時的なR2アップロードURLと公開画像URLを取得します
- 同じContent-TypeでPUTしてファイルをアップロードし、fileurlを拡大APIのinputに使用します
- ベース URL:
https://bigjpg.com
POST
Enlarge API
/api/task/
cURL
curl -d '{"style": "art", "noise": "3", "x2": "1", "input": "YOUR_IMAGE_URL"}' \
-H 'X-API-KEY: YOUR_API_KEY' \
https://bigjpg.com/api/task/
Python
import json
import requests
data = {
'style': 'art',
'noise': '3',
'x2': '1',
'file_name': 'small.jpg',
'input': 'YOUR_IMAGE_URL'
}
r = requests.post(
url='https://bigjpg.com/api/task/',
headers={'X-API-KEY': 'YOUR_API_KEY'},
data=json.dumps(data)
)
print(r.json())
- JSON format
- style can be 'art', 'photo' which means 'cartoon illustration', 'photo'
- noise can be '-1', '0', '1', '2', '3' which means 'None', 'Low, 'Medium', 'High', 'Highest'
- x2 can be '1', '2', '3', '4' which means 2x, 4x, 8x, 16x
- input your enlarge image url
- 成功すると tid(タスク ID)、minute(予想所要時間)、remaining_api_calls(残り呼び出し回数)が返ります。
GET
Result Query API
/api/task/{task_ids}
cURL
curl https://bigjpg.com/api/task/tid1,tid2,tid3,tid100
Python
import requests
r = requests.get(
url='https://bigjpg.com/api/task/tid1,tid2,tid3,tid100'
)
print(r.json())
- カンマ区切りで複数のタスク ID をまとめて指定できます(1 回あたり最大 100 件)。
- 各タスクは {"status": ..., "url": ..., "size": ...} の形で返ります。status は new / process / success / error。
- 完了するまで url と size は空です。
POST
Task retry API
/api/task/{task_ids}
cURL
curl -X POST https://bigjpg.com/api/task/tid1,tid2,tid3,tid100
Python
import requests
r = requests.post(
url='https://bigjpg.com/api/task/tid1,tid2,tid3,tid100'
)
print(r.json())
エラー応答
status
- valid_api_key_required — X-API-KEY ヘッダーがないか認識されていません。ヘッダー名と、有効期限が切れていない有料アカウントのキーかどうかを確認してください。
- requires_vip — 無料プランか期限切れのアカウントです。API には有効な有料プランが必要です。
- month_limit — 月間の呼び出し回数を使い切りました。成功時には remaining_api_calls が返るので、事前に気づけます。
- param_error — パラメータが範囲外です。style は art か photo、noise は -1〜3、x2 は 1〜4(無料アカウントは 1〜2)。
- input_url_error — input は外部からアクセスできる http:// または https:// の画像 URL にしてください。
X-API-KEY: 有料会員は API を利用できます
追加のAPIについてはお問い合わせください i@bigjpg.com