fbi

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: MIT Imports: 9 Imported by: 0

README ¶

fbi

import "github.com/brittonhayes/fbi"

fbi is a Go client for the FBI's Most Wanted REST API 🚔

Installation
go get -u github.com/brittonhayes/fbi
Usage
func main() {
	// Initialize fugitives
	f := new(fbi.Fugitives)

	// List the fugitives
	err := f.List()
	if err != nil {
	    // handle error
		panic(err)
	}

	// Print raw results
	fmt.Println(f)

	// Print specific items from the list of results
	fmt.Println(f.Items[0])

}
Pretty Print Results
func main() {
	// Initialize fugitives
	f := new(fbi.Fugitives)

	// List the fugitives as pretty-printed json
	j, err := f.ListPretty()
	if err != nil {
		panic(err)
	}

	// Print out the results
	fmt.Println(string(j))

}
Reference

Source API: https://api.fbi.gov/wanted/v1/list

Index

Constants

const (
    BaseURL = "https://api.fbi.gov/wanted/v1"
)

type Downloader

Downloader allows locally downloading the remote files and images from their URLs

type Downloader interface {
    Download(filename string) error
}

type FBI

FBI contains the methods available to the Individual type

type FBI interface {
    List() error
    ListPretty() ([]byte, error)
    Find(opt *Options) error
}

type Files

Files are any related files available pertaining to the individual

type Files struct {
    Name string `json:"name"`
    URL  string `json:"url"`
}
func (Files) Download
func (f Files) Download(filename string) error

Download files to a file from the URLs provided

type Fugitives

Fugitives is the base structure for the FBI most wanted REST API response and contains a list of individuals as well as the total items found

type Fugitives struct {
    Total int          `json:"total"`
    Items []Individual `json:"items"`
}
func (*Fugitives) Find
func (f *Fugitives) Find(opt *Options) error

Find all fugitives matching the parameters provided in the opt struct

func (*Fugitives) List
func (f *Fugitives) List() error

List all fugitives from the Most Wanted API

func (*Fugitives) ListPretty
func (f *Fugitives) ListPretty() ([]byte, error)

ListPretty lists all fugitives from the Most Wanted API and then auto formats results as pretty-printed JSON

type Images

Images are the pictures available of the individual

type Images struct {
    Large    string      `json:"large"`
    Caption  interface{} `json:"caption"`
    Original string      `json:"original"`
    Thumb    string      `json:"thumb"`
}
func (Images) Download
func (i Images) Download(filename string) error

Download images to a file from the URLs provided

type Individual

Individual represents a single person in the FBI most wanted list

