Service Api's


package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
	"os"
)

const (
	API_KEY = "YOUR API"
	ZODIAK  = "YOUR ZODIAC"
	ENDPOINT = "https://senpai-bot.store/zodiac"
)

type Result struct {
	Code   int `json:"code"`
	Result struct {
		Hasil  string `json:"hasil"`
		Zodiak string `json:"zodiak"`
	} `json:"result"`
}

func main() {
	encodedZodiak := url.QueryEscape(ZODIAK)
	fullURL := fmt.Sprintf("%s?apikey=%s&url=%s", ENDPOINT, API_KEY, encodedZodiak)

	resp, err := http.Get(fullURL)
	if err != nil {
		fmt.Println("Gagal request:", err)
		return
	}
	defer resp.Body.Close()

	var data Result
	if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
		fmt.Println("Gagal parsing JSON.")
		return
	}

	if data.Code != 200 {
		fmt.Printf("API error code: %d\n", data.Code)
		return
	}

	if data.Result.Hasil != "" {
		fmt.Println("Arti Zodiak:")
		fmt.Println("Zodiak :", data.Result.Zodiak)
		fmt.Println("Deskripsi :", data.Result.Hasil)
	} else {
		fmt.Println("Tidak ada hasil ditemukan.")
	}
}