robtex

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2023 License: MIT Imports: 7 Imported by: 0

README

Robtex API

A simple Robtex API client.

Examples

Free JSON API
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/electrologue/robtex"
)

func main() {
	client := robtex.New("")

	ctx := context.Background()

	ipQueryResponse, err := client.IPQuery(ctx, "199.19.54.1")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%#v\n", ipQueryResponse)

	asQueryResponse, err := client.ASQuery(ctx, "1234")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%#v\n", asQueryResponse)

	pDNSForward, err := client.PassiveDNSForward(ctx, "a.iana-servers.net")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%#v\n", pDNSForward)

	pDNSReverse, err := client.PassiveDNSReverse(ctx, "199.43.132.53")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%#v\n", pDNSReverse)
}
Pro JSON API
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/electrologue/robtex"
)

func main() {
	client := robtex.New("my_api_key")

	ctx := context.Background()

	ipQueryResponse, err := client.IPQuery(ctx, "199.19.54.1")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%#v\n", ipQueryResponse)

	asQueryResponse, err := client.ASQuery(ctx, "1234")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%#v\n", asQueryResponse)

	pDNSForward, err := client.PassiveDNSForward(ctx, "a.iana-servers.net")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%#v\n", pDNSForward)

	pDNSReverse, err := client.PassiveDNSReverse(ctx, "199.43.132.53")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%#v\n", pDNSReverse)
}

Documentation

Overview

Package robtex a simple Robtex API client. https://www.robtex.com/api/

Index

Constants

View Source
const (
	FreeAPIBaseURL = "https://freeapi.robtex.com"
	ProAPIBaseURL  = "https://proapi.robtex.com"
)

API endpoints.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASQueryResponse

type ASQueryResponse struct {
	Status string   `json:"status"`
	Nets   []Prefix `json:"nets"`
}

ASQueryResponse asquery response type.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client a Robtex API client.

func New

func New(apiKey string) *Client

New created a new Client.

func (Client) ASQuery

func (c Client) ASQuery(ctx context.Context, number string) (*ASQueryResponse, error)

ASQuery Returns an array of networks related to a specific AS number. Currently, only returns networks actually in global bgp table, but plans are to extend it. ex: https://freeapi.robtex.com/asquery/1234

func (Client) IPQuery

func (c Client) IPQuery(ctx context.Context, ip string) (*IPQueryResponse, error)

IPQuery This API returns the current forward and reverse of an IP number, together with GEO-location data and network data. The format returned is JSON. Most keys are self-explanatory. ex: https://freeapi.robtex.com/ipquery/199.19.54.1

func (Client) PassiveDNSForward

func (c Client) PassiveDNSForward(ctx context.Context, domain string) ([]PassiveDNS, error)

PassiveDNSForward This API returns ldjson format, that is one JSON object per line. The format used is Passive DNS - Common Output Format (https://tools.ietf.org/html/draft-dulaunoy-dnsop-passive-dns-cof-03). ex: https://freeapi.robtex.com/pdns/forward/a.iana-servers.net

func (Client) PassiveDNSReverse

func (c Client) PassiveDNSReverse(ctx context.Context, ip string) ([]PassiveDNS, error)

PassiveDNSReverse This API returns ldjson format, that is one JSON object per line. The format used is Passive DNS - Common Output Format (https://tools.ietf.org/html/draft-dulaunoy-dnsop-passive-dns-cof-03). ex: https://freeapi.robtex.com/pdns/reverse/199.43.132.53

type IPQueryResponse

type IPQueryResponse struct {
	Status            string `json:"status"`
	City              string `json:"city"`
	Country           string `json:"country"`
	AS                int    `json:"as"`
	ASName            string `json:"asname"`
	Whois             string `json:"whoisdesc"`
	Route             string `json:"routedesc"`
	BGPRoute          string `json:"bgproute"`
	ActiveForwardDNS  []Item `json:"act"`
	ActiveDNSHistory  []Item `json:"acth"`
	PassiveReverseDNS []Item `json:"pas"`
	PassiveDNSHistory []Item `json:"pash"`
}

IPQueryResponse ipquery response type.

type Item

type Item struct {
	O         string `json:"o"`
	Timestamp int    `json:"t"`
}

Item IP item.

type PassiveDNS

type PassiveDNS struct {
	RRName    string `json:"rrname"`
	RRData    string `json:"rrdata"`
	RRType    string `json:"rrtype"`
	TimeFirst int    `json:"time_first"`
	TimeLast  int    `json:"time_last"`
	Count     int    `json:"count"`
}

PassiveDNS pdns response type.

type Prefix

type Prefix struct {
	N     string `json:"n"`
	InBGP int    `json:"inbgp"`
}

Prefix AS prefix.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL