Go client library for News API
go get github.com/Newscatcher/newscatcher-go
import ( "context" newscatcher "github.com/Newscatcher/newscatcher-go" newscatcherclient "github.com/Newscatcher/newscatcher-go/client" "github.com/Newscatcher/newscatcher-go/option" ) client := newscatcherclient.NewClient( option.WithApiKey("YOUR_API_KEY"), ) response, err := client.Search.Post( context.TODO(), &newscatcher.SearchPostRequest{ Q: "renewable energy", PredefinedSources: []string{"top 50 US"}, Lang: []string{"en"}, From: "2024-01-01", To: "2024-06-30", }, )
import ( "github.com/Newscatcher/newscatcher-go/core" "fmt" ) response, err := client.Search.Post(...) if err != nil { if apiErr, ok := err.(*core.APIError); ok { fmt.Println(apiErr.Error()) fmt.Println(apiErr.StatusCode) } return err }
Was this page helpful?