Skip to content

jpfyoder/go-usda-nass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-usda-nass

Go wrapper for the USDA's NASS service.

More information on the USDA's NASS API can be found in the official API documentation

Installation

Install the library with go get:

go get github.com/jpfyoder/go-usda-nass

Add the import statement to your project:

import (
        "github.com/jpfyoder/go-usda-nass"
)

Usage & Examples

Basic Usage

client := nass.NewClient("API-KEY-GOES-HERE")
fmt.Println(client.ParamValues("sector_desc"))
// [ANIMALS & PRODUCTS CROPS DEMOGRAPHICS ECONOMICS ENVIRONMENTAL]

Query the Database

query := nass.NewQuery(client)
query = query.Filter("commodity_desc", "CATTLE").Filter("statisticcat_desc", "INVENTORY")
query = query.Filter("year", "2010").Filter("agg_level_desc", "NATIONAL")
fmt.Println(query.Count())
// 109
fmt.Println(query.Execute())
// [map[CV (%): Value:2,744,600 agg_level_desc:NATIONAL ...

Applying Operators

query2 := nass.NewQuery(client)
query2 = query2.Filter("commodity_desc", "CORN").Filter("statisticcat_desc", "AREA PLANTED")
query2 = query2.FilterRange("year", "1925", "LT")
fmt.Println(query.Count())
// 86
fmt.Println(query.Execute())
// [map[CV (%): Value:118,200 agg_level_desc:AGRICULTURAL DISTRICT ...

About

Go wrapper for the USDA's NASS service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages