Arti Nama API for Go.
Clean example request for the name meaning feature endpoint. Replace YOUR API and the name input, then run the code.
Checking
Clean example request for the name meaning feature endpoint. Replace YOUR API and the name input, then run the code.
package main
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"os"
"time"
)
const (
API_KEY = "YOUR API"
NAMA = "YOUR NAME"
ENDPOINT = "https://senpai-bot.store/artinama"
)
type Response struct {
Code int `json:"code"`
Result struct {
Hasil string `json:"hasil"`
} `json:"result"`
Message string `json:"message"`
}
func main() {
encodedName := url.QueryEscape(NAMA)
fullURL := fmt.Sprintf("%s?apikey=%s&url=%s", ENDPOINT, API_KEY, encodedName)
client := http.Client{Timeout: 10 * time.Second}
resp, err := client.Get(fullURL)
if err != nil {
fmt.Println("Gagal request:", err)
os.Exit(1)
}
defer resp.Body.Close()
var data Response
if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
fmt.Println("Gagal parsing JSON:", err)
os.Exit(1)
}
if data.Code != 200 {
fmt.Printf("API error code: %d - %s\n", data.Code, data.Message)
os.Exit(1)
}
if data.Result.Hasil != "" {
fmt.Println("Arti Nama:")
fmt.Println(data.Result.Hasil)
} else {
fmt.Println("Tidak ada hasil ditemukan.")
}
}