API
Quattro endpoint: richiedere l'URL di upload, creare il task, leggere il risultato, ritentare un task fallito. Con regole dei parametri, stati ed errori.
POST
API di caricamento immagini
/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
- Gli utenti a pagamento possono usare l’API
- Chiama questo endpoint con la tua chiave API per ottenere un URL temporaneo di caricamento R2 e l’URL pubblico dell’immagine
- Carica il file con PUT usando lo stesso Content-Type, poi usa fileurl come input nell’API di ingrandimento
- URL di base:
https://bigjpg.com
POST
API di Ingrandimento
/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())
- Formato JSON
- style puo essere ’art', 'photo' che significa 'illustrazione', 'foto'
- noise puo essere ’-1', '0', '1', '2', '3' che significa 'Nessuna', 'Bassa', 'Media', 'Alta', 'Massima'
- x2 puo essere ’1', '2', '3', '4' che significa 2x, 4x, 8x, 16x
- inserisci l’url dell’immagine da ingrandire
- Una chiamata riuscita restituisce tid (id del task), minute (tempo stimato) e remaining_api_calls (chiamate residue).
GET
API di Query Risultati
/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())
- Puoi passare più id separati da virgole — fino a 100 per richiesta.
- Ogni task torna come {"status": ..., "url": ..., "size": ...}; status è new, process, success o error.
- url e size restano vuoti finché il task non è concluso.
POST
API di Riprocessamento
/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())
Risposte di errore
status
- valid_api_key_required — l'header X-API-KEY manca o non è riconosciuto. Controlla il nome dell'header e che la chiave appartenga a un account a pagamento attivo.
- requires_vip — l'account è gratuito o scaduto. L'API richiede un piano a pagamento attivo.
- month_limit — la quota mensile è esaurita. Ogni chiamata riuscita restituisce remaining_api_calls, così puoi controllarla in anticipo.
- param_error — parametri fuori intervallo: style deve essere art o photo, noise da -1 a 3, x2 da 1 a 4 (1 a 2 con account gratuito).
- input_url_error — input deve essere un URL immagine http:// o https:// raggiungibile pubblicamente.
X-API-KEY: Gli utenti a pagamento possono usare l’API
Contattaci tramite i@bigjpg.com per ulteriori chiamate API