Skip to content

A Go library for interacting with MACLookup's API v2

License

Notifications You must be signed in to change notification settings

logocomune/maclookup-go

Repository files navigation

maclookup-go

CircleCI Go Report Card codecov CodeFactor

A Go library for interacting with MACLookup's API v2. This library allows you to:

  • Get full info (MAC prefix, company name, address and country) of a MAC address
  • Get Company name by MAC

Installation

You need a working Go environment.

 go get github.com/logocomune/maclookup-go

##Getting Started

package main

import (
	"log"

	"github.com/logocomune/maclookup-go"
)

func main() {
	client := maclookup.New()
    
	r, err := client.CompanyName("000000")

	if err != nil {
		log.Fatal(err)
	}

	log.Println("MAC found in database:", r.Found)
	log.Println("MAC is private (no company name):", r.IsPrivate)
	log.Println("Company name:", r.Company)
	log.Println("Api response in: ", r.RespTime)
	log.Println("Rate limits - remaining request for current time window:", r.RateLimit.Remaining)
	log.Println("Rate limits - next reset", r.RateLimit.Reset)

}

Use custom timout

    client := maclookup.New()
    client.WithTimeout(10*time.Second) 

API Key

Get an API Key here

    client := maclookup.New()
	client.WithAPIKey("an_api_key")

Example