“Now that I have built my amazing AI app, how do I put it in the hands of my users?”

Two words. Rest API. 

Rest is an acronym that stands for: Representational State Transfer. To put it simply, it’s a protocol that provides a blueprint for organizing data exchanges between machines across the vast landscape of the World Wide Web. Why “representation“? Because we adhere to guidelines in representing data. “State” because data mirrors the ever-evolving state of a system, encapsulating variables that change over time, such as stock market information. And “transfer” because this protocol facilitates the exchange of information. 

API is an acronym for Application Programming Interface, with “interface” being the operative term. It’s the digital gateway that enables internet users to interact, whether they’re human or machine. But why the need for such protocols? Picture a world without them, a digital Tower of Babel. Protocols are the glue holding the internet together, the guardians of order in the often chaotic realm of the World Wide Web. 

Let’s take a concrete example: Imagine you want to uncover the postal code of Cherrapunji, the renowned record-holder for the world’s highest rainfall. You can achieve this by simply entering its name into a website like worldpostalcode.com. The resulting webpage will pinpoint the postal code on a map, accompanied by relevant details like lat-long coordinates and neighboring postal codes. This seamless exchange of information is orchestrated by a protocol known as HTTP, or Hypertext Transfer Protocol. Any computer equipped with a web browser that ‘speaks’ HTTP can access the website as demonstrated, without any unforeseen hiccups. 

But what if your needs extend beyond mere manual inquiries? What if you’re dealing with a deluge of geo-tagged messages, seeking to decode their origins for continuous monitoring? In such cases, the manual approach becomes impractical. This is precisely where the Rest API emerges as a beacon of efficiency. A Rest API, accessed much like a webpage through a URL, responds to your questions with answers. It’s worth noting that sometimes, the answer might be a straightforward “I don’t know!” Each unique query corresponds to a specific URL template known as a Rest API endpoint, as illustrated here: https://app.zipcodebase.com/api/v1/code/city?apikey=YOUR-APIKEY&city=cherrapunji&state_name=meghalaya&country=in. 

Let’s unpack this URL, shall we? One notable distinction is “/code/city,” signaling its purpose as the endpoint for city-to-postal code queries. To formulate the URL with this endpoint, we provide parameters such as city, state_name, and country. Can you decipher the role of the “apikey” parameter? Hint: It’s a guardian of security. 

The response from a Rest API typically arrives in a format known as JSON (JavaScript Object Notation), appearing something like this: 

	{
   "query":{
      "code":"10005",
      "unit":"km",
      "radius":"10",
      "country":"us"
   },
   "results":[
      {
         "code":"10005",
         "city":"New York",
         "state":"NY",
         "distance":0
      },
      {
         "code":"10270",
         "city":"New York",
         "state":"NY",
         "distance":0.14
      },
      {
         "code":"10041",
         "city":"New York",
         "state":"NY",
         "distance":0.24
      },
	   ...
	  {
         "code":"11102",
         "city":"Astoria",
         "state":"NY",
         "distance":9.99
      }
   ]
}
	
			
		    		
	    

While it might not appear overly impressive, the true power lies in its versatility. This plain, universal format, devoid of embellishments, makes automation a breeze—precisely why Rest API packs a punch. Furthermore, beyond retrieving information, Rest API encompasses all four of the CRUD verbs: Create, Retrieve, Update, or Delete information remotely. Most programming languages are fluent in JSON, capable of converting it into objects within the programming environment and vice versa, facilitating the exchange referred to as serialization. 

Having demystified the Rest API, you can see that exposing Rest API endpoints can place your amazing AI app directly into the hands of users. This opens up a world of possibilities for crafting innovative User Experiences around these endpoints. How easy is it to stand up a Rest API endpoint for your fantastic AI app? Surprisingly straightforward, depending on your choice and flexibility preferences. In future posts, we’ll delve into three options: Gradio, Streamlit, and Fastapi, each with its own trade-offs. Imagine not only learning to build incredible AI apps but also mastering the art of deploying them. 

Our FastAI coaching program is your gateway to the cutting-edge realm of artificial intelligence. Here, you’ll wield the power of Python and the enchantment of deep learning to craft AI applications that will astound the world. If you boast at least a year’s worth of Python experience, hesitate no longer. Reach out to us on WhatsApp, and let’s embark on this electrifying journey together.