advweb-grp1 / advanced-web-final-year-project

Final year advanced web develop unit project
MIT License
1 stars 0 forks source link

Feature/news #38

Closed advweb-grp1 closed 1 year ago

advweb-grp1 commented 1 year ago

Home page should have a news section which displays cards for news related to the cardiomyopathy field of research. spec: image

advweb-grp1 commented 1 year ago

Blockers are API that returns required information.

AymanReh commented 1 year ago

Currently have found an existing api which relays all current news activity which are related to cardiomyopathy , its called news api org. Returns data in a json format

Example end points include

{"title":"Coolio died of an accidental fentanyl overdose, coroner's report shows","author":"Kaitlyn Radde","source":{"Id":null,"Name":"NPR"},"publishedAt":"2023-04-07T14:08:04Z","url":"https://www.npr.org/2023/04/07/1168605721/coolio-death-fentanyl-overdose-coroners-report"}

Useful endpoint includes title, publishedAt, author, source:

Requires an api key but have signed up and recieved one: apiKey=

https://newsapi.org/v2/everything?q=cardiomyopathy&apiKey=6328e1652eaa4cca859e9aa418e87b8e

This api's return data seems abit broad, but is all related to cardiomyopathy e.g. coolio dying of fentanyl overdose means he went into cardiac arrest

AymanReh commented 1 year ago

Not 100% sure that most apis for news feeds include an image endpoint but I will add it anyways and if the api we choose to implement doesn't have an image endpoint it can be removed

AymanReh commented 1 year ago

Found another news api named newscatcher api response data is in JSON format. Requires an api key but managed to get one: APIKEY: Example search: api.newscatcherapi.com/v2/search?q=Cardiomyopathy the api key goes inside of the header! Page: to conduct queries online: https://docs.newscatcherapi.com/api-docs/endpoints/search-news A successful request response looks like this: includes title, author, date, summary which matches our needs.

{
    {
"status":"ok"
"total_hits":268
"page":1
"total_pages":6
"page_size":50
"articles":[
0:{
"title":"Dilated Cardiomyopathy Market to Witness Growth by 2032, Estimates DelveInsight"
"author":"Delveinsight Business Research"
"published_date":"2023-04-13 10:52:52"
"published_date_precision":"full"
"link":"https://www.openpr.com/news/3011870/dilated-cardiomyopathy-market-to-witness-growth-by-2032"
"clean_url":"openpr.com"
"excerpt":"DelveInsight s Dilated Cardiomyopathy Market Insights Epidemiology and Market Forecast 2032 report delivers an in depth understanding of Dilated Cardiomyopathy historical and forecasted epidemiology…"
"summary":"Dilated Cardiomyopathy Market to Witness Growth by 2032, Estimates DelveInsight https://www.delveinsight.com/sample-request/dilated-cardiomyopathy-market-forecast?utm_source=openpr&utm_medium=pressrelease&utm_campaign=kpr https://www.delveinsight.com/report-store/dilated-cardiomyopathy-market-forecast?utm_source=openpr&utm_medium=pressrelease&utm_campaign=kpr https://www.delveinsight.com/sample-request/dilated-cardiomyopathy-market-forecast?utm_source=openpr&utm_medium=pressrelease&utm_campaign=kpr https://www."
"rights":"openpr.com"
"rank":9387
"topic":"business"
"country":"DE"
"language":"en"
"authors":"DelveInsight Business Research"
"media":"https://cdn.openpr.com/W/4/W413602838_g.jpg"
"is_opinion":false
"twitter_account":NULL
"_score":22.211132
"_id":"07498fa953320b94ba3e6e1ee3f6e94d"
}
1:{
"title":"Cardiomyopathy Market Recent Trends, In-depth Analysis, Size and Forecast 2023 to 2030"
"author":"Stratagem Market Insights"
"published_date":"2023-04-14 12:27:54"
"published_date_precision":"full"
"link":"https://www.openpr.com/news/3014279/cardiomyopathy-market-recent-trends-in-depth-analysis-size"
"clean_url":"openpr.com"
"excerpt":"A Cardiomyopathy Market 2023 Often a lookup record consists of a specified examination of a positive market or industry According to The Stratagem Market Insights the Latest lookup document on…"
"summary":"Cardiomyopathy Market Recent Trends, In-depth Analysis, Size and Forecast 2023 to 2030 Cardiomyopathy Market https://www.stratagemmarketinsights.com/sample/187994 https://www.stratagemmarketinsights.com/Discount/187994 https://www.stratagemmarketinsights.com/promobuy/187994 https://www.stratagemmarketinsights.com A Cardiomyopathy Market 2023 Often, a lookup record consists of a specified examination of a positive market or industry.According to The Stratagem Market Insights, the Latest lookup document on Cardiomyopathy Market Size, Revenue, Global Analysis, and Forecast 2023 to 2030 The Cardiomyopathy Market lookup learn about is a expert document with top class insights into the measurement of the business, modern patterns, drivers, risks, workable outcomes, and most important segments."
"rights":"openpr.com"
"rank":9387
"topic":"business"
"country":"DE"
"language":"en"
"authors":"Stratagem Market Insights"
"media":"https://cdn.openpr.com/W/4/W414603372_g.jpg"
"is_opinion":false
"twitter_account":NULL
"_score":20.825356
"_id":"982bf7c256ecb631fa68010b98c10d55"
}

    "user_input": {
        "q": "Cardiomyopathy",
        "search_in": [
            "title_summary"
        ],
        "lang": null,
        "not_lang": null,
        "countries": [
            "CA"
        ],
        "not_countries": null,
        "from": "2021-12-15 00:00:00",
        "to": null,
        "ranked_only": "True",
        "from_rank": null,
        "to_rank": null,
        "sort_by": "relevancy",
        "page": 1,
        "size": 1,
        "sources": null,
        "not_sources": null,
        "topic": null,
        "published_date_precision": null
    }
}

The query above is showing 2 news reports for cardiomyopathy, in the actual query there are hundreds of news reports about cardiomyopathy, each with a title, published_date and summary. However there are no tags.

Example way of implementing this into js would be

const apiKey = "YOUR_API_KEY";
const searchQuery = "cardiomyopathy";
const language = "en";

fetch(`https://api.newscatcherapi.com/v2/search?q=${searchQuery}&lang=${language}&api_key=${apiKey}`)
  .then(response => response.json())
  .then(data => {
    // Handle the API response data here
    console.log(data);
  })
  .catch(error => {
    // Handle any errors here
    console.error(error);
  });

I believe with all our available API looked at newscatcherapi is our best choice offers the most detailed responses and contains almost every piece of data we need.