Documentation
¶
Overview ¶
Package nihreporter is the library behind the nihreporter command line: the HTTP client, request shaping, and the typed data models for the NIH Reporter API.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public API throws under load. Build your endpoint calls and JSON decoding on top of it.
Index ¶
- Constants
- type Client
- func (c *Client) GetProject(ctx context.Context, projectNum string) (*Project, error)
- func (c *Client) SearchByOrg(ctx context.Context, orgName string, limit, offset int) ([]*Project, int, error)
- func (c *Client) SearchByPI(ctx context.Context, lastName string, limit, offset int) ([]*Project, int, error)
- func (c *Client) SearchProjects(ctx context.Context, query string, limit, offset int) ([]*Project, int, error)
- type Config
- type Domain
- type Project
Constants ¶
const Host = "reporter.nih.gov"
Host is the NIH Reporter site, used for Locate / URI resolution.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client talks to the NIH Reporter API over HTTP.
func NewClientWithConfig ¶
NewClientWithConfig returns a Client using the given config.
func (*Client) GetProject ¶
GetProject fetches a single project by project number.
func (*Client) SearchByOrg ¶
func (c *Client) SearchByOrg(ctx context.Context, orgName string, limit, offset int) ([]*Project, int, error)
SearchByOrg searches grants by organization name.
type Config ¶
type Config struct {
BaseURL string
Rate time.Duration
Retries int
Timeout time.Duration
UserAgent string
}
Config carries the tunable parameters for the NIH Reporter client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults for the NIH Reporter API.
type Domain ¶
type Domain struct{}
Domain is the nihreporter driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Classify ¶
Classify turns any accepted input into the canonical (type, id). Any non-empty string is treated as a project number.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Project ¶
type Project struct {
ID int `json:"id" kit:"id"` // appl_id
ProjectNum string `json:"project_num"`
Title string `json:"title"`
Abstract string `json:"abstract,omitempty"`
FiscalYear int `json:"fiscal_year,omitempty"`
AwardAmount int64 `json:"award_amount,omitempty"`
StartDate string `json:"start_date,omitempty"`
EndDate string `json:"end_date,omitempty"`
PINames []string `json:"pi_names,omitempty"`
OrgName string `json:"org_name,omitempty"`
OrgState string `json:"org_state,omitempty"`
ActivityCode string `json:"activity_code,omitempty"`
Agency string `json:"agency,omitempty"`
Terms []string `json:"terms,omitempty"`
}
Project is an NIH research grant record.