API

엔드포인트 네 개: 업로드 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
POST

확대 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())
GET

결과 조회 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())
POST

작업 재시도 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

X-API-KEY: 유료 회원은 API를 사용할 수 있습니다

더 많은 API 호출에 대해서는 i@bigjpg.com으로 문의해 주세요