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 पाने के लिए इस endpoint को अपनी API key के साथ कॉल करें
- उसी Content-Type के साथ PUT द्वारा फ़ाइल अपलोड करें, फिर fileurl को enlarge 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' हो सकता है जिसका अर्थ है 'कार्टून इलस्ट्रेशन', 'photo'
- noise '-1', '0', '1', '2', '3' हो सकता है जिसका अर्थ है 'कोई नहीं', 'कम', 'मध्यम', 'उच्च', 'सर्वोच्च'
- x2 '1', '2', '3', '4' हो सकता है जिसका अर्थ है 2x, 4x, 8x, 16x
- अपनी एनलार्ज इमेज का 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 — महीने की API कोटा खत्म हो गई। हर सफल कॉल remaining_api_calls लौटाती है, इसलिए पहले से देख सकते हैं।
- param_error — पैरामीटर रेंज से बाहर: style art या photo, noise -1 से 3, x2 1 से 4 (फ्री अकाउंट में 1 से 2)।
- input_url_error — input को सार्वजनिक रूप से उपलब्ध http:// या https:// इमेज URL होना चाहिए।
X-API-KEY: सशुल्क सदस्य API का उपयोग कर सकते हैं
अधिक API कॉल के लिए हमसे i@bigjpg.com द्वारा संपर्क करें