오늘은 뉴스 api 를 가져와서 화면에 보여주는 작업을 해볼 것이다. 아래처럼!
[API 사용 설정]
아래의 홈페이지에 들어가서 뉴스 API를 사용하기 위해 가입을 하고 API 키를 받아 준다. 키를 받고 문서에 들어가 보면 사용법을 제공한다.
News API – Search News and Blog Articles on the Web
“Ascender AI has a mission to apply AI to the media, and NewsAPI is one of our most valuable resources. Ascender is redefining how users interact with complex information, and the NewsAPI feed is an essential showcase for our technologies.” Braddock Ga
newsapi.org
[Postman에 적용 해보기]
Api 키와 주소를 적용 해서 Get으로 보면 이렇게 뉴스가 잘 보인다. 여기서 웹 주소에 country 에 국가 코드를 입력해서 각 국가의 코드를 적용해서 볼 수 있다.
https://newsapi.org/v2/top-headlines?country=국가코드&apiKey=api키번호입력
[pubspec.yaml]
이제 통신용 http 모듈을 설치한다. 그리고 pub get을 설치하면 통신이 이제 이루어진다.
'Flutter' 카테고리의 다른 글
Flutter 뉴스 API 연동하기(3) - 화면에 그리기 (0) | 2024.02.01 |
---|---|
Flutter 뉴스 API 연동하기(2) - 통신하기 (0) | 2024.01.31 |
Flutter 정규식 표현(RegExp) - dart 정규표현식 (1) | 2024.01.24 |
Flutter 플랫폼 구별하기 (안드로이드, IOS, Web) - Platform & kIsWeb (0) | 2024.01.22 |
Flutter 아이폰 스위치 CupertinoSwitch 만들기 (StatelessWidget) (0) | 2024.01.17 |