Skip to content

About

moonito-go is a lightweight Go SDK for integrating Moonito's visitor analytics and filtering platform. Protect your web applications from bots, crawlers, and malicious traffic while gaining real-time visitor insights. Compatible with Echo, Gin, Fiber, and other Go frameworks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

Moonito Go SDK (moonito-go)

Official Go SDK for Moonito — a smart analytics and visitor filtering platform designed to protect your website from unwanted traffic, bots, and malicious activity while providing deep visitor insights.

Go Reference Go Report Card License: MIT


Overview

moonito-go is a lightweight Go SDK for integrating your web application with the Moonito Visitor Analytics API.
It allows you to:

  • Analyze and monitor web traffic intelligently
  • Filter out bots, crawlers, and unwanted visitors
  • Get real-time visitor behavior insights
  • Protect APIs, landing pages, and web apps automatically

Compatible with Echo, Gin, Fiber, and other Go web frameworks.


Installation

Initialize your Go module (if you haven’t yet):

go mod init github.com/yourusername/yourproject

Then install the SDK:

go get github.com/moonito-net/moonito-go

Quick Start (net/http)

package main

import (
	"log"
	"net/http"

	moonito "github.com/moonito-net/moonito-go"
)

func main() {
	client := moonito.New(moonito.Config{
		IsProtected:           true,
		APIPublicKey:          "YOUR_PUBLIC_KEY",
		APISecretKey:          "YOUR_SECRET_KEY",
		UnwantedVisitorTo:     "https://example.com/blocked", // URL or HTTP status code
		UnwantedVisitorAction: 1,                             // 1 = Redirect, 2 = Iframe, 3 = Load content
	})

	mux := http.NewServeMux()
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("Hello, World!"))
	})

	// Unwanted visitors are answered by Moonito and never reach your routes.
	log.Fatal(http.ListenAndServe(":8080", client.Middleware(mux)))
}

Quick Start (Echo)

import "github.com/moonito-net/moonito-go/middleware"

e := echo.New()
e.Use(middleware.EchoTrafficFilter(client))

If the check cannot run (the API is unreachable, or refuses because a plan expired) the visitor is let through and the reason is logged. Moonito never turns into an error page on your site.


Configuration Options

Field Type Description
IsProtected bool Enable (true) or disable (false) protection
APIPublicKey string Your Moonito API public key (required)
APISecretKey string Your Moonito API secret key (required)
UnwantedVisitorTo string URL to redirect unwanted visitors or HTTP error code
UnwantedVisitorAction int Action for unwanted visitors: 1 = Redirect, 2 = Iframe, 3 = Load content
TrustedProxies []string Optional. Public proxy or load balancer IPs/CIDRs whose X-Forwarded-For is trusted. Private proxies and Cloudflare are recognised automatically

Manual Evaluation (No Framework)

result, err := client.EvaluateVisitorManually("8.8.8.8", "Mozilla/5.0", "/home", "example.com")
if err != nil {
    fmt.Println("Error:", err)
}

if result.NeedToBlock {
    fmt.Println("Blocked visitor detected.")
}

Example Use Cases

  • Prevent fake signups and bot traffic
  • Protect landing pages from ad click fraud
  • Collect accurate visitor analytics
  • Detect suspicious activity in real time

Requirements


Development Setup

git clone https://github.com/moonito-net/moonito-go.git
cd moonito-go
go mod tidy
go run examples/main.go

Testing

go test ./...

License

MIT License © 2025 Moonito


Keywords

go analytics sdk, moonito sdk, visitor filtering go, go bot protection, go traffic analytics, moonito go sdk, moonito api, website protection sdk go, moonito visitor analytics, go security sdk


Learn More

Visit https://moonito.net to learn more about:

  • Visitor analytics
  • Website traffic protection
  • API-based bot and fraud filtering

Moonito — Stop Bad Bots. Start Accurate Web Analytics.

About

moonito-go is a lightweight Go SDK for integrating Moonito's visitor analytics and filtering platform. Protect your web applications from bots, crawlers, and malicious traffic while gaining real-time visitor insights. Compatible with Echo, Gin, Fiber, and other Go frameworks.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages