Chapter 9. Software Interfaces
This chapter will first show you how to use Python to get information from APIs that are used now to share data between organizations, and then highlight the tools that most Python-powered organizations would use to support communication within their own infrastructure.
We already discussed Pythonâs support for pipes and queues across processes in âMultiprocessingâ. Communicating between computers requires the computers at both ends of the conversation use a defined set of protocolsâthe Internet adheres to the TCP/IP suite.1 You can implement UDP yourself over sockets, Python provides a library called ssl for TLS/SSL wrappers over sockets, and asyncio to implement asynchronous transports for TCP, UDP, TLS/SSL, and subprocess pipes.
But most of us will be using the higher-level libraries that provide
clients implementing various application-level protocols:
ftplib
, poplib
, imaplib
, nntplib
, smtplib
, telnetlib
, and xmlrpc
.
All of them provide classes for both regular and TLS/SSL wrapped clients
(and urllib exists for HTTP requests, but recommends the Requests library for most uses).
The first section in this chapter covers HTTP requestsâhow to get data from public APIs on the Web. Next is a brief aside about serialization in Python, and the third section describes popular tools used in enterprise-level networking. Weâll try to explicitly say when something is only available in Python 3. If youâre using Python 2 and canât find a module ...
Get The Hitchhiker's Guide to Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.