Skip to content
A Go API client for HackerOne (api.hackerone.com)
Go
Branch: master
Clone or download
aegarbutt Merge pull request #17 from bored-engineer/program
Add ProgramService and update related structs
Latest commit bc8cb11 Dec 13, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
_examples Add getProgram example Nov 25, 2016
h1 Merge pull request #17 from bored-engineer/program Dec 12, 2016
legacy
polling
.gitignore Add default GitHub gitignore Aug 1, 2016
.travis.yml Only build coverage for h1 subpackage for now Aug 1, 2016
LICENSE.txt
README.md Callout structs in README.md Aug 1, 2016

README.md

hackeroni GoDoc Build Status Coverage Status

A Go interface around api.hackerone.com.

Usage

import "github.com/uber-go/hackeroni/h1"

To list all reports matching a filter:

reports, _, err := client.Report.List(h1.ReportListFilter{
	Program: []string{"uber"},
})
if err != nil {
	panic(err)
}
for _, report := range reports {
	fmt.Println("Report Title:", *report.Title)
}

To retrieve a specific report:

report, _, err := client.Report.Get("123456")
if err != nil {
	panic(err)
}
fmt.Println("Report Title:", *report.Title)

Authentication

The h1 library does not directly handle authentication. Instead, when creating a new client, you can pass a http.Client that handles authentication for you. It does provide a APIAuthTransport structure when using API Token authentication. It is used like this:

tp := h1.APIAuthTransport{
	APIIdentifier: "your-h1-api-token-identifier",
	APIToken: "big-long-api-token-from-h1",
}

client := h1.NewClient(tp.Client())

Pagination

All requests for listing resources such as Report support pagination. Pagination options are described in the h1.ListOptions struct and passed to the list methods as an optional parameter. Pages information is available via the h1.ResponseLinks struct embedded in the h1.Response struct.

filter := h1.ReportListFilter{
	Program: []string{"uber"},
}
var listOpts h1.ListOptions

var allReports []h1.Report
for {
	reports, resp, err := client.Report.List(filter, &listOpts)
	if err != nil {
		panic(err)
	}
	allReports = append(allReports, reports...)
	if resp.Links.Next == "" {
		break
	}
	listOpts.Page = resp.Links.NextPageNumber()
}
You can’t perform that action at this time.