Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) AskStories() ([]int, error)
- func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)
- func (c *Client) Item(id int) (*Item, error)
- func (c *Client) JobStories() ([]int, error)
- func (c *Client) MaxItem() (int, error)
- func (c *Client) NewRequest(s string) (*http.Request, error)
- func (c *Client) NewStories() ([]int, error)
- func (c *Client) ShowStories() ([]int, error)
- func (c *Client) TopStories() ([]int, error)
- func (c *Client) Updates() (*Updates, error)
- func (c *Client) User(id string) (*User, error)
- type Item
- type ItemsService
- type LiveService
- type Updates
- type User
- type UsersService
Constants ¶
const ( STORY_TYPE_NEW = "new" STORY_TYPE_TOP = "top" STORY_TYPE_JOB = "job" STORY_TYPE_ASK = "ask" STORY_TYPE_SHOW = "show" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Items ItemsService Users UsersService Live LiveService // BaseURL is the base url for Hacker News API. BaseURL *url.URL // User agent used for HTTP requests to Hacker News API. UserAgent string // contains filtered or unexported fields }
A Client communicates with the Hacker News API.
func NewClient ¶
NewClient returns a new Hacker News API client. If httpClient is nil, http.DefaultClient is used.
func (*Client) AskStories ¶
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
func (*Client) JobStories ¶
func (*Client) NewRequest ¶
NewRequest creates an API request.
func (*Client) NewStories ¶
func (*Client) ShowStories ¶
func (*Client) TopStories ¶
type Item ¶
type Item struct { ID int `json:"id" bson:"_id"` Parent int `json:"parent" bson:"parent"` Kids []int `json:"kids" bson:"kids"` Parts []int `json:"parts" bson:"parts"` Score int `json:"score" bson:"score"` Timestamp int `json:"time" bson:"time"` By string `json:"by" bson:"by"` Type string `json:"type" bson:"type"` Title string `json:"title" bson:"title"` Text string `json:"text" bson:"text"` URL string `json:"url" bson:"url"` Dead bool `json:"dead" bson:"dead"` Deleted bool `json:"deleted" bson:"deleted"` }
Item represents a item
type ItemsService ¶
ItemsService communicates with the news related endpoints in the Hacker News API
type LiveService ¶
type LiveService interface { GetStories(string) ([]int, error) MaxItem() (int, error) Updates() (*Updates, error) }
LiveService communicates with the news related endpoints in the Hacker News API
type User ¶
type User struct { About string `json:"about"` Created int `json:"created"` Delay int `json:"delay"` ID string `json:"id"` Karma int `json:"karma"` Submitted []int `json:"submitted"` }
User represents a Hacker News user
func (*User) CreatedTime ¶
CreatedTime return the time of the created
type UsersService ¶
UsersService communicates with the news related endpoints in the Hacker News API