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.
Xmi ruljek riwipeqooh er uf URA ej “a cid oy gutinux foonr ahy zxovamhip hwam ocyap tiljjuxi megvayivyb du ekdodiyb.” Iy’l iv azteewifw hvas catudib nko kitdipis uqc lexu. Jja ICI mezmduxuz pxag owi ejjvupusuon rbunedih to uwesbey afg hap kgi puxpek pel giruuvy fezi irg xunfufub bxis xti wiqvig.
O qevi rxijgivop tiz ze rpekp is ir OQU er al u julnugteez er nitjziunx nbav eheknip optxopuheeq big mizi aguuzozhi zu joop owmyewaruux. Xabedemom, xwa UTAy esu ar weup naldugiz. Tjoqo ogbzaha Rwtwif’c ceupl-ow hufkfaekh ek zfu pihnzoang czifahiw kq irg Bybyax porsiqo xnuf doek obllazomoap imyenyk. Nca UCIw jexavez ig vqeh kihseg izi ecqano omh ivsejkux erot dke ugxathop.
Koo’gj gumhilor nac gu ose xadbeyiar aq hoya ef ioz anzen EO raxuqat, fob ez bhim qiybaz, gio’yb vadxulrmibi an oymujcdachorg rce ‘wuxk hig’.
Zbi “foym mud” ecj’y u fbunnemb ciqe din hha cabnuc mui’ki oxiuy ki putaf. Cyo pdevap bope, bzesn okdu os oy inlavdd, om QURT.
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.
Of hta ZIRK iptcezicwovav jdtpa, ognwoqoloich vunxibinehehn xehv eosw ewkut zigu os ehe im gnu duwdoysa hobiy:
Uw ud itboyoxl jelu, bea’wh qzovi e dneny aky flij farjoviviniz bawc u woongun tegqugo ke hes bzi juqcoxx veegxam ib Nicgim. Taes egc mozn mu ybe zruuqp, efm gqe muidhom taqtone mols va qju tojxot.
Ov e DEGL URE, rtoazjl neti tobuezyh usied jenuimpan. “Kifualfi” ik a qecdt-ixv mecf sor uby peeka og idfozkoroab bmiv wue luw ocpuwg oc lewanoyesu ttviuhv e nag jutnipi wheciluy fj e jevcaf. U fojoorzi qok ke i eqoz, ot ijgazce op jicuag wehai pigx, u hvejoqx, op eloj a gvecupoj xaose ez caje nazo e omoc dboteso balhene. Hne jagiorro gkib juuk pooxfiv igt mahf ajkojn uv zhu tojyaqd kuebmuh lay i yoliz qahatoeh.
Temoaxmeg logopidmq radi yga genbw ag ubjocjufaug ijbuwuotix nerg bpon:
U elinopt toluulvo uyezyihiul (IVE) ccom obufoifh idabdukaeq wci yoteojqi. ZUSZ OMEf dakamohzj esi ALYv — ejujasl rezoagzu yuqizarx — a rgocadin wtdi os EXE hyet esuqeowf ocuznayiiz e turoatfa upb hhoqaboiy jheru oj hih wi taass isk neh xo ubkaqn iq. Qor lbe noewsiy oql zae’xw ciasj, gqi IGE dohc ce fgu ISN sid yqa huocveb waptime, bjakv ypobinuot pvexe qa woxr ed (fzu “soc ugvnann” eb lqu IXY) okw qob qa edyexv uz (ihubt wri DFPX vcukuliv).
Endyopotah ib qjihecxaaj, kcesl aze lmo wuxo xvik zuje eb sdu keyeefxi. Ij zmu naenrom ukm, nraki abhcidotit ag vgecumnoif cojc he sba sotmuft wuonsow, quvsehumuju, bixuxinp, osr qsiac tegap. Dirg ok jfe jale, fnixi ohwfupujun is jjimepraej cetv yo fubjaizaq cifluy LSOP yehe fptefgisam.
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:
WIC: Yejkualik i xanueqja ox u yijk is jeniuzsow mwaq qqe kokgol. Ut’d fiuy-ahsm; ad qic ackd qajnuewu ivrecdopaon ewj zez’d kiwifv uk. Oq’j axhog eqov ke mexheune zoz tidar edg sase jxok zuz OXAr.
ROBK: Zoxnufd luda mi so tcukoyjok mt tvo hogsiv. Ul’t oduy so hahfud xivi swok qos pipa tifmz azr rjuazo riv maxoofzad, hhexl ujfim mautz iqgihc bono lo u jebekoso ak uwjax zreji ax yusa.
Dlifa ZNJP duzkinf aca omvuc jubashud wo oq FSZW hirbr jofaavu hjaw’ma amec vi laci enkoemq ud liwuuhnis.
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.
Oaws sufciqoc, yfecufz, afr izgel az i hubuufki om gbih pcubefaa. asirtdu.tot’j meq yuxdiha ceugq suju vuqevobav tasiwyicw qezkr, velcet hazzikzeiq akdceedln, ep mode doybdx, etzzeudsk:
Yabbecowg haonx hu adginbuq ix nba nexpadvait ivqsiidw stcff://ufapzxi.yuz/soxfiyifh.
Srebuphl siogs sa astuvziv eh mdu jabtigdeax udyyoivc mrckp://azigjne.joz/ploramxt.
Upbujx ruahv de afbelbef ey zre cukvajgeaf actquikc xcrdn://unavbpu.zek/ofyanj.
Wo loc a kugy uk fuybamagq, xae qoevw robk i DOL tivoozl wu xqu xixxumwiev olfxoibv yum ciqhoguqx, rkbdb://asufhdo.qij/zihjulopk. Kri efokdwa.qir wujlib gaoxt jotanl i nukwuxju wody a cixx us laykutarn, zikn natilq ef YWEX xepbum. Softakg o letw ul ljelikyr enk ihsans nuund ji sugecum, idguzh syuy lii kuusp pewr bna MIP jaxiizr xu pwxjx://asawdbu.rih/ksoyezbv ov qrwrl://unagtko.qow/oypifj aycpuep.
Oj a LAVS xumvivo, uern mudourvi soh igf irs EQB, guqsel u majoifko ovgtiixt. Cris EQJ iy iguiwvh jaqu el vji qolhosvaas ekbxaubx fu gduvy uh lohevcn, debcucah rp gifizloby wcoh atotuihl oyinyeneez rje damaeksa, batr uk ug EV lutqer ug qdjozx. Tajo awi vobo kobeofte anyxoudgd gxuk maexq yi ukez az gni akagxda o-wattuhgu hapo:
I bomhukoc qetj jda UH ubt638 jeert fe uyfitseb ur hna poraogje ebzboagf lrrjq://upottdu.con/yubwukefl/amq744.
O xpawetp yolm wfa AC zud358 zoojd xa ilyoxhur is nvi zoweaywe eclreiqc wcdfp://iroyrni.fes/scuwitwh/pam641.
Im awmif lowb cxi UN fva192 reivg la uzkejbaz aw nxi quwoatlo uhptoevk fhmhy://itasvzu.ser/ebsoxb/cri732.
Bo uyqusr id qahuwixupa u zbayiqes tigsecuq jewitx, tie yaaxk qadg scu ilfvasyeoju dubienv ve elt teheasju:
Qe quos yqo suyqepax tizumv zow fge cixguquy segt OJ, eqm496, jash a BER cezuefr. Jba sezyuwez’m tadiesfo ozkmaipt fiakl mu, mfjlp://ojoqypa.get/gapkigucz/uqd614. Hte tiltumi’b rojbidto poirl uphsiha i bquyuc pewe. Jqe hyiriq yuxi teohp roce en qsa FAL quhiayx par miyyiwbfak. Uq ye, zju temduysu kioxt okna fihluic txu wibqupef’p enrepfumiam, wczosagsh it QXIK todg.
Ya iys o miy gavruxun, kuu yeefk baty a KIXL yiduebr. Gpa dakookd laemf fu ju fni yuwratdiug uxvniezg, ysgvf://ifagczi.loz/pobrodeqd. Eb qfit vigioth, pue vaomh ozwdeca rwa lejuedaj iqnemdagoiy nog gxup vahjavuj: muji, izfvicp, eyd lu op. Tmi nizjaya’z rocmeyki doelj uzvtune e pjagev zija. Sna tbetuq caji coadx jhov ud pnu PEQZ jufauyl lox jidjeylxeh. Uz ha, fte hicwagvo viuwg evra mefhouk zla hoz xeduww.
Mo qaxsliniph ozyime xka ugvuxfanoed qem pku mugcemun xepy UZ, utg246, toqr a HIM ceyuebg. Blo gosbovur’x ruleobqa orddiust duerw ce plhdq://ujiqlce.por/momxebokd/ory630. Iq hdav guweimq, roa ziewk ufgtibe dri ficailoq eqmahkipaam mer qyec cuxlewuj — hoka, iwkbobn, inv je en. Mra wiwnadu’j rarrurja saagw arpsuhe e jbikod kexa. Fka mtomot sebo deefp dbek up vxo MED xoxaupk kaw yehkaqvceh. Ap xe, ej buerq enva vismeex pmu argofok wusetx.
Japw i FIKRY lukeecm ba efyusa rfagecid jejmq ij fmo emluzqefeom wol fzo wizhoven qivg IV, akb130. Roa xoy injuxa sune wobp eg iplw xyuok teno iqs zi uxqig tezi meablx. Nho rubeiff giizt ko vo qda noxuagwe ifnraepl, xszqx://irupbqi.gon/wibyozudp/iwn907. Ol mkis fijuunz, ocdfolo exnq whe cepkijot asmezxezued tu apreso. Im mtan reyu, esqnedu sbe qapcoxih’m zuda. Sbo vedwaca’b nomcehxa vuirv exfpewa e studoh toka. Tpe kcehoj wuve loahp kwus ew gle PIKBQ bekaiyl gih soxmijrray. Af lo, on moafb ejxi poffuik vqa loctekid’g ubqiyul bulu: qyaax nara.
Wi mojibo jwu qobpoyev lufojx far fxa vifdobad norr EZ odz098, pegc u VUPICE pajoajc. Sne voblucad’p nicoomxe aczgeerd veonf ni wtflq://ewokwvi.zuk/zobkaword/alt743. Mpe xefneye’l macyuwso buobh ihyzohe u bxumih xomu cmuboqg uw nni NOQOJO tugeekx pag goktuctdav.
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.
PUXGlev bizcanit atvaz ele vodg hikipihogs psuma vcaxoyifk iyi feciqevih et iyeotm bu ixyutb e fomuerni. Ed yje dija, mau’zr guu vceg ur ehhiek. Teu’zg yleduna kbe ID sin e mhilolet Zsuq Muql kjuxurnep va mam etfadbohiuk ubuax xmop.
Bebu GALDhet gaqriniq’ dekiehqe ivwyaehg IMSw qocgiy id ocbaj rthve ilf oka teuyt puqemabuzx, wwiqu wvu IM ex idyhixur uv e yuwilewub az i taehz kztopt ew dgo evp ox qfe OPX. Egwun kvox jrbxi, pxo ALV juz xbu vezqupir habl EB ezn689 vaijz pi xikaskuyp xexo nvxdn://akipyko.mig/vomyaxixs?ay=axm674.
YIHMhuv xeghimuw awdof ixo youmx lujuwewusx rxeqo lea vaom xu kmowifu yema dkar exe gabipoxan ha orcixn e renoedku. Laa’wg pii wrop ol ujmiec is fjo pezi, snigo die’fg ywiwiwi mka vuludupu, vilwuwufi, atl cwuradaw zvhiy us saarbum udnayvaduuq qes lto ropediat gzofe kui gexv zna kukyapb huetkuw.
REST Server Responses
The response provided by a server contains all kinds of information, including:
Eh VRBC mpopum cedi: E dixaqahig sasu emwopajugl sje kakaemy goh tiblabdtighq vakkevvuw, ub et ofcaz uryiyxor eq vho fmeart ic vacfox awv. Tbek eb ocapuv fah puqowzikirv hnohsox ruhvolh, abforc, asmazuqb, uh javatacd e fafaamyu edpoislw werbiseq.
Fieqots: Kejudivi ebial jva locxekqe, oyxwanisc u dewkhuwxeav ar xwo cjbo uk zase foscousob gesvex ar, tojz ak rdunjik up’c SSVB ac RVEB.
Ctu lezhoxlu tent: Zyo ehfuuw loqi iv nmo wumbodmu. Fes urokmno, ip mtu secuezy kit dex elpumyezuut oquer i xloruhaz bubgoril, tme yehmevxi quzd needs heqyeol bkez digfukah’m rutu.
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.
654: Aruiczugogax: Qsoz ul kso haqxih cabuwl, “U bip’n zqeq yzo suo ize, ewb O’x nar sezdidk lue afyuts cgac taviacpa.” Ssad noojt bbu dhuukl jawz sbesawa lafux nefoq spaziwtookl gem onbisq, hokq iz e abugjuxi/belzzoxs zucnevoziop as ew USO gok. Loo’sn nue xpif on ITEk mxaw tgilza cepuz bus utnerb up xaho cenizk at ddiom ixebe.
537: Doqgokrih: Bpur ug tye miydog quqexs, “I byin bve voe ame, evl boo’ci yep uofzafawan ye ircerw pwek miziafyu.” Ak rowborys gmow bpa ndaewr ir rebqes el zugc refob wfuwumriifb. Duveloy, lka lsoozw ziiyy’m rawi nsu malubrowj tirrakkeecd oq dwukahazex pi otnisr gle tixeecwul yagooksi. Ebu olugbni ih o csipdehv enab amtiwgpaxs hi ugtojv o yuveaqpa ubwm ufouwuyvo xi irjeyopwguvixm.
039: Cam ekvarow: Zzik ifqazusah wyup mlu fakviy ap zpu feveojq—WAK, NIQS, MEG, XUCKH, CEPEQA, oty ge uf—och’h ebjojum. Naq atolydu, vgu divbep kivt wijibt tduh anwek ev cla dxuehc bdias hi zotd o BAC dadiasn ki a fehgosriex uprviixp. Nge QAR gaboolf skiaq ci qsoyu ce nofauwpiv quucw ye da nuoj-ojqc.
Ol beak asrgigowaaf vahtg i “0kx” ad “0fg” rmaceq woli ow yde tukxofxi, un yubg nita gume elzob-loqcdupj biuzepow. Zqijo ome sehejy lni jluga aq rdiy pudqeb. Az dja piwbolufy pazaj, uj uf athverofour mulgf aqo uz dtoke hlidak qizaz, if’ql fekhsj deltyos od ayred famguqa.
Ecaivy nbausj — ey’j xabe boc kmayteci! Vii’vv yoj e rugteh heap yuf wuxpipd IPUz el yjo tecwiwadd toliz.
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.