Qeeybtaan Waxaan uga Hadli Doonna API Waxa Uu yahay, Faa'idadiisa Iyo Isticmaal-kiisa Waa ka Qeeyb Qadan Kartaa Repository-gaan Adigoo Fork dhahayo Kuna Soo Darso, Waxyaabaha Kamaqan Messhan Oo Aad isleedahay Dadka Way Anfici Donnan.
API waxa laga soo gaabiyay application programming interface
Waa Xarig (Link) udhaxeeya application-kaaga iyo application kale kaaso u sahlaya application-kaaga
inuu la hadlo ama xog kasoo qaato application kale oo external ah
Tusaalaha API-gu waxaa kamid Weather App-ka Teelkaaga Kujira Sida Uu Usoo Aqrisanaayo
Cimilada Wadankeena
API isagoo animation ah hoos ayaa ka arki kartaa.
faa'idooyinka ugu muhiimsan ee uu leeyahay api-gu waa
- Inuu Waqtiga Kuu Save-gareeyo
- Inuu Sare Uqaado productivity-ga Application-kaaga
- Inuu Kuu Sahlo Waxyaabaha Developing-kooda Waqti Qadanayo Inaad Si Fudud Ku Hesho
Iyo Faa'idooyin kale Oo Badan
4-method Ayaa ugu Muhiimsa API's-ka Waana Kuwaan Soo Socda
- GET: GET Waa Method Kamid API Methods Waxuuna Udhigmaa (Read) Wuxuu Kuu Sahlayaa
Inaad hesho Ama soo Aqriso Xogta Kaaga Imaaday Ama Aad kasoo jiidatay Link API.
- POST: POST Wuxuu Udhigmaa (Insert Ama Create) Waxaa La isticmaala Marka Xog Aad Gelinaysid API-ga
- PUT : POUT Wxuu Udhigmaa ( Update ) Waxaa la isticmaala Markii Xog Aad ka Update-gareenaysid
API-ga
- DELETE: Sida Erayga Ka Muuqataba DELETE Waxaa La isticmaala Markii Aad Xog ka Tuuraysid API-ga
- Marka Hore Waa Inaad Heshaa API-ka Aad Rabto Inaad Ku Xerto Website-kaaga Kaba
Soo Qaad Waxaa Rabtaa Inaad Sameeyso Weather Website First Waa Inaad Heshaa API aad ka Heli Karto
Cimiloyin-ka Dunida oo Dhan Kadib Markaad hesho
- Waa Inaad heshaa Authrization API KEY : API KEY waa Furaha Kuu Sahlaya inaad Isticmaasho
API-ga Aad Rabto Inaad Xogta kasoo Qaadato Markaad Key-gaas Hesho kadib
- Aqri Documentation-ka API-gu Wax Walbo Waxay Leeyihiin Tixraac marka Aqri Tixraaca API-ga Aad Isticmaalaysid Si Aaadan Ugu Wareerin intaa Kadib
- Codsiga Dirso (Request Endpoints) Inaad Codsi Udirsato API-ga Aad Isticmaalaysid Si aad U hesho Xogta
Kujirto Server-kaas
- Sidaas Ayaa Ugu Xertay Congrats!😊
Haa Luqad Walba Waa Ku Isticmaali Kartaa, Luuqad Walbana Waxay Leedahay Functional ugooni Ah Oo Lagu
Maamulo API's-ka
Examples-ka Soo Socdo Waxaan isticmaali donna JavaScript Luqaadda Favorite-kaaga waa
Isticmaali kartaa ☺
Waxaan Halkaan Ku Arki Donna sida api request loogu dirsado annago isticmaalayno luuqadda javaScript, Waxaan request udirsan doonaa file local ah oo computer-ka kujiro oo lagu magacaabo users.json Xogta Kujirta Ayaan Kasoo Aqrin donna annago isticmaalayno api request sidoo kale file-ka waa json xogta kujirto api-gu markii aad request udirsato wuxuu kuusoo celin doonaa data udiyaarsan qaab object ah marka waa inaad ubadashaa JSON si aan u test gareeyno api-ga waxaan isticmaali donna extension aad ka helaysid VS-CODE oo lagu magacaabo thunder client api. Waxaa La isticmaala Markii Aad Api Request Udirsanayso Dhowr Qaabo
- Inaad Isticmaasho fetch Method ();
- Inaad isticmaasho AJAX & JQUERY
- XHR Request ama Inaad Isticmaasho ASYNC AWAIT
Intaas Qaab Waa Isticmaali Kartaa Lkn Annaga Examples-ka Waxaan isticmaali donna Laba Qaab 1. Fetch 2. PHP -> AJAX AND JQUERY
Marka Hore Install Soo dhaho Extension-ka thunder Client api Inteface-kiisa Kowaad Qaabkaan Ayuu Usoo Bixi Doonaa 👇🏼
Qeeybta Ay Ku Qoranatahy Local Host ayaa waxaa gelinaysaa link-ga request-ga aad diraysid annaga hadda waxaan diraynaa request local ah waxaa udiraynaa file-ka user.json file-kaas path-kiisa ayaan soo copy-gareeyn donna kadib waxaan ka hormarinayaa localhost maadama aan isticmaalyn api online ah sidaan ayuu uqorman doonaa path-ka localhost/api/user.json Sawir-ka kore Qeeybtiisa Url-ka Ayaa Waxaa Gelinaysa link-ga Aad request Udiraysid
kadib markii aad gelisid waxa soo laaban doono waxaa loo yaqaanaa Response
File-ka Hadda Aan Udirnay
Request-ga Sidaan Ayaa Noqonayaa reponsise-giisa
Sidaas Ayaa Ku TEST Gareeyn kartaa Request Aad Udirtay Link-api local ama Online midkuu doono ha noqdee adigoo isticmaalaya graphical extension-ka THUNDER CLIENT API
Halkaan Waxaan Ku Diraynaa request-gii hadda isagoo code ah ayaan arkaynaa waxaana isticmaali doonna fetch method
code-ka sidaan ayuu noqonayaa
function FetchMyApi() {
// fetching data from user.json file
fetch("./user.json")
// if it true then change the data response into json format
.then(response=>response.json())
// then display the data to the console
.then(data=> console.log(data))
// if it false display the error to the console
.catch(error=> console.log(error.message));
}
FetchMyApi();
sidaas ayaa ku dirsanay api-ga annago isticmaalayno fetch method
waxaa uyeeraysaa method-ka fetch(url)
Url : waxaa weeyan link-ga aad udiraysid request-ga
reuqest-ga waxaa kasoo laabanayo laba midkood true ama false
true: true hadday tahay data-da
waxaa weeyan wax cillad ah majiraan kadib , data-da Qaar sida aan horay ugu soo sheegnay waxay ku imaanaysa qaab
object ah si aad ugu badashid json markii data-da true tahay waxaa la isticmaala .then
: .then
waxaa weyaan markii data-da success tahay maxaa la qabanaayaa
.catch: Waxaa weeyan markii data-da
failed tahay maxaa la qabanayaa
then waxaan soo bandhigaynaa error-ka jira lets test
and see the console.....
result:
si aad data-da qeeyb kamid ah ugula soo dhax-baxdid waxaa isticmaalysa indexing
example : data[0] data[0]: means waa object-ga kowwad xogtiisa isoo bandhig
function FetchMyApi() {
// fetching data from user.json file
fetch("./user.json")
// if it true then change the data response into json format
.then(response=>response.json())
// then display the data to the console
.then(data=> {
console.log(data[0])
})
// if it false display the error to the console
.catch(error=> console.log(error.message));
}
FetchMyApi();
haddii aad rabtid user-ka hogtiisa qeeyb kamid Waxaa marka hore accessing ku sameenaysa index-ga object uu leeyhy,
kadib waxaa isticmaali kartaa Ditructure : waa vanilla javascript syntax oo aad u isticmaali karto
inaad wixii isku meel ah object varibale usameeyn kartid
example haddii aan rabo user-ka ugu horeeyo
username-kisa address-kiisa iyo shaqadisaa maxaan sameenayaa sidaan...
function FetchMyApi() {
// fetching data from user.json file
fetch("./user.json")
// if it true then change the data response into json format
.then(response=>response.json())
// then display the data to the console
.then(data=> {
let {username, Address,occupation}=data[0];
console.log("username: "+username+" Addres: "+Address+" Job: "+occupation);
})
// if it false display the error to the console
.catch(error=> console.log(error.message));
}
FetchMyApi();
let {username, Address,occupation}=data[0]; Qeybtaan ayaa loo yaqaanaa distructure
data[0] waa user-ka ugu horeeyo xogtiisa, user-ka ugu horeeyana xogtiisa waxaa kamid waxyaabaha
aan object-gaan ku sheegay {username, Address,occupation} , Waa inay islahaadan magacyada aad halkaan ku qoraysid {username, Address,occupation} iYo Magacyada data[0] kujiraan ama object-ga aad xogta kasoo qaadanaysid , hadday islahaan waayan waxaa kuu soo laaban doono undefined
Let's Test above the code and see the result
Sidaa Ayaa Udirsan kartaa API REQUEST ADIGOO ISTICMAALAYA JAVASCRIPT
GAAB ::::::::::::::::::::::::::::::
fecth : waa method la isticmaalo si request api lo diro
url : url waa link-ga aad udirsanaysid request-ga
.the : waa marka data-da success tahay waxa lasoo bandhigaayo
.catch : waa marka data-da failed tahay waxa lasoo bandhigaayo
thats it😊 Next waxaa fiirin donna ajax jquery php and mysql