Introduction to API and web services

An API is a defined way for one program to talk to another, and a web service is an API you reach over the web, so your Android app can pull data from a remote server it does not own, like a weather feed or an events API.

10 min read · 6 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

Talking to servers you do not own

So far FestConnect Mobile talked to Firebase, a backend you set up. But apps often need data from other servers: a weather feed, a maps service, a public events listing, systems you do not own and cannot change. How does your app get data from them?

Through an API, and specifically a web service. This final unit is about your Android app consuming external web APIs: sending a request over the internet and using the data that comes back. This lesson defines API and web service; the rest of the unit shows how to actually call one from Android.

Theory

API and web service

An API (Application Programming Interface) is a defined set of rules by which one program can request services or data from another. It is a contract: 'ask in this way, and you will get this back'. APIs let programs cooperate without knowing each other's internals.

A web service is an API you reach over the web (over HTTP). Your app sends a request to the service's URL (an endpoint), and the service replies with data, usually JSON. Because it works over standard web protocols, a web service is platform-independent: your Android app (Kotlin) can call a service written in any language, running anywhere. That interoperability is the whole point.

Formula

Request to an endpoint, data back

The mental model is simple: your app sends an HTTP request to a web service's endpoint (a URL like https://api.example.com/events), and the service sends back data (typically JSON) that your app then uses.

So consuming a web service is a conversation over the internet: ask at the right URL, receive structured data, display or process it. Everything in this unit, REST, JSON parsing, Volley, GET and POST, is about doing that conversation correctly from Android. Keep this picture in mind: endpoint in, JSON out.

Quiz

What is a web service?

  1. A website designed for humans to read in a browser
  2. An API accessed over the web (HTTP) that lets programs exchange data, usually JSON, across platforms
  3. A type of Android layout
  4. A database stored on the phone
Show the answer

An API accessed over the web (HTTP) that lets programs exchange data, usually JSON, across platforms

A web service is an API reached over the web (HTTP): programs send requests to its endpoint and receive structured data (usually JSON), and because it uses standard web protocols it works across languages and platforms. Option A describes a normal website meant for human eyes in a browser; a web service serves PROGRAMS and returns data, not a styled page. Option C is unrelated: layouts define UI, not remote data exchange. Option D describes local, on-device storage; a web service is a REMOTE service reached over the internet. The essence: an API over HTTP for programs to exchange data.

Think first

Why consume external web services instead of building everything yourself?

Why would your app call someone else's API rather than providing all data itself? Then tap.

Show the answer

Because no single app can produce all the data and functionality users want, and web services let you TAP INTO specialist systems that already do it well, saving enormous effort and giving richer features. Think about what an app might need: current weather, maps and directions, currency rates, payment processing, translation, sending SMS, a feed of public events. Building and maintaining any one of these from scratch would be a massive project, gathering weather data worldwide, mapping every road, keeping exchange rates current, and it would be foolish to duplicate what dedicated providers already offer through APIs. By CONSUMING their web services, your app asks the weather service for weather, the maps service for directions, the payments service to charge a card, and focuses its own effort on what makes IT unique. This is the same reason software is built from libraries and services rather than reinvented each time: specialisation and reuse. Web services make this practical across the internet because they are platform-independent, your Kotlin app can call a service written in anything, so a whole ecosystem of data and capability becomes available with a simple HTTP request. The trade-offs are dependence on those providers (their uptime, pricing, and terms) and needing network access, which is why you also handle errors and sometimes cache. But the ability to compose your app from the world's APIs, plus your own logic, is a large part of what makes modern apps so capable. Reuse the world's services; build only what is uniquely yours.

Summary

Key takeaways

  • An API (Application Programming Interface) is a defined set of rules for one program to request services or data from another.
  • A web service is an API accessed over the web (HTTP), letting programs exchange data (usually JSON) across platforms.
  • This unit is about the Android app consuming external web APIs (beyond Firebase).
  • The app sends an HTTP request to the service's endpoint (URL) and receives structured data back.
  • Web services are platform-independent, so a Kotlin app can call a service written in any language.
  • Consuming external services lets your app reuse specialist data and functionality instead of building everything itself.
  • Memory hook: an API is a contract between programs; a web service is that API over HTTP, endpoint in, JSON out.

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Working with Data and API in Android

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Introduction to API and web services · Advance Mobile Application Development - II (Major-15-02) · Gri-Learn