Skip to content
/ API Public

Halkaan waxaa Ka Daalacan Kartaa Article ku Saabsan API; Sidoo Kale Conttribution Waa Ku Sameeyn Kartaa Kuna Soo Darso Waxyaabaha Kamaqan

Notifications You must be signed in to change notification settings

ENG-CJ/API

Repository files navigation

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.

1. Waa Maxay APi ?

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.

Waaa Maxay Faa'idada Uu Leeyahay API-gu?

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

API METHODS ( Methods-ka Lagu Maamulo API-ka)

4-method Ayaa ugu Muhiimsa API's-ka Waana Kuwaan Soo Socda

  1. 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.
  2. POST: POST Wuxuu Udhigmaa (Insert Ama Create) Waxaa La isticmaala Marka Xog Aad Gelinaysid API-ga
  3. PUT : POUT Wxuu Udhigmaa ( Update ) Waxaa la isticmaala Markii Xog Aad ka Update-gareenaysid API-ga
  4. DELETE: Sida Erayga Ka Muuqataba DELETE Waxaa La isticmaala Markii Aad Xog ka Tuuraysid API-ga

Sidee Ugu Xeraysaa API Website-kaaga Ama App-kaaga?

  1. 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
  2. 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
  3. Aqri Documentation-ka API-gu Wax Walbo Waxay Leeyihiin Tixraac marka Aqri Tixraaca API-ga Aad Isticmaalaysid Si Aaadan Ugu Wareerin intaa Kadib
  4. Codsiga Dirso (Request Endpoints) Inaad Codsi Udirsato API-ga Aad Isticmaalaysid Si aad U hesho Xogta Kujirto Server-kaas
  5. Sidaas Ayaa Ugu Xertay Congrats!😊

Luqad Walba Maku Isticmaali karaa?

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 ☺

API using JavaScript

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

  1. Inaad Isticmaasho fetch Method ();
  2. Inaad isticmaasho AJAX & JQUERY
  3. 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

API USING JAVASCRIPT |2| fetch Graphical Interface Using thunder API Extension

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

API USING JAVASCRIPT |3| By Code Using (fetch method)

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

About

Halkaan waxaa Ka Daalacan Kartaa Article ku Saabsan API; Sidoo Kale Conttribution Waa Ku Sameeyn Kartaa Kuna Soo Darso Waxyaabaha Kamaqan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published