type Individual struct {
    Images                []Images      `json:"images"`
    Occupations           interface{}   `json:"occupations"`
    DatesOfBirthUsed      interface{}   `json:"dates_of_birth_used"`
    WeightMax             interface{}   `json:"weight_max"`
    AgeMax                interface{}   `json:"age_max"`
    AgeRange              interface{}   `json:"age_range"`
    AdditionalInformation interface{}   `json:"additional_information"`
    WeightMin             interface{}   `json:"weight_min"`
    RewardText            string        `json:"reward_text"`
    Aliases               interface{}   `json:"aliases"`
    UID                   string        `json:"uid"`
    HairRaw               interface{}   `json:"hair_raw"`
    Race                  interface{}   `json:"race"`
    RaceRaw               interface{}   `json:"race_raw"`
    Eyes                  interface{}   `json:"eyes"`
    Hair                  interface{}   `json:"hair"`
    Sex                   interface{}   `json:"sex"`
    Languages             interface{}   `json:"languages"`
    WarningMessage        interface{}   `json:"warning_message"`
    PossibleCountries     interface{}   `json:"possible_countries"`
    Remarks               interface{}   `json:"remarks"`
    Build                 interface{}   `json:"build"`
    HeightMin             interface{}   `json:"height_min"`
    Suspects              interface{}   `json:"suspects"`
    Publication           string        `json:"publication"`
    Status                string        `json:"status"`
    Subjects              []string      `json:"subjects"`
    Title                 string        `json:"title"`
    ScarsAndMarks         interface{}   `json:"scars_and_marks"`
    Path                  string        `json:"path"`
    PossibleStates        interface{}   `json:"possible_states"`
    Nationality           interface{}   `json:"nationality"`
    Files                 []Files       `json:"files"`
    Coordinates           []interface{} `json:"coordinates"`
    PersonClassification  string        `json:"person_classification"`
    Description           string        `json:"description"`
    PlaceOfBirth          interface{}   `json:"place_of_birth"`
    HeightMax             interface{}   `json:"height_max"`
    Locations             interface{}   `json:"locations"`
    Caution               interface{}   `json:"caution"`
    EyesRaw               interface{}   `json:"eyes_raw"`
    Ncic                  interface{}   `json:"ncic"`
    LegatNames            interface{}   `json:"legat_names"`
    Complexion            interface{}   `json:"complexion"`
    FieldOffices          []string      `json:"field_offices"`
    RewardMin             int           `json:"reward_min"`
    RewardMax             int           `json:"reward_max"`
    AgeMin                interface{}   `json:"age_min"`
    URL                   string        `json:"url"`
    Details               string        `json:"details"`
    Modified              time.Time     `json:"modified"`
    Weight                interface{}   `json:"weight"`
    ID                    string        `json:"@id"`
}

type Options

Options contains the available query params for filter API request results

type Options struct {
    Title                string `url:"title"`
    FieldOffices         string `url:"field_offices"`
    Status               string `url:"status"`
    PersonClassification string `url:"person_classification"`
    Page                 int    `url:"page"`
    Limit                int    `url:"pageSize"`
    SortOn               string `url:"sort_on"`
    SortOrder            string `url:"sort_order"`
}

Generated by gomarkdoc

Documentation ¶

Overview ¶

fbi is a Go client for the FBI's Most Wanted REST API 🚔

Installation

go get -u github.com/brittonhayes/fbi

Usage

func main() {
	// Initialize fugitives
	f := new(fbi.Fugitives)

	// List the fugitives
	err := f.List()
	if err != nil {
	    // handle error
		panic(err)
	}

	// Print raw results
	fmt.Println(f)

	// Print specific items from the list of results
	fmt.Println(f.Items[0])

}

Pretty Print Results

func main() {
	// Initialize fugitives
	f := new(fbi.Fugitives)

	// List the fugitives as pretty-printed json
	j, err := f.ListPretty()
	if err != nil {
		panic(err)
	}

	// Print out the results
	fmt.Println(string(j))

}

Reference ¶

Source API: https://api.fbi.gov/wanted/v1/list

Index ¶

Constants ¶

View Source
const (
	BaseURL = "https://api.fbi.gov/wanted/v1"
)

Variables ¶

This section is empty.

Functions ¶

This section is empty.

Types ¶

type Downloader ¶

type Downloader interface {
	Download(filename string) error
}

Downloader allows locally downloading the remote files and images from their URLs

type FBI ¶

type FBI interface {
	List() error
	ListPretty() ([]byte, error)
	Find(opt *Options) error
}

FBI contains the methods available to the Individual type

type Files ¶

type Files struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

Files are any related files available pertaining to the individual

func (Files) Download ¶

func (f Files) Download(filename string) error

Download files to a file from the URLs provided

type Fugitives ¶

type Fugitives struct {
	Total int          `json:"total"`
	Items []Individual `json:"items"`
}

Fugitives is the base structure for the FBI most wanted REST API response and contains a list of individuals as well as the total items found

func (*Fugitives) Find ¶

func (f *Fugitives) Find(opt *Options) error

Find all fugitives matching the parameters provided in the opt struct

func (*Fugitives) List ¶

func (f *Fugitives) List() error

List all fugitives from the Most Wanted API

