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
- 유료 회원은 API를 사용할 수 있습니다
- 임시 R2 업로드 URL과 공개 이미지 URL을 받으려면 API 키와 함께 이 엔드포인트를 호출하세요
- 같은 Content-Type으로 PUT을 사용해 파일을 업로드한 다음 fileurl을 확대 API의 input으로 사용하세요
- 기본 URL:
https://bigjpg.com
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())
- JSON 형식
- style은 'art', 'photo'로 설정할 수 있으며 '만화 일러스트레이션', '사진'을 의미합니다
- noise는 '-1', '0', '1', '2', '3'으로 설정할 수 있으며 '없음', '낮음', '중간', '높음', '최고'를 의미합니다
- x2는 '1', '2', '3', '4'로 설정할 수 있으며 2배, 4배, 8배, 16배를 의미합니다
- 확대할 이미지 URL 입력
- 성공하면 tid(작업 id), minute(예상 시간), remaining_api_calls(남은 호출 수)가 돌아옵니다.
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())
- 작업 id를 쉼표로 구분해 여러 개 넘길 수 있습니다. 한 요청에 최대 100개.
- 각 작업은 {"status": ..., "url": ..., "size": ...} 형태로 돌아오고 status는 new, process, success, error 중 하나입니다.
- 작업이 끝나기 전까지 url과 size는 비어 있습니다.
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
- 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:// 이미지 주소여야 합니다.
X-API-KEY: 유료 회원은 API를 사용할 수 있습니다
더 많은 API 호출에 대해서는 i@bigjpg.com으로 문의해 주세요