newsapi

package
v1.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

README

NewsAPI Client

This package provides a client for the NewsAPI API, which is used to interact with the NewsAPI service.

References:

Documentation

Overview

newsapi implements an API client for NewsAPI (https://newsapi.org/docs)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	Source      Source    `json:"source"`
	Title       string    `json:"title"`
	Author      string    `json:"author,omitempty"`
	Description string    `json:"description,omitempty"`
	Url         string    `json:"url,omitempty"`
	ImageUrl    string    `json:"urlToImage,omitempty"`
	PublishedAt time.Time `json:"publishedAt,omitempty"`
	Content     string    `json:"content,omitempty"`
}

type Client

type Client struct {
	*client.Client
}

func New

func New(ApiKey string, opts ...client.ClientOpt) (*Client, error)

func (*Client) Articles

func (c *Client) Articles(opt ...Opt) ([]Article, error)

Returns articles

func (*Client) Headlines

func (c *Client) Headlines(opt ...Opt) ([]Article, error)

Returns headlines

func (*Client) Sources

func (c *Client) Sources(opt ...Opt) ([]Source, error)

Sources returns all the models. The options which can be passed are:

  OptCategory: The category you would like to get sources for. Possible
			  options are business, entertainment, general, health, science, sports,
			  technology.

  OptLanguage: The language you would like to get sources for

  OptCountry: The country you would like to get sources for

func (*Client) Tools added in v1.0.10

func (c *Client) Tools() []agent.Tool

Return all the agent tools for the weatherapi

type Opt

type Opt func(*opts) error

Opt is a function which can be used to set options on a request

func OptCategory

func OptCategory(v string) Opt

Set the category

func OptCountry

func OptCountry(v string) Opt

Set the country

func OptLanguage

func OptLanguage(v string) Opt

Set the language

func OptLimit

func OptLimit(v int) Opt

Set the number of results

func OptQuery

func OptQuery(v string) Opt

Set the query

func OptSortByDate

func OptSortByDate() Opt

Sort for articles by date

func OptSortByPopularity

func OptSortByPopularity() Opt

Sort for articles by popularity

func OptSortByRelevancy

func OptSortByRelevancy() Opt

Sort for articles by relevancy

type Source

type Source struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Url         string `json:"url,omitempty"`
	Category    string `json:"category,omitempty"`
	Language    string `json:"language,omitempty"`
	Country     string `json:"country,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL