API
Vier Endpunkte: Upload-URL anfordern, Vergrößerungsauftrag anlegen, Ergebnis abfragen, fehlgeschlagenen Auftrag wiederholen. Inklusive Parameterregeln, Status und Fehlerantworten.
POST
API zum Bild-Upload
/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
- Zahlende Mitglieder können die API nutzen
- Rufen Sie diesen Endpunkt mit Ihrem API-Schlüssel auf, um eine temporäre R2-Upload-URL und die öffentliche Bild-URL zu erhalten
- Laden Sie die Datei per PUT mit demselben Content-Type hoch und verwenden Sie fileurl als input in der Vergrößerungs-API
- Basis-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
- Eine erfolgreiche Anfrage liefert tid (Auftrags-ID), minute (geschätzte Dauer) und remaining_api_calls (Restkontingent).
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())
- Mehrere Aufgaben-IDs lassen sich mit Kommas übergeben — bis zu 100 pro Anfrage.
- Jede Aufgabe kommt als {"status": ..., "url": ..., "size": ...} zurück; status ist new, process, success oder error.
- url und size bleiben leer, bis die Aufgabe fertig ist.
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())
Fehlerantworten
status
- valid_api_key_required — der Header X-API-KEY fehlt oder wird nicht erkannt. Prüfen Sie den Header-Namen und ob der Key zu einem aktiven bezahlten Konto gehört.
- requires_vip — das Konto ist kostenlos oder abgelaufen. Für die API ist ein aktiver bezahlter Plan nötig.
- month_limit — das Monatskontingent ist aufgebraucht. Jeder erfolgreiche Aufruf meldet remaining_api_calls, so sehen Sie es vorher.
- param_error — Parameter außerhalb des Bereichs: style muss art oder photo sein, noise -1 bis 3, x2 1 bis 4 (kostenlos 1 bis 2).
- input_url_error — input muss eine öffentlich erreichbare Bild-URL mit http:// oder https:// sein.
X-API-KEY: Zahlende Mitglieder können die API nutzen
Kontaktieren Sie uns i@bigjpg.com für mehr API calls