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.
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

























