func (*Fugitives) ListPretty ¶

func (f *Fugitives) ListPretty() ([]byte, error)

ListPretty lists all fugitives from the Most Wanted API and then auto formats results as pretty-printed JSON

type Images ¶

type Images struct {
	Large    string      `json:"large"`
	Caption  interface{} `json:"caption"`
	Original string      `json:"original"`
	Thumb    string      `json:"thumb"`
}

Images are the pictures available of the individual

func (Images) Download ¶

func (i Images) Download(filename string) error

Download images to a file from the URLs provided

type Individual ¶

type Individual struct {
	Images                []Images      `json:"images"`
	Occupations           interface{}   `json:"occupations"`
	DatesOfBirthUsed      interface{}   `json:"dates_of_birth_used"`
	WeightMax             interface{}   `json:"weight_max"`
	AgeMax                interface{}   `json:"age_max"`
	AgeRange              interface{}   `json:"age_range"`
	AdditionalInformation interface{}   `json:"additional_information"`
	WeightMin             interface{}   `json:"weight_min"`
	RewardText            string        `json:"reward_text"`
	Aliases               interface{}   `json:"aliases"`
	UID                   string        `json:"uid"`
	HairRaw               interface{}   `json:"hair_raw"`
	Race                  interface{}   `json:"race"`
	RaceRaw               interface{}   `json:"race_raw"`
	Eyes                  interface{}   `json:"eyes"`
	Hair                  interface{}   `json:"hair"`
	Sex                   interface{}   `json:"sex"`
	Languages             interface{}   `json:"languages"`
	WarningMessage        interface{}   `json:"warning_message"`
	PossibleCountries     interface{}   `json:"possible_countries"`
	Remarks               interface{}   `json:"remarks"`
	Build                 interface{}   `json:"build"`
	HeightMin             interface{}   `json:"height_min"`
	Suspects              interface{}   `json:"suspects"`
	Publication           string        `json:"publication"`
	Status                string        `json:"status"`
	Subjects              []string      `json:"subjects"`
	Title                 string        `json:"title"`
	ScarsAndMarks         interface{}   `json:"scars_and_marks"`
	Path                  string        `json:"path"`
	PossibleStates        interface{}   `json:"possible_states"`
	Nationality           interface{}   `json:"nationality"`
	Files                 []Files       `json:"files"`
	Coordinates           []interface{} `json:"coordinates"`
	PersonClassification  string        `json:"person_classification"`
	Description           string        `json:"description"`
	PlaceOfBirth          interface{}   `json:"place_of_birth"`
	HeightMax             interface{}   `json:"height_max"`
	Locations             interface{}   `json:"locations"`
	Caution               interface{}   `json:"caution"`
	EyesRaw               interface{}   `json:"eyes_raw"`
	Ncic                  interface{}   `json:"ncic"`
	LegatNames            interface{}   `json:"legat_names"`
	Complexion            interface{}   `json:"complexion"`
	FieldOffices          []string      `json:"field_offices"`
	RewardMin             int           `json:"reward_min"`
	RewardMax             int           `json:"reward_max"`
	AgeMin                interface{}   `json:"age_min"`
	URL                   string        `json:"url"`
	Details               string        `json:"details"`
	Modified              time.Time     `json:"modified"`
	Weight                interface{}   `json:"weight"`
	ID                    string        `json:"@id"`
}

Individual represents a single person in the FBI most wanted list

type Options ¶

type Options struct {
	Title                string `url:"title"`
	FieldOffices         string `url:"field_offices"`
	Status               string `url:"status"`
	PersonClassification string `url:"person_classification"`
	Page                 int    `url:"page"`
	Limit                int    `url:"pageSize"`
	SortOn               string `url:"sort_on"`
	SortOrder            string `url:"sort_order"`
}

Options contains the available query params for filter API request results

Directories ¶

Path Synopsis

Jump to

Keyboard shortcuts

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