An Application Programming Interface is a set of commands, functions, protocols, and objects that programmers can use to create software or interact with an external system.
다른 개발자가 만들어놓은 프로그램을 외부의 다른 개발자가 갖다가 쓰는거.
데이타 제공자와 개발자간의 계약. 예를 들어, 지역별 범죄율 데이터, 날씨, 공공 데이터, jquery 등등
Your server | request-----> | API | ----->request | someone else's server |
<---response | <-----response |
실험
JokeAPI
JokeAPI
JokeAPI is a RESTful API that serves jokes from many categories while also offering a lot of filtering methods
v2.jokeapi.dev
1. End points를 찾아라 - An endpoint is an access point to send the HTTP requests to and get your response.
JokeAPI offers these following endpoints:
3. Path
엔드포인트 뒷부분, 그러니까 /programming,Christmas 가 Path
개발자가 미리 지정해 놓은 부분, so somewhere on this joke API server, they have to be able to catch when a request is made to this URL/programming path 프로그래밍 조크만 필터해서 보여줄 수있게 미리 만들어짐.
미리 생각해둘 수 없는 부분의 필터는 어떻게 할까? -> a PARAMETERS
4. Parameters
커스텀쿼리 - URL/ path 다음에 ?contains=debugging 으로 나오는 부분이 PARAMETERS!
contains: key (가변)
=debugging: query (가변)
URL /path ? key=query & key = query
5. 결과
위의 url을 주소창에 넣고 엔터
{
"error": false,
"category": "Programming",
"type": "single",
"joke": "The six stages of debugging:\n1. That can't happen.\n2. That doesn't happen on my machine.\n3. That shouldn't happen.\n4. Why does that happen?\n5. Oh, I see.\n6. How did that ever work?",
"flags": {
"nsfw": false,
"religious": false,
"political": false,
"racist": false,
"sexist": false,
"explicit": false
},
"id": 123,
"safe": true,
"lang": "en"
}
css가 필요하지만 값은 출력됨.
'프로그래밍 공부 > 백엔드' 카테고리의 다른 글
The MailChimp API - Newsletter App.1: before start (0) | 2022.03.05 |
---|---|
Open Weather API - Postman - JSON (0) | 2022.03.04 |
Calculator 만들기: 2+3은 23의 문제에 대하여.. (0) | 2022.03.03 |
Calculator 만들기: res.sendFile(__dirname (0) | 2022.03.03 |
Understanding with Routes. (0) | 2022.03.03 |