API

Bốn endpoint: xin URL tải lên, tạo tác vụ phóng to, kiểm tra kết quả, thử lại tác vụ lỗi. Kèm quy tắc tham số, trạng thái tác vụ và lỗi trả về.

POST

API tải ảnh lên

/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

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())
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())
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())

Phản hồi lỗi

status

X-API-KEY: Thành viên trả phí có thể sử dụng API

Liên hệ với chúng tôi theo i@bigjpg.com để biết thêm các lệnh gọi API