Random Pict API for Python.
Clean example request for the random picture feature endpoint. Replace YOUR API and amount input, then run the code.
Checking
Clean example request for the random picture feature endpoint. Replace YOUR API and amount input, then run the code.
import requests
API_KEY = "YOUR API"
JUMLAH = int
ENDPOINT = "https://senpai-bot.store/randompict"
def main():
full_url = f"{ENDPOINT}?apikey={API_KEY}&num={JUMLAH}"
try:
response = requests.get(full_url)
response.raise_for_status()
except requests.RequestException as e:
print(f"Gagal request: {e}")
return
try:
data = response.json()
except ValueError:
print("Gagal parsing JSON.")
return
if data.get("code") != 200:
print(f"API error code: {data.get('code')} - {data.get('message', 'Tidak diketahui')}")
return
hasil = data.get("result")
if hasil:
print("Hasil gambar:")
for url in hasil:
print(url)
else:
print("Tidak ada hasil ditemukan.")
if __name__ == "__main__":
main()