-
Notifications
You must be signed in to change notification settings - Fork 1
/
req_Michalina.js
129 lines (85 loc) · 4.2 KB
/
req_Michalina.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Michalina - zabawy z REST API
const https = require('https');
const http = require('http');
const request = require('request');
let OWMAPPID = "dea49c5dbe5ecf2f3b3d6ed074766ee2"
let accuAPIID = "MOVo4OIH5KgNohU1JXHgHI2J7pMHB3Io"
let NASAAPPID = "Nzei0jlJaiJzcmlX5vxdCRB3TOMBFEazgudEUn32"
let sWynik=""
//Amogus
function OpenWeatherMap(sCity){
request(`https://api.openweathermap.org/data/2.5/weather?q=${encodeURI(sCity)}&appid=${OWMAPPID}&lang=pl&units=metric`, (err, res, body) => {
console.log(body);
let oPogoda = JSON.parse(body);
console.log(oPogoda);
console.log(`openweather-> ${sCity}, zakodowany URL = ${encodeURI(sCity)}`);
console.log(`openweather-> temperatura: ${oPogoda.main.temp}°C, temperatura odczuwalna: ${oPogoda.main.feels_like}°C, temp min: ${oPogoda.main.temp_min}°C, temp max: ${oPogoda.main.temp_max}°C`);
console.log(`openweather-> ciśnienie: ${oPogoda.main.pressure}hPa, wilgotność: ${oPogoda.main.humidity}`);
console.log(`openweather-> widoczność: ${oPogoda.visibility}m`);
console.log(`openweather-> http://openweathermap.org/img/w/${oPogoda.weather[0].icon}.png`)
});
}
function DifferentDogdFactsAPI(){
//https://dog-facts-api.herokuapp.com/api/v1/resources/dogs/all
request(`https://dog-facts-api.herokuapp.com/api/v1/resources/dogs/all`, (err, res, body) => {
let oFakty = JSON.parse(body);
oFakty.forEach(element => {
console.log(`dog-facts->: ${element.fact}`);
});
});
}
function BoredAPI(){
request(`https://www.boredapi.com/api/activity?participants=1`, (err, res, body) => {
let oCorobic = JSON.parse(body);
console.log(`BoredAPI->: ${oCorobic.activity}`);
});
}
//https://restcountries.eu/rest/v2/name/${sName}
function niewiemno(sName){
request(`https://restcountries.eu/rest/v2/name/${encodeURI(sName)}`, (err, res, body) => {
let oKraj = JSON.parse(body);
console.log(`restcountries-> nazwa kraju: ${oKraj[0].name}, domena: ${oKraj[0].topLevelDomain}, stolica: ${oKraj[0].capital}`);
});
}
function CosTamAPI(){
//https://dog-facts-api.herokuapp.com/api/v1/resources/dogs/all
request(`http://api.zippopotam.us/${sKraj}/${sKodPoczt}`, (err, res, body) => {
//console.log(body);
let oFakty = JSON.parse(body);
//console.log(oFakty.length);
oFakty.forEach(element => {
console.log(`dog-facts->: ${element.fact}`);
});
});
}
//OpenWeatherMap('Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch')
//OpenWeatherMap('Amorgos')
//https://www.youtube.com/watch?v=dQw4w9WgXcQ
//OpenWeatherMap("Katowice")
//OpenWeatherMap("Bielsko-Biała")
niewiemno("Iceland")
//DifferentDogdFactsAPI();
//BoredAPI()
// https://dataservice.accuweather.com/forecasts/v1/hourly/1hour/${cityID}?apikey=${accuAPIID}&language=pl&metric=true
// console.log(`AccuWeather-> temp:${o1hForecast[0].Temperature.Value}°${o1hForecast[0].Temperature.Unit}, link: ${o1hForecast[0].MobileLink}`);
// console.log(`AccuWeather-> icon: https://www.accuweather.com/images/weathericons/${o1hForecast[0].WeatherIcon}.svg`);
//https://translate.googleapis.com/translate_a/single?client=gtx&sl=${sSourceLang}&tl=${sTargetLang}&dt=t&q="${encodeURI(sTekst)}
//https://api.nasa.gov/planetary/earth/assets?lon=18.947329&lat=50.193520&date=2021-04-10&dim=0.20&api_key=${NASAAPPID}
// https://api.nasa.gov/planetary/apod?api_key=${NASAAPPID}
//https://api.thingspeak.com/channels/730056/feeds.json
//https://freegeoip.app/json/
//https://restcountries.eu/#api-endpoints-all
//https://restcountries.eu/rest/v2/name/${sName}
//https://restcountries.eu/rest/v2/all
//https://openlibrary.org/dev/docs/api/books
//https://openlibrary.org/isbn/${sISBN}.json
//https://api.ipify.org/?format=json
//https://ipinfo.io/161.185.160.93/geo
//http://api.zippopotam.us/pl/40-748
//http://www.zippopotam.us/
//http://api.zippopotam.us/${sKraj}/${sKodPoczt}
//https://www.boredapi.com/
//https://www.boredapi.com/api/activity?participants=1
//https://www.boredapi.com/api/activity?participants=${iIleOsob}
//https://api.publicapis.org/entries
// Amogus