liveBook · Manning

Contract

As explained in Software Engineering for Data Scientists

An application programming interface is a defined interface through which software components request functionality or data from another software component.

An application programming interface (API) lets one software component communicate with a service without knowing how that service works internally. A client sends a request, the remote service processes it, and the API returns results. section 9.3.1

APIs are useful when a Python model must be called from another language, run on another server, or support a web application. FastAPI can convert Python model-prediction code into an API. section 9.0 section 9.3

Common API design and transport choices include:

  • REST commonly uses request types such as GET, POST, PUT, PATCH, and DELETE; REST APIs are stateless between requests. section 9.3.1
  • HTTPS is a common transport for REST APIs; WebSocket supports bidirectional real-time communication, while TCP/IP provides a lower-level client-server mechanism. section 9.3.1
  • SOAP is an older, more complex API architecture used less frequently than REST. section 9.3.1

From a request to a model prediction

A browser sends a search term to a remote server and receives search results without running the server’s ranking code. The same pattern can accept a customer ID, fetch its features from a database, pass them to a churn model, and return the prediction. Another language or system can make the request while Python handles the model computation. section 9.3.1

Figure 9.6 This diagram shows a simplified version of making an API request. Here, the client represents your device, such as phone or computer. The client sends a request to a remote server, which then computes some results (such as search results) and returns them to the user. The user never directly interacts with or runs any code.
ch9 simple api example

Use the client-server diagram to trace how a device sends a request, how the remote server computes results, and how the API returns them without exposing implementation details. section 9.3.1

How Software Engineering for Data Scientists covers it

How deep it goes
Defines client-service communication and compares request types, architectures, and transports without detailing endpoint implementation.
Examples
Uses Google search, browser request types, customer churn predictions, database feature retrieval, and cross-language Python services.
What it assumes
Assumes familiarity with Python-based models and client-server applications while explaining API communication through common examples.
What you can do after
Apply it via FastAPI to expose Python model predictions to other languages, systems, servers, or web applications.
How it connects
Connects REST, SOAP, HTTPS, WebSocket, TCP/IP, databases, machine learning models, and command-line interfaces.

Also explained in

Compare how 58 books explain contract →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Engineering for Data Scientists. The section links point to the parts of the book it draws on.