REST is a way of designing a web service so that every thing it manages (a student, a mark) has a predictable address, and standard HTTP methods act on it. A student marks API is a good first project because the data is familiar, the rules are easy to state, and mistakes show up quickly as wrong status codes or bad data. This guide gives you a 14-day build plan, a method-route-status table, and a rubric to grade your own work.
Why a marks API teaches REST better than a to-do app
A marks system has relationships and constraints. A student has many marks. A mark must belong to a real student. A score cannot exceed the maximum. Those constraints force you to deal with the things beginners skip: validation, missing records, duplicates and clear error messages.
The core REST ideas you will practise are:
- Resources are nouns. Students and marks are resources. Actions like “fetch” or “delete” come from the HTTP method, not the URL.
- Methods carry meaning. GET reads, POST creates, PUT replaces, PATCH changes part of a record, DELETE removes.
- Status codes tell the client what happened. A client should never have to read the message text to know whether a request worked.
- Stateless requests. Each request carries everything the server needs; the server does not remember your previous call.
Data model for the student marks API
Keep the model small so the design decisions stay visible. The field names below are illustrative; you can change them, but stay consistent.
| Resource | Field | Type | Rule |
|---|---|---|---|
| Student | id | integer | Generated by the server, never sent by the client |
| Student | roll_no | string | Required, unique, 1 to 20 characters |
| Student | name | string | Required, non-empty after trimming spaces |
| Student | programme | string | Optional free text, for example “BCA” |
| Mark | id | integer | Generated by the server |
| Mark | student_id | integer | Taken from the URL, must match an existing student |
| Mark | subject | string | Required, one mark per subject per student per exam |
| Mark | exam | string | Required, for example “mid-term” |
| Mark | score | number | Required, 0 up to max_score |
| Mark | max_score | number | Required, greater than 0 |
Free 2-Week CareerSwami Internship
Online, 14 days, with a free offer letter and a free completion certificate once you finish the work. Check with your college that it fits your requirement before you enrol.
HTTP method, route and status code map for the marks API
This table is the centre of the project. Build every row, and write a test request for both the success case and at least one failure case.
| Method | Route | Purpose | Success code | Failure codes |
|---|---|---|---|---|
| GET | /students | List students, with optional filters | 200 | 400 for a bad filter value |
| POST | /students | Create a student | 201 plus a Location header | 400 malformed JSON, 409 duplicate roll_no, 422 invalid fields |
| GET | /students/{id} | Fetch one student | 200 | 404 unknown id |
| PUT | /students/{id} | Replace a student record | 200 | 404, 409, 422 |
| PATCH | /students/{id} | Change selected fields | 200 | 404, 409, 422 |
| DELETE | /students/{id} | Remove a student and their marks | 204, no body | 404 |
| GET | /students/{id}/marks | List marks for one student | 200 | 404 if student missing |
| POST | /students/{id}/marks | Add a mark | 201 | 404 student, 409 duplicate subject and exam, 422 invalid score |
| PATCH | /students/{id}/marks/{mark_id} | Correct a score | 200 | 404, 422 |
| DELETE | /students/{id}/marks/{mark_id} | Delete a mark | 204 | 404 |
| GET | /students/{id}/summary | Total, percentage and per-subject view | 200 | 404 |
Two decisions worth thinking about. First, 400 versus 422: a common convention is 400 when the request cannot be parsed and 422 when it parses but fails your business rules. Pick one convention and apply it everywhere. Second, the summary route is a read-only computed view; it should never be written to directly.
A 14-day plan for building the student records API
The free two-week online internship from CareerSwami runs for 14 days, so this plan is sized to fit that window. Treat it as a pacing guide, and adjust the tasks to your track and your own schedule.
| Days | Focus | Output to keep |
|---|---|---|
| 1 | Set up Python, a virtual environment and a framework (Flask or FastAPI) | A “hello” route returning JSON |
| 2 | Write the data model on paper, then in code | Field table and in-memory storage |
| 3 | GET and POST for /students | Two working routes, 200 and 201 |
| 4 | GET one, PUT, PATCH, DELETE for students | Full student CRUD |
| 5 | Validation functions for student fields | One reusable validator |
| 6 | Consistent error format and 404 handling | A single error helper |
| 7 | Review week one against the rubric below | Scored self-check |
| 8 | Marks routes: create and list | Nested routes working |
| 9 | Score validation and duplicate checks | 409 and 422 cases covered |
| 10 | Update and delete marks, cascade on student delete | No orphan marks |
| 11 | Summary route, filtering and pagination | Percentage calculation |
| 12 | Move storage to SQLite | Data survives a restart |
| 13 | Write a request collection or test script | Success and failure case for every route |
| 14 | Final rubric score, README, clean-up | Repository ready to show |
Worked illustration: adding a mark and getting the error response right
This example is illustrative. It shows the intended behaviour of the design above; it is not output from a run.
A client sends a request to add a mark for student 7:
POST /students/7/marks
Content-Type: application/json
{"subject": "Data Structures", "exam": "mid-term", "score": 46, "max_score": 40}
The score is higher than the maximum, so the request is well-formed but breaks a rule. The design calls for 422 and a body that names the field:
HTTP/1.1 422 Unprocessable Entity
{
"error": "validation_failed",
"message": "One or more fields are invalid.",
"details": [
{"field": "score", "problem": "must be between 0 and max_score (40)"}
]
}
Now the corrected request with a score of 36 should return 201 with the created record and a Location header such as /students/7/marks/12. If the same subject and exam is sent again, the right answer is 409, because the request is valid but conflicts with existing data. If student 7 does not exist, the right answer is 404 before any validation of the body.
A sketch of the validation logic in Python, shown as an illustration of the idea:
def validate_mark(data):
errors = []
for f in ("subject", "exam", "score", "max_score"):
if f not in data:
errors.append({"field": f, "problem": "is required"})
if errors:
return errors
if not isinstance(data["score"], (int, float)) or isinstance(data["score"], bool):
errors.append({"field": "score", "problem": "must be a number"})
elif data["max_score"] <= 0:
errors.append({"field": "max_score", "problem": "must be greater than 0"})
elif not (0 <= data["score"] <= data["max_score"]):
errors.append({"field": "score",
"problem": f"must be between 0 and {data['max_score']}"})
return errors
Note the order: check required fields first, then types, then ranges. Checking in that order prevents crashes from comparing a string with a number.
Self-check rubric for naming, validation and error responses
Score each row from 0 (absent) to 2 (done consistently). The maximum is 30. Be strict with yourself; a reviewer will be.
| Area | Check | 0 | 1 | 2 |
|---|---|---|---|---|
| Naming | Routes use plural nouns, not verbs such as /getStudent | Verbs used | Mixed | All nouns |
| Naming | Nested routes show ownership (/students/{id}/marks) | Flat query hacks | Partly nested | Fully nested |
| Naming | JSON field names follow one style, such as snake_case | Mixed styles | Mostly one style | One style throughout |
| Methods | GET never changes data; DELETE is not done through GET | Violated | One slip | Clean |
| Methods | PUT and PATCH behave differently | Identical | Unclear | Clearly different |
| Validation | Required fields are checked | None | Some | All |
| Validation | Types are checked, including rejecting text for score | None | Some | All |
| Validation | Ranges and business rules enforced (score within max) | None | Some | All |
| Validation | Whitespace-only names and duplicates are rejected | Accepted | One handled | Both handled |
| Errors | Correct status code for each failure type | Always 200 or 500 | Mixed | Correct throughout |
| Errors | One JSON error shape across all routes | Varies | Mostly same | Identical |
| Errors | Messages name the field and are safe (no stack traces) | Traces leak | Vague | Specific and safe |
| Errors | Unknown routes and malformed JSON return JSON, not an HTML page | HTML | One of two | Both JSON |
| Success | 201 on create with Location, 204 on delete with no body | Always 200 | One right | Both right |
| Testing | Every route has a success and a failure request saved | None | Some | Every route |
Reading your score: 26 to 30 means the design is consistent and ready to show. 18 to 25 means the structure works but some failure cases are untested. Below 18, go back to days 5 and 6 and fix validation and the error helper before adding features.
Typical design slips in a student marks API
- Returning 200 with an error inside the body. Clients and tools rely on the status code; put the failure there.
- Letting the client choose the id. The server generates identifiers.
- Trusting the body for the student id. In a nested route, the URL decides which student the mark belongs to.
- Storing percentage in the database. Compute it in the summary so it never goes stale after a correction.
- Using floats carelessly. Marks such as 36.5 are fine, but compare with care and decide on rounding for percentages.
- Forgetting cascade behaviour. Decide what happens to marks when a student is deleted, and document it.
SRMU students: using this API project alongside your programme
SRMU’s homepage describes it as a private university on Lucknow-Deva Road, Uttar Pradesh, that offers B.Tech and other programmes. It also says the university combines academic learning with industry exposure, internships, technical training and placement preparation. That page gives no rules, duration, credits or evaluation details for internships, so do not assume this project counts toward any university requirement.
The same homepage links to programme pages for B.Tech CSE (Data Science & AI), B.Tech CSE (Cyber Security) and BCA (Data Science & AI), among others. Students on those programmes will meet databases, web development or data handling at some point, and a records API is a natural practical exercise. Whether your own syllabus includes a project or training component, and in which semester, is not something this guide can state; the programme page or syllabus document is where to look.
The homepage navigation also lists a Placements section with a Placement Cell page and a Placement Policies page. If you plan to show this project to a recruiter, those pages are the official place to learn how the cell works. A third-party listing on Careers360 says the training and placement cell coordinates summer training, projects and industry visits, but that is an outside description, so treat it as a lead to check rather than a rule.
The project itself needs only a laptop and Python, so you can do it during a semester break or alongside classes. The Academic Calendars page is linked from the homepage and is the place to check when breaks fall. Plan the 14 days around your exams, not the other way round.
Verification steps for SRMU students before you rely on this project
- Open your programme page from the SRMU homepage and download the current syllabus; look for any project, training or internship component and its semester.
- Ask your department coordinator in writing whether an online, self-arranged internship is accepted, and what document (letter, certificate, report) is required.
- Read the Placement Policies page on srmu.ac.in and note anything about eligibility, training records or project submissions.
- Visit or email the Training and Placement Cell and ask how students should present personal projects such as a GitHub repository.
- Check the Academic Calendars page for exam dates and breaks before you fix your 14-day start date.
- Keep a copy of every written reply, with the date, in one folder.
Presenting the finished API: README, requests and repository
A reviewer should understand your project in under five minutes. Include in the README:
- One paragraph on what the API does and the framework used.
- Setup commands that start the server from a clean machine.
- The method, route and status code table from this guide, updated to match what you built.
- Two or three example requests with the exact responses, including one error response.
- A short “design decisions” note covering your 400 versus 422 choice, cascade behaviour and the error format.
- A list of what you did not build, such as authentication, so the scope is honest.
If you complete the CareerSwami internship, you receive a free offer letter and a free completion certificate after successful completion. These show participation; the repository is what shows skill, so make sure it stands on its own.
Extensions once the core API passes the rubric
- Pagination and sorting on /students with limit, offset and sort parameters.
- Grade bands in the summary, with the thresholds held in configuration rather than hard-coded.
- Token-based authentication so only a teacher role can write marks.
- Automated tests using pytest and the framework’s test client.
- OpenAPI documentation, which FastAPI generates for you, to compare with your hand-written table.
Frequently Asked Questions
Should I use Flask or FastAPI for a student marks API?
Either works. Flask is minimal and makes you write validation yourself, which is good for learning. FastAPI validates types for you and generates interactive documentation. If this is your first API, start with Flask and rebuild the validation by hand, then try FastAPI as a comparison.
What is the difference between PUT and PATCH in this project?
PUT replaces the whole student record, so the client must send every required field. PATCH changes only the fields included in the request. Implement both and test that PATCH leaves untouched fields unchanged.
Why return 204 for DELETE instead of 200?
204 means the action succeeded and there is no body to return. It tells the client plainly that nothing more is coming. Some teams return 200 with a message; what matters is choosing one approach and using it for every delete route.
Is 400 or 422 correct for a score above the maximum?
Both appear in real APIs. A widely used convention is 400 for unparseable requests and 422 for well-formed requests that break rules. Pick one convention, write it in your README, and apply it consistently.
Do I need a database for the first week?
No. Plain Python dictionaries or lists are enough while you learn routes and status codes. Moving to SQLite in the second week lets you see the difference between data that vanishes on restart and data that persists.
Can I count this project toward my SRMU internship or project requirement?
That depends on your programme’s rules, which this guide cannot confirm. SRMU’s homepage mentions internships in general terms but gives no regulations. Ask your department coordinator in writing and request the relevant clause or circular before assuming it counts.
Does the CareerSwami internship give a stipend or academic credit as a Shri Ramswaroop Memorial University student?
No. It is a free two-week online internship with a free offer letter and a free completion certificate after successful completion. It does not promise a stipend, credit, placement or a job.
How do I test the API without writing a frontend?
Use curl, a request client such as Postman or Insomnia, or a short Python script using the requests library. Save one success and one failure request for every row in the method table, then rerun them after each change.
Related Python & Backend Engineering guides
- Maharaja Chhatrasal Bundelkhand Vishwavidyalaya Students: Backend Internship Ethics and Data Handling
- Sri Sathya Sai Institute of Higher Learning Students: Service-Minded Backend Projects for Internships
- NIFTEM Students: A Food-Supply Inventory API as a Python Backend Internship Project
- All Python & Backend Engineering internship guides
Ready to put this into practice?
Join the free two-week CareerSwami online internship in Python & Backend Engineering. The internship, the offer letter and the completion certificate are free.














