Congratulations on reaching the final module of Introduction to APIs for Data!
So far, you have learned what APIs are, how they work, how to retrieve information, how to display API data, and how to protect API connections.
Now it is time to bring everything together.
In this module, you will build a simple Student Information Dashboard. The application will collect sample information from an API and display it on a webpage.
Course progress: 8 out of 8 modules (100%)
An API-powered application is a website or software that uses an API to obtain or exchange information with another system.
For example, imagine that you are using a school website to check examination results.
The website may not store all the information directly on the page. Instead, it requests the information from a server through an API.
The server sends the information back, and the website displays it.
A simple web application may use four important technologies:
| Technology | What It Does |
|---|---|
| HTML | Creates the structure of the webpage. |
| CSS | Controls the appearance and design. |
| JavaScript | Makes the webpage interactive and communicates with the API. |
| API | Provides information or performs operations on a server. |
Think of building a house:
We will build a Student Information Dashboard for an imaginary secondary school in Ibadan.
The dashboard will display sample user information from a public testing API.
It will include:
Build a webpage that requests sample records from an API and allows users to search through the returned information.
Before building an API-powered application, you need to choose an API that provides the information your application requires.
For this project, we will use JSONPlaceholder.
JSONPlaceholder is a public testing API that provides sample information for developers and learners.
Our API endpoint:
https://jsonplaceholder.typicode.com/users
This endpoint returns a list of sample users.
We will use the returned names, email addresses, and addresses as pretend student information.
Before writing code, let's understand how our application will work.
USER OPENS WEBPAGE
|
v
STUDENT DASHBOARD
|
v
USER CLICKS LOAD STUDENTS
|
v
JAVASCRIPT SENDS API REQUEST
|
v
API SERVER PROCESSES REQUEST
|
v
SERVER RETURNS JSON DATA
|
v
JAVASCRIPT PROCESSES DATA
|
v
STUDENT RECORDS DISPLAYED
|
v
USER CAN SEARCH RECORDS
Now let's build the complete application.
We will write the HTML, CSS, and JavaScript in one file to make the project easier for beginners.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Student Information Dashboard</title>
<style>
body {
margin: 0;
padding: 20px;
}
.container {
max-width: 850px;
margin: auto;
padding: 25px;
border-radius: 12px;
}
h1 {
}
button {
border: none;
padding: 12px 18px;
border-radius: 6px;
cursor: pointer;
}
button:hover {
}
input {
width: 100%;
padding: 12px;
margin: 15px 0;
border: 1px solid #ccc;
border-radius: 6px;
}
.student {
padding: 15px;
margin-bottom: 12px;
border-radius: 8px;
}
.student h3 {
}
.message {
margin: 15px 0;
}
.error {
}
</style>
</head>
<body>
<div class="container">
<h1>Student Information Dashboard</h1>
<p>
Welcome to the student information dashboard.
Click the button below to load sample records.
</p>
<button id="loadButton">
Load Students
</button>
<input
type="text"
id="searchBox"
placeholder="Search by student name..."
disabled
>
<div id="message" class="message"></div>
<div id="students"></div>
</div>
<script>
let allStudents = [];
const loadButton =
document.getElementById("loadButton");
const searchBox =
document.getElementById("searchBox");
const message =
document.getElementById("message");
const studentContainer =
document.getElementById("students");
async function loadStudents() {
message.textContent = "Loading student records...";
message.className = "message";
studentContainer.replaceChildren();
loadButton.disabled = true;
try {
const response = await fetch(
"https://jsonplaceholder.typicode.com/users"
);
if (!response.ok) {
throw new Error("Unable to retrieve records.");
}
const data = await response.json();
allStudents = data;
displayStudents(allStudents);
message.textContent =
allStudents.length + " sample records loaded.";
searchBox.disabled = false;
} catch (error) {
message.textContent =
"Something went wrong: " + error.message;
message.className = "message error";
} finally {
loadButton.disabled = false;
}
}
function displayStudents(students) {
studentContainer.replaceChildren();
if (students.length === 0) {
message.textContent = "No matching records found.";
return;
}
students.forEach(student => {
const card = document.createElement("div");
card.className = "student";
const heading = document.createElement("h3");
heading.textContent = student.name;
const email = document.createElement("p");
email.textContent =
"Email: " + student.email;
const city = document.createElement("p");
city.textContent =
"City: " + student.address.city;
card.appendChild(heading);
card.appendChild(email);
card.appendChild(city);
studentContainer.appendChild(card);
});
}
searchBox.addEventListener("input", function() {
const searchTerm =
searchBox.value.toLowerCase().trim();
const filteredStudents = allStudents.filter(student =>
student.name.toLowerCase().includes(searchTerm)
);
displayStudents(filteredStudents);
});
loadButton.addEventListener("click", loadStudents);
</script>
</body>
</html>
Let's understand the important parts of the application.
<h1>Student Information Dashboard</h1>
<button id="loadButton">
Load Students
</button>
<div id="students"></div>
This creates the heading, button, and area where student records will appear.
const response = await fetch(
"https://jsonplaceholder.typicode.com/users"
);
This sends a request to the public API.
const data = await response.json();
This reads the JSON response and converts it into JavaScript data.
allStudents = data;
The returned information is saved inside the allStudents variable so that the application can use it later.
displayStudents(allStudents);
This sends the information to the function responsible for displaying the records.
const filteredStudents = allStudents.filter(student =>
student.name.toLowerCase().includes(searchTerm)
);
This checks the names and returns only the records that match the search.
Follow these steps:
You should see sample names, email addresses, and cities displayed on the webpage.
You should also be able to search for names and display matching records.
A good developer does not stop after making an application work. They also look for ways to improve it.
Here are some features you can add:
Testing means checking whether your application works as expected.
| Problem | What to Check |
|---|---|
| Nothing appears | Check your internet connection and browser console. |
| API request fails | Check the endpoint and server response. |
| Search does not work | Check the search event and filter function. |
| Information is missing | Check the JSON property names and response structure. |
| Page looks untidy | Review your CSS and HTML structure. |
The browser console helps developers find errors.
In most desktop browsers, you can open developer tools by pressing F12 and selecting the Console tab.
You may see messages such as:
Failed to fetch
404 Not Found
TypeError
These messages can help you understand what went wrong.
The application we built is a learning project. It retrieves sample information from a public testing API.
A real school management system would need more features.
| Learning Project | Real School Application |
|---|---|
| Uses sample records. | Uses authorised school records. |
| Displays information. | May allow authorised users to manage information. |
| Does not require a private login. | Requires secure authentication. |
| Does not store real student records. | Needs a properly protected database. |
| Uses a public testing API. | Uses a controlled API with permissions and security checks. |
You have now built a Student Information Dashboard. It is time to design your own API-powered application.
Choose one of the following project ideas:
Before submitting your project, check the following:
You have reached the final assessment for Introduction to APIs for Data. Choose the correct answer for each question.
What is an API-powered application?
Which technology provides the structure of a webpage?
Which technology controls the appearance of a webpage?
Which technology can make an API request from a webpage?
Which JavaScript function can request data from an API?
Why do developers use response.json()?
Which method can help search through an array?
What is the purpose of a loading message?
Why should a real school application use authentication and authorization?
What should you do when an API request fails?
Let's review everything you have learned across the eight modules.
| Module | Topic |
|---|---|
| 1 | Introduction to APIs and Data |
| 2 | How APIs Work - Requests, Responses and Endpoints |
| 3 | Understanding HTTP Methods and Status Codes |
| 4 | Introduction to JSON and XML Data Formats |
| 5 | Working with REST APIs and API Documentation |
| 6 | Working with API Data Using JavaScript |
| 7 | API Security, Authentication and Data Protection |
| 8 | Building a Complete API-Powered Application |
After completing this course and practising the exercises, you should be able to:
You do not need to know everything about programming before you start working with APIs. The best way to improve is to keep practising, building small projects, and learning from your mistakes.
Every great developer started as a beginner.
You have successfully reached the end of Introduction to APIs for Data.
Keep practising the projects and exercises. Try connecting different APIs and building applications that solve real problems.
Build an application that retrieves information from an API, displays the information, and allows users to interact with it.
Do not just learn how APIs work. Use them to build something useful!
Course: Introduction to APIs for Data
Modules: 8
Final Project: API-Powered Application
Platform: CRMNuggets
CRMNuggets
Learn. Practice. Get Certified.