go-dol-healthsafety provides programmatic access to the United States Department of Labor Health & Safety datasets API.
This library is currently a work in progress and only provides access to the datasets listed in Provided Endpoints.
go get github.com/gmccue/go-dol-healthsafety
In order to use this library, you must have a valid API token for the DOL Public API. You can register for an API key at the US DOL website.
Important: By default, the first 100 results will be returned per request. In order to retrieve additional data, you must use query filters and paginate through the dataset. See the Filters section for more information.
import (
"log"
hstats "github.com/gmccue/go-dol-healthsafety"
)
func main() {
api := hstats.New("{my_secret_key}")
api.Debug = true
basicMineInfo, err := api.QueryAddressOfRecord()
if err != nil {
log.Println(err)
}
log.Printf("%v", basicMineInfo)
}
A description of available filters can be found here.
Filters can be applied by using the AddFilter()
method. For example:
import strconv
// Paginate API results: 10 results per page, first 10 pages.
resultsPerPage := 10
for p := 0; p < 10; p++ {
top := strconv.Itoa(resultsPerPage)
skip := strconv.Itoa(p * resultsPerPage)
api.AddFilter("top", top)
api.AddFilter("skip", skip)
}
These queries provide access to the Auto Workers API endpoint.
ccr, err := api.QueryCarClosedRepurposed()
These queries provide access to the Basic Mine Information API endpoint.
aor, err := api.QueryAddressOfRecord()
These queries provide access to the DOL OSHA Compliance API endpoint.
of, err := api.QueryOSHAFatalities()
These queries provide access to the the Full Mine Information API endpoint.
fm, err := api.QueryFullMineInfo()
These queries provide access to the Fatal Occupational Injuries API endpoints.
a, err := api.QueryFIArea()
c, err := api.QueryFICase()
c, err := api.QueryFICategory()
c2, err := api.QueryFICategory2()
dp, err := api.QueryFIDataPub()
dt, err := api.QueryFIDataType()
e, err := api.QueryFIEvent()
f, err := api.QueryFIFootnote()
gc, err := api.QueryFIGQTCase()
gc, err := api.QueryFIGQTChar()
gco, err := api.QueryFIGQTCharOwnership()
go, err := api.QueryFIGQTOwnership()
gs, err := api.QueryFIGQTState()
gso, err := api.QueryFIGQTStateOwnership()
i, err := api.QueryFIIndustry()
s, err := api.QueryFISeries()
These queries provide access to the the Gulf Oil Spill API endpoint.
dr, err := api.QueryOSHADirectReadSampling()
on, err := api.QueryOSHANoiseReport()
These queries provide access to the the Mine Accident Injuries API endpoint.
ma, err := api.QueryMineAccidents()
These queries provide access to the Mine Inspections API endpoint.
ep, err := api.QueryMineInspections()
These queries provide access to the Mine Violation API endpoint.
mv, err := api.QueryMineViolations()
These queries provide access to the MSHA Employment Production API endpoint.
ep, err := api.QueryMSHAEmploymentProduction()