package main
import (
"bytes"
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.dappier.com/app/datamodel/dm_01j0pb465keqmatq9k83dthx34"
apiKey := "<YOUR_DAPPIER_API_KEY>"
query := `{
"query": "lifestyle new articles",
"similarity_top_k": 3,
"ref": "",
"num_articles_ref": 0,
"search_algorithm": "most_recent",
"page": 1,
"num_results" : 10
}`
req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(query)))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}