Now whenever we talk about the REST Web services, there are two terms that should always come to your mind - first is, either you are exposing the web service (acting as server) or you will be consuming the web service (acting as client).
Exposing a web service means that you have made the web service and has deployed it on your server and this can be consumed by any client by using the URL to our service.
Let us make a simple REST API and also understand the design aspects of making the REST API. In this tutorial we will build a simple Registration API. It will have students, classes and the information of students enrolled in different classes.
So first, let's summarise what this registration app can do:
Now let's start designing the application. The first thing we should do is designing the Database Model.
ER diagram of the Registration App.
If we look at the ER Diagram of the Registration app, the basic entities are:
Now let's define the URI for our application's various services. Notice that in the registration application everything will be URI.
This will give information about all the students.
This will give information about all the courses.
This will give information about all the registrations data.
This will give information about the registration of student with roll no 1.
Notice two things about the URI:
The advantage of such resource based URI is that they are not dependent on the framework you use.
Now the URI for student with the student ID 1 will be
/Myapp/students/1 and for the student ID 2 it will be
Similarly with the courses we can have resource based URI. For example: for course with ID 1 it will be,
To get the registrations for a particular student we will use the query parameter, which we will discuss in the upcoming lessons.