DataCareerHub
Explore learning
← Shared foundationsFree companion · 25 minute suggested activity

Document a minimal service contract

HTTP, JSON & API contracts · Shared foundation workshop · Describe inputs, outputs, limits and failure behavior clearly.

Learn → Try → ExplainReviewed 2026-10-15
01

Objective & prerequisites

Describe inputs, outputs, limits and failure behavior clearly. Prerequisites: basic Python expressions and files; use a disposable local practice folder and fictional data. This shared workshop complements the existing data/AI tracks and does not create a second progress system.

02

Understand the concept

An API contract includes route/method, authentication, content type, fields/types, bounds, response schema, status categories and examples. Documentation must distinguish an example response from a live capability. Versioning helps consumers reason about changes, but version labels do not replace compatibility tests. Keep secrets out of example requests.

03

Worked example

For the local sum_cents tool, input is a closed rows envelope with at most 50 rows; output is total_cents. Unknown actions are rejected. There is no network route, account token or hosted deployment in this pure-Python reference.

python3 foundation_labs.py FoundationTests.test_contract_and_total
04

Try it yourself

Write a one-page contract for a future loopback service wrapping safe_total. Include valid input, duplicate rejection and a zero-row policy, and label the proposed route as not implemented. Record your prediction before running the supplied reference, then compare the observed result and explain any difference.

Worked solution

The current function accepts an empty list and returns 0; document whether that means an intentionally empty population or requires a completeness warning upstream. Do not invent an HTTP endpoint in the report. Tests cover the function contract, not a deployed API.

06

Knowledge check

Should a proposed endpoint be described as already deployed? Try answering without rereading the example.

Check and explain

No. Distinguish the executed function, a local service experiment and a future hosted deployment.

08

Mini-project, mistakes & handover

Produce a short README with the question, exact local command, input meaning, checks and actual results. Include one failure case and its explanation. Never silently turn an exception into a passing result. Mark simulated behavior explicitly, credit the supplied teaching code and identify your own contribution. These activities are unsaved self-practice, not certification.

09

Authoritative reference

Read the official reference ↗

— consulted for the underlying interface/concept. The lesson and fictional examples are original teaching material. Python reference tested with 3.12; designed for 3.10+. Git lab requires Git 2.28+.

Make the reasoning yours.

Try the activity before reading its reference. Keep your sources, commands and assumptions with your work. Companion activities are unsaved self-practice and do not award a certificate or change lesson progress.

Resume guidance and examples are for learning and preparation only. They do not guarantee interviews, a job offer or employment.

Public registration, payments and new paid enrolment remain disabled. These free resources do not grant access to protected course modules.

Learner dashboard ↗ · Ask a question ↗