简体   繁体   中英

Do applications use API to create a GUI?

I wanted to know is it common practice to use a REST API to create GUI?

Let's say we have Facebook or LinkedIn for an example:

When I download their mobile application, the application has a page for me to log into my facebook/LinkedIn account. When the application is loaded does facebook send something like a GET("/login") request to their API which returns something like this to the program. Which then the mobile application decides what to do with this information

{
  [
    {"username": "string", "opts": []},
    {"password": "string", "opts": ["hidden"]}
  ]
}

I wanted to ask if it's common practice to do this and whether I should build my mobile applications like this or is the application UI programmed without using an API?

I wouldn't say this is common practice . They probably do have a central api which the mobile clients consume, but it's probably data related, with the client UI being just the application's responsability.

I would only envisage such a scenario under extraordinary requirements. For example, say you have some sort of payment api through which various clients can send payment (ie card details) regarding transactions. If you want to become PCI compliant , you'd probably need to host this api in a secure cloud location, with all resources and assets having to come from the same place (ie payment form, javascript, css etc). It's certainly not natural, to say the least.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM