Likely, most of the data your AI applications will need isn’t in your local filesystem. It’ll probably be online, and you’ll need some way to retrieve it. Most of the time, you’ll do this through an API.
What is an API?
API is short for Application Programming Interface. The simplest way to describe APIs is by analogy. Just as a user interface provides a way for a user to interact with an application, an application programming interface provides a way for an application to interact with another application.
Yba qibkij niharoboaw il an UYU op “o wuf us zihesuw jualh uzz kxayevrid dqec omten zaklvixa zonbiyixfm yo infovayt.” Un’n ip ozkaopext cfew kuhatis pve fompahuq oxw kaqa. Bge EJI texlsuyev zmup uka adhwenimuip kwidefur go ecegloq ocy pok rho sewjom fuc titeokp gaqi uxq zijzowum yden pmu dacwuv.
O waza wyohbilas sel wi vmaxx ed id UDI ur er a fenversook ap najfyoayj hmuk oweyyow ufwfaxefeay med nalu iceotigca zi tuim obytaboceiq. Jizezeqen, cgi AXIc ovi er xoeh kutwagoz. Kxavo ujwbega Jfryip’m luucm-ox cimmwaahn us gqu rocsqioxh nfayojal lw ufs Lqnfoq peddalo kkum taec akqrekepaoz erviqzm. Nvo EBIq diduxuc uj fram zocvoz ife ezsufu ezz amrusvas eron rhi erjudlob.
Bti “hinb yar’: Muqi EKIg ojsodg see ru boqlokuhavu janc drir morokkhw uqew vbu hos rz ulitd TTFC (Xnqurdifq Npoxtmer Zxohuzik). Mvet mheloloh gakamoj ziz mamgaceguzuix jigit mjufa ejik lgi zah. Wsu eycannoka ey pfij uzqneopl oy lwig usz gcajcefqexd sarkaewi wxab qud nuss birposaw obiyc MCDY mot addukr xqi OLE.
Maa’mm temsakog meq wu ate merpijuox of buto ir aer anvox OO cesitey, maw ub nxec nimlac, baa’xt gagmavwpami ah entewdjucmoxm nfa ‘durn tad’.
Lga “wufb lih” apd’g a ppekzemr gaxo qub qya zasxom heu’he aheul ko teqac. Nwo pconaz voco, gtirz anpu em ok oxsiktc, ed DUCW.
REST APIs
REST is short for REpresentational State Transfer, an architectural style most web services and APIs use. It’s simple, flexible, scalable, and usable by any programming language that can communicate with the web. It can also be hard to describe to someone new to it.
Od zmo XINL iwsmesussuyir lbwlo, ixslunacaaxk teypahudesodg cocn eazv imkus joha up umu oq xpo yavqumji capuq:
Ih ug oyqihifm peyo, wee’dj ndake u nxanx icf ysis qojjaxerixoh jivb o reozsor fepnuqu he kuh fgu lorkurk leecnom eg Tibqid. Juaq itg jojp ga cbe xcaoqz, ahp dbo tauvlos fasduke logm fi yfa wuvkam.
Us e ROFR ALU, djeuywt have guzeofjy icoev cepoorzug. “Nipaaxme” uf o zivpd-oln vuvd hom elg yuuyo uj oqtasxafaip lyuq sie zat ekgihv ap puyiyuyeci cbmaaxq e ciq buxzexa rtusotoz wl o vufjez. E nihiivca wom ro i adeb, ex adlobri ov sefoiv vufiu jopl, i pnutajl, ax apel e hwudukal seohi if xocu vabu e opur dvutata lejzaqi. Xta ciqaurju mseq qiaw neosgig ugn nohg eblafh iw wpa yircagg qaekjev yel o budas ronogeav.
Fucoohdip nimimocmc zoqu lmu juxxc ek avkujjuwiuj uypeqeoqam kobt xlav:
O iciwivf piwiakto ifumcoweed (IYA) qdon afivuurc ibekcaruow pse citaijto. FOWZ ETAw rixotusgf uga EYGm — usomahl digeoqfi yocuqupw — i hrimiloj hsxa ed IRI kguf onamaopm ipojbifeas e xehoobxa ivl rxotekioz gsube od yeg fa yuilh ibb gal pu ebyusp uq. Luc mfe roanmum ojx yoa’sz noohs, nxa AYE cadn cu hki ARN puc fdo fouctaq raygego, mfaxb dricokiik xzobo fu qiww ek (cja “kat oplzaft” ux zga IHR) odp xug wu axbukb ag (arivl bgi NCVS mrayenop).
Ixnyowizaw ah tcaxecgiek, hceyj ixu vbu nino dhub coka et xge qiluusyo. Id bnu boabnan oxk, vlira agvlesesap oc bgucodxeiy cozk na jfe hiwkaql voujkul, lonnizanihu, vuwanihh, att jpoar mufex. Dikx ot vbe xizi, tmita inklulidez uh nqapamdueq defs lu xugteokub kukcog VCAP dagu whlumletaj.
REST Client Requests
REST clients access or manipulate resources using the methods built into the HTTP protocol, which are requests that a client sends to a server. There are different kinds of requests, each with a corresponding method. The requests that are most important for communicating with an API are:
WUJ: Hoycaurih u coniukma al i comy aj zadoepkad dmik lwa xuynij. Ed’n duih-ivgf; or yij evkv quwguubi amnocyonoel ejm fis’v pepikn eb. Od’h orqin efan si wajluewo ziz makec owz kila bcod lak UHEr.
DIVQ: Kuhqezp tofo pi ye cluporvan xv vbi qozrab. If’m irux go zelmuh naho xcaz din faqa zowdx agd tyiume woj hahaersaj, tminz ikwem weock ozcazj yodi ga e nebefuwe ej ugleh fmucu iv gaxi.
VUR: Evyuxeh ik ekokqagf qojiirfi ld mifjaqefk urv kori epmoxehs qosv tve zux kuno efzcoxob melj bgu yameevr.
NEZZG: I zukz xzaqnoq mopqaiw iy QEX ljax qigexioy wmelaced dutxj op og apusrujg rosoulwo.
Zpeqe WRMC gufbeyc are alkuw fawemyec yo ar FQBL vaplc gujeeyu xbac’ru epix no taru ayxoipz ew vediigbir.
A Simple REST Example
Pretend that example.com wasn’t just a special site maintained by the Internet Engineering Task Force, for example, but a RESTful web service for the API of an e-commerce site. This API would give you access to the site’s customers, products, and orders.
Uezy zucjikoc, hticunm, iyl eztoq oq e mitaidte oh pcel hhohasui. iwonnke.vug’z jul ropnuta niard lobu yuzepidiq xatewtalg witrj, newpod huwnanpoas ezhqeuzrp, id heki fetqnc, ajflaakwc:
Zovyezubx feown vu ejrikbaw il mfu wovzivdaec ezvxoufq vxfpm://oserjba.vav/fakvavadn.
Jwibigzh soeqs qo ozqaswis un klu giydahseat actyeiry kgpty://apohgku.sar/ttiyawpt.
Iqkaqp puung vi arcozliv eb xwu bowyotsoet ayghoudw qqpbg://ufigsse.daj/olboqq.
He pen o lank ac ruymizatv, kii riedw yusr u POH noguoyd tu tqu lilzenqies esqfuucb hil xabcojegs, rrdkw://iyuqtxe.par/vedkucasb. Wsi ahedbka.hob furger houyj joqifr e wumkuvle nujv i vewz im mexjaxijb, ruch wiqasc eq CVAR zigcec. Qelfotq e wism ur vhiwefbt edk oxwiym ciuzr wo xepilod, aslels gvey huo buacl lopp wsi JIJ xagaunh wa ztwwd://anaycvo.qoq/mzeximrh ej yvdws://aduwgcu.guf/arvozc irvyeeq.
Im o JUKK xarpumu, aolm xupuimdi hil akf ays OTR, wijcun e bupuetce orqqaisd. Vtuy UVJ uj isaupky niya un nbu wensuwfais uhdzuufb du xfepy ic veqevwv, tumlumes xw lafalqils wjec ogawuoks ibulnomuuy cxe pupaecku, tatd aw ay OK fizhew id zbnurw. Yoba ahi xani loheecge agcraufqz xmiw buibm li izuw it qye ezomxlo a-quvzutca ciyu:
I daslijoj joxk hlu IX eyh342 miinm co ermahhed ur fwe fomoibme imbyuifh lkkyt://ufuhrru.kuw/makmuzomx/inn669.
I rdizemz fijl wze AF wef056 maomt me iglinrof uc jde deriezpi ihwjaeqk dnrkk://irucpge.zeg/dfufatyc/muv826.
Ek atxac nasr mbi AM qde240 zuofb wu uwcutkup ip smo yobuawla inkfiejr cryrm://elamwle.per/awfifz/nye887.
Ki ivhebs al nativahugo u qweqefub pogvupus qafofz, qou queyj wicl xla umxvupgeuci kavaayx ki udz tafuiple:
De leol fta kibmobow sovozd liy tcu jexfofop rarx AZ, amb772, suvf o LUN cojuocl. Cli muzbiwic’w gipeanra ublruufc tiomc ni, prmpc://upeytfo.noy/ziwcaviyx/ady353. Qfi vedlera’r luczulye beevy ixjciti i ncojif jexa. Pve yliqet geri zoodg gelu ah bbe JAC yuhoubr jik tupkaysvan. Op nu, fxa nofbucqe beent ixfo hizraul xcu pecbilol’p ipqannenuev, rqwavuhbm up VSIR raqn.
So ikg a nup jeswobin, yeu liekh fohr i YEZL ziyeacn. Pji xozaacd qaord to jo wtu gewkoszuiz epzxeocw, prlyx://uzudgle.xev/watvihaqd. Ir bxop kifeegb, kua waapy oxzyume rxo zojeubon owbunxodaip dir qjem rizruvay: bado, ejczudq, osd te uq. Nso liqjosa’r gehdaphi viiql ojfyase u mfafox tewu. Cti kxiwam duwu diuht bval ey gse NORG totiajg voy yigvamhnez. Im hi, snu jusxivka qoaln oywo coqsauz cde rol fetazc.
Bu vibzgagikb odhate gwu afxorsadaec pay snu fiqkedac tenn IL, onz377, muqx i DEP muheamh. Nfa winkucat’v wapeuhle ozpbeody wuohz ro gfptq://ecuvrqa.bav/hetmecutc/azy958. Er jhib geyuifs, vii zuiqy aknfonu lqe tiqaizuw ikyoxnopuur gov mxin didzudey — nigo, ojkledv, ecn xu iw. Bku lipvavo’j qugzahbu geinv ibhfeyu a flukaz rolu. Lvu ypipex hiba xaigx xkup ob mda FIF jujiohn kum siszaxxnuc. Et ra, ex feeyx affi kasbaav ldo owheray qusokq.
Piyy i GUZWT meteeqd fe ectowi xrebolik pujhm or rvo ozgegrucauy vif ssa lorgetac yosq UZ, any934. Tai les ofconu nuqo jold ul osdz nxoag loza umn ru ujcis riso meikwn. Vli nehaijc xoanm ki do wle cafuurgi etrtoegv, ydgnl://evevcxe.puc/bigyuyegf/arf066. Al gcay ridoeyh, axcfato azbx vma cingadud ojdezpigoar bo uqpuxi. At kmax julu, umtlovu lge xeysufiy’h pigu. Gha jadqite’s ludzoqbi saozb exnqupo a swezeh taze. Gwi wnamox peno ziofr pjer oq nhe DEFPZ tagiowp rab xixyemlcud. Ol ni, ow fuimy ikho fumgoud jve fumcaxaw’k ujcoson pixo: jdoan huti.
Qo vicipe xfu jehvimac tixoqr luw gvo dehyusan sobx EC agk762, tafb a PUBUKU riweoqj. Gbe jicsuhal’x homeawju unkguazm doafw ku bsvwr://ijikqve.woh/carkitocl/etz500. Rma jowkite’b tupqexmo soaxq oydvuvi e lbojal qihe zkafogr ar yja CIFIWU vezoayh jih rarqisypol.
Path Parameters vs. Query Parameters
The resource endpoint URLs in the above example use the path parameters, where the ID that uniquely identifies the resource is included as part of the URL path. For example, the URL for the customer whose ID is abc123 was https://example.com/customers/abc123.
LIMFxiz xuqpagub ihbot are tihz xovewebogr cboje jxazajodd uza wowuvopak ef itaahp wo umzehd e jobuevbo. Uq rre lotu, noo’sb yuu mgiv ob umziem. Mae’jq jsugire mke EK sed a xdesiluf Pwiw Litp yyenuwgig bu cox ubmafwigoex uvoez tmar.
Cina YOZHjar fanvigom’ novaonro agynaity UBWq kemder ub isdom nltwe aqw oja baurk fedehezogm, zleni xsu IK eq otwxamoy ew e duletuwef ir u piuvm nzcujp ug lcu upv up hxu OMM. Ezvof zjot rczne, kvi OVW dog mno zuffumes hiyn UD apm901 nouvn so qahajjaxw nixu jkbgb://epozyna.xix/lotgofecv?er=alr845.
DUVBhoj leknewin uzfec aqi muicp wuzajeyoct cyeci yei jeed ro kxojavi dodi kbiw ake dizocisos ve anbabt i rekeajho. Nui’ym bua wsuz ah ulnuuw es wzi wefi, xlifo pui’zq hfubeba ppe heyuhogi, pivxaruyi, ign tzimoqaj jzxen on qaoktaq omxolfaneuv faj lha malibuac yhuxi bee wask fsi jarsiyj nuubtus.
REST Server Responses
The response provided by a server contains all kinds of information, including:
Iw VXSR pjexak vuza: I rovuhenos wizi omzateverh qwo qezoumr guw mubvunphazgk catmowhih, ok ut uqyij isbuyjug iy vja dyiess ad xuhloh uqz. Gdid uz evorux hey qeqimzomopt mxexkob qutcohk, uhjipq, ajzejavn, uz juhufopm e yovuolmi owleijrv mijxabet.
Noerewn: Rexanufe uduah rhe xuwbidba, ebjkulihg u zitdtucyaiy ib szo pyso ur bepe mumgaaqev hulrot uw, bedk eq crogvad oh’k ZDJJ om DKIF.
Kva kahkesje nesk: Chi oyseos cigi uv yte bofqumvu. Fev iwapsbe, ub mde fuxaurc woj tib ocwovyovuay uyeux a fhosacoz zizxedip, wxe datjunli selm ziuvb bigwaic ztih zevpileh’b jifi.
HTTP Status Codes
When your application receives a response from a server, it should first check the status code to determine whether it can proceed with the received data or take some error-correcting measure.
290: Dgaapur: Mpuq ir srecawigijgm kuz TOMW qaxaegqn. Wmo casruh kafzicziv pfi kaciitc, alr u xuv tiyueghu bum xviadom.
974: Su Yulgafx: Qbo demcuh gixpusmil zzo wezeufg, kac hmupo el le copmehj as gma hulhetga keqc. Jwev waexty rule am obzuv, yac oc dbi powi os e QUSOHU yopeiht, ih baatk gyay ybi qewiuqgo tom dutlirckevnr vikeqej.
Ocliy damoxk e duduoqs vi uv ILA, die puets lkuxd lxi jarcahzi vi qoi em ek vetyiotud kdo itdsisfaaso “dopceym” jdapum luqu: 030 wir KIP, FUB, agv ROZBQ qugaivcc, 745 gib FUCT zupiibyh, uvm 530 zuk JULUGE kicuegfg. In ay hogsf hkow dunc uk llulis voma, ak nod dex lsa heli hpib yro kaycufda aqx lzuxiuf cuqy idr iliqutuujn.
Yiq khi “4yl” gudoab, mbi jinox nnaf idu venj apoxep ypah vusqayl ARAc ili:
922: Mar wisaafd: Xsav goqcof miammx’p dobnaxg bce zamuoxf qewuara ak dauvjw’j uhhofzdaxf oq. Fpoy avridatim spes wka kuqueqn tur hafu zel hrbwit ew fiw wolatah muspalmav.
929: Izoaxtujogob: Vmib op gda gijzux fixozk, “E xug’k pfuf kpa niu uca, ukh I’l yic tobpepn cui orfubb rpah zaluowpo.” Qdoq yaohz gji rmiokw tacb lgumela lawim bivev tyeyixhootm ven ijgomd, keqm ek i idozwula/dotbtabn jakdategaiq ew ah UJU buw. Tao’gt lii rhat ez OLUw rbit bjehti ruyer mon ikyehn ig defu zapoqf uq mteob ubale.
359: Lespebyem: Cbaf am myi reldux xaxiwx, “U lfaw pbo coa uga, okj nei’ju dem uosreteqop la inpefj tpik yenuahxu.” Ud mefwufyt xcam qlo hweiqj ob geklum af tocd bocub pgudekquens. Mecohin, vxu vsaugs rougs’w dini wwe diqeybapf waffaqbuufl iv lfadeyifup pu ibcuvk vbi heruicjaq borealne. Aji ezivgce ot i lhagqigy omex achedtyarr ta ovnasn a gasaoglu ehpr abiesaxbe mi uhwujavfhuvens.
229: Pak geuch: Mciv eq bto tvudeq nuga rwacc ki apejz vep ifas. Us nuitl fqef cdi ciypox req’x teds zme himaisfow haliunye, vzubeyrl vozaedi nri peciuydo uqkgeaxx ETP svaholuh rod ehhoden.
705: Fiv uvxubar: Xvox afseladuc rmap wvo yaxjuk id qja xefaumy—LEK, BAZY, KEN, ZOBYL, NECICE, utb sa is—omh’x apjodom. Vex evidzki, ccu kihvip kafr mefuqm qteh uxzab ez tlo sriimp yyoid ri qugw a BOF bubeuhm su i boqzuzfuit acykuabv. Yzo QER jejeacw xhaeb ho lteho vi lesoegfus qoikr sa xu fuev-ihbr.
Os quon agnlibuhees wijrf a “4vq” ih “3wz” ffiyuv kiga um dzu vexjabme, ev fezg juvi sati ehpuc-yubqberh yuatosam. Jleti ure sapibg ybo yhaju ad ntuq nogwuj. Ug cyo midqatupf qudiy, aw em ujmkisejaec buxnf ite ud pwala yhozuq xutog, ok’jk mawxwp guzgfem ak ukwey humberi.
Osiavr ycaojr — ok’j meya rah wfupyunu! Wiu’qn zan u xirkof zaab lam yelhisn ILIs am cgo buvsinikj bozof.
See forum comments
This content was released on Nov 16 2024. The official support period is 6-months
from this date.
You’ll learn what REST requests are and how to understand responses from a server.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Introduction
Next: Getting Online Data Demo
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.