PCPP1 · domain
Networking And Restful Apis
This domain covers Python networking and REST API consumption for the PCPP1 exam. It tests the standard library socket module, the requests library, HTTP methods, JSON parsing, API key authentication, and safe handling of nested response data. Questions present realistic client/server and API scenarios requiring correct library and error-handling choices.
Focused practice
Practice Networking And Restful Apis questions
Scored sessions drawing only from this domain — pick a length below.
Start 20-question practice test →What this domain covers
What to know about Networking And Restful Apis
Candidates must write Python code that performs HTTP requests with requests, sends API keys as query parameters, parses JSON, and handles missing nested keys safely. The most important thing is choosing the correct library and using safe dictionary access rather than direct indexing.
Using the socket module for low-level TCP client and server socket creation
Sending GET requests with requests and passing API keys as query parameters
Parsing JSON responses with response.json() and accessing nested dictionaries safely
Managing requests.Session objects across multithreaded HTTP scraper threads
Watch out for
Common Networking And Restful Apis exam traps
- ▸Assuming requests is part of the standard library; it is a third-party package, while socket and urllib are standard.
- ▸Accessing nested JSON keys directly instead of using .get() or exception handling, causing KeyError on missing fields.
- ▸Sharing one requests.Session across threads without synchronization, leading to race conditions or corrupted state.
Question index
All Networking And Restful Apis questions (63)
Click any question to see the full explanation, or start a practice session above.
Which THREE of the following are true regarding the use of 'threading' and 'requests' in Python?
Hard2You are consuming a paginated REST API that returns a JSON object with a 'data' list and a 'next' field holding the URL of the following page, or null on the last page. You want a loop that retrieves every record exactly once. Which TWO statements about implementing this loop correctly are true? (Choose two.)
Medium3Which of the following headers is commonly used in REST APIs to indicate the format of the request body?
Easy4You are writing a Python client to consume a REST API. The API documentation states that the server may respond with a 307 Temporary Redirect when a resource has moved temporarily. You need to ensure that your client, built with the 'requests' library, preserves the original HTTP method and body when following such redirects. Which of the following best describes how 'requests' handles a 307 redirect by default?
Medium5You are writing a Python script that uses the `socket` module to create a TCP client. After calling `sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)`, which method should you call next to initiate a connection to a remote server at `('example.com', 80)`?
Medium6Which module provides a high-level API for working with URLs, such as parsing and unparsing them?
Medium7Which TWO of the following exceptions might be raised during socket operations?
Medium8Which TWO of the following represent common data formats used for REST API request/response payloads?
Easy9You are writing a client that must upload a binary file to a REST endpoint using requests.put(). The file is several hundred megabytes, and you want to avoid loading it entirely into memory while still letting the server know the total size. Which approach meets both goals?
Medium10Which THREE of the following are attributes of the 'requests.Response' object?
Medium11A Python script consumes a REST endpoint that returns a JSON document. You call response = requests.get(url) and want to convert the body into native Python objects. The response is guaranteed to be valid JSON. Which expression gives you the deserialized data?
Easy12In the 'requests' library, which HTTP method is typically used to update an existing resource on a server?
Easy13What is the purpose of the 'socket.shutdown()' method in Python?
Medium14When receiving data from a TCP socket using 'recv(buffer_size)', what does the returned value represent?
Easy15Which THREE of the following steps are required to initialize a TCP server socket?
Hard16When sending a JSON payload with 'requests.post()', which argument should you use to automatically set the 'Content-Type' to 'application/json'?
Medium17When using 'requests.get()', how can you include a custom HTTP header in your request?
Easy18You need to send binary data over a socket. Which method should you use on the socket object to ensure all data is sent?
Medium19You are developing a multithreaded HTTP scraper. When using the 'requests' library inside 'threading.Thread' objects, what is the recommended practice for handling session persistence?
Hard20You are writing a Python script that needs to parse a URL and extract the query parameters. The URL is 'https://api.example.com/v1/items?limit=10&offset=20'. Which module should you use to reliably parse this URL and retrieve the value of 'limit'?
Easy21Which status code indicates that a requested resource has been successfully created?
Easy22You need to perform a HEAD request to check if a file exists on a server without downloading the body. How is this done with 'requests'?
Medium23What is the primary difference between the 'socket.AF_INET' and 'socket.AF_INET6' address families?
Easy24In a multithreaded network application, you observe 'ConnectionResetError'. What is the most likely cause when using Python sockets?
Hard25You are using the socket module to create a TCP client. After creating the socket object, which method call is required to establish a connection to a remote server listening on 192.168.1.50 at port 8080?
Medium26You are writing a Python tool that must connect to a REST API over HTTPS. The API's server certificate is signed by an internal corporate CA whose root certificate is stored in a file named corp-ca.pem. You use the requests library and need the connection to be verified against that specific CA while still performing normal hostname checking. Which call accomplishes this?
Medium27Which TWO of the following are true regarding the HTTP 'User-Agent' header?
Hard28Which THREE of the following are correct regarding socket buffer sizes?
Medium29You are building a Python script that consumes a REST API which returns paginated JSON responses. The API includes a 'next' link in the response body for the next page. You need to follow these links until all pages are retrieved. Which approach is most appropriate using the requests library?
Medium30You are developing a Python application that needs to retrieve data from a public REST API. The API returns JSON data and requires you to send a GET request with a custom User-Agent header. Which of the following code snippets correctly sends the request using the requests library?
Easy31You are implementing a Python client that communicates with a REST API over HTTPS. The API uses a self-signed certificate. You need to verify the server's certificate against a custom CA bundle while also ensuring that the hostname is verified. Which approach correctly configures the 'requests' library?
Hard32Which THREE of the following are valid HTTP request methods commonly used in RESTful API design?
Easy33Which TWO of the following are commonly used for debugging REST API integrations?
Easy34You are developing a Python application that uses the `requests` library to consume a REST API. You need to implement a retry mechanism for transient HTTP errors (e.g., 500, 502, 503, 504) and connection timeouts. Which TWO of the following approaches are valid and recommended for achieving this with `requests`? (Choose two.)
Hard35You are building a client for a REST API that requires an OAuth 2.0 bearer token. The token is long-lived and stored in an environment variable. You want every request in a session to carry the Authorization header without repeating the header setup at each call site. Which approach is correct and idiomatic with the requests library?
Hard36You wrote a small REST client that calls `requests.get('https://api.example.com/v1/items', timeout=5)`. Under normal network load the call succeeds, but the server occasionally takes longer than 5 seconds to start sending the response body while the TCP connection is already established. You want to allow up to 5 seconds for the connection to be established and up to 30 seconds for the server to send data after the connection is made. Which call achieves this?
Medium37You are implementing a Python client that uses the `socket` module to communicate with a server. The server sends data in chunks, and you need to ensure you receive all data until the connection is closed by the server. Which approach correctly reads all data from the socket?
Hard38You are writing a REST client that must handle HTTP error responses robustly. For each response, you want to detect server errors and extract the error message returned in a JSON body. Which TWO of the following approaches are correct and safe? (Choose two.)
Medium39You are designing a Python microservice that exposes a REST API. A client sends a PUT request to update a resource with a JSON body. Your service must ensure idempotency: if the same request is received multiple times, the resource should end up in the same state. Which HTTP method and semantics should you implement to guarantee idempotency for updates?
Hard40When implementing a timeout in 'requests.get()', what is the consequence of setting it as a single float (e.g., timeout=5)?
Hard41When working with raw sockets, what does the 'socket.SOCK_STREAM' constant represent?
Medium42Which standard Python library module is used for lower-level networking and creating server/client sockets?
Easy43You are writing a script that downloads a large file from a REST endpoint using `requests.get(url, stream=True)`. You want to write the content to disk in chunks rather than loading it all into memory. Which approach correctly implements chunked reading?
Easy44Which TWO of the following are potential pitfalls when using multithreading for network operations in Python?
Medium45You are designing a Python REST API client that must handle HTTP errors gracefully. The client uses the requests library. Which TWO of the following statements about error handling with requests are correct? (Choose two.)
Hard46Which THREE of the following are standard ways to handle API authentication?
Easy47You are investigating a network bottleneck in your Python application using `requests`. If you aren't using a `Session` object, what performance-related behavior should you expect?
Hard48You are writing a Python script that needs to send a GET request to a REST API and parse the JSON response. The API requires an API key passed as a query parameter. Which code snippet correctly performs this request using the requests library?
Easy49When using the 'socket' module, what is the effect of calling 'socket.settimeout(5.0)' on a socket object?
Medium50In Python socket programming, what does the 'SO_REUSEADDR' socket option achieve?
Hard51You are designing a REST client that must call an endpoint protected by OAuth 2.0 using the client credentials grant. The authorization server expects the client identifier and client secret to be sent in the request body as `application/x-www-form-urlencoded`, along with `grant_type=client_credentials`. Which `requests` call correctly obtains the token?
Hard52You are using 'concurrent.futures.ThreadPoolExecutor' to fetch data from multiple REST APIs. What happens if an exception is raised inside a thread?
Hard53Which TWO of the following statements about the Python 'requests' library are correct?
Hard54You are building a REST client that needs to handle 429 Too Many Requests status codes. Which strategy is most effective when implementing an automatic retry mechanism?
Hard55When using the 'requests' library to perform a GET request, which parameter should be passed to the 'params' argument to include query string parameters in the URL?
Easy56You are designing a Python application that consumes a REST API which returns JSON data. The API responses can be large, and you need to process the JSON incrementally to avoid loading the entire response into memory. The server supports chunked transfer encoding. Which of the following techniques should you use with the 'requests' library to stream the response and parse it incrementally?
Hard57You are implementing a REST API client in Python using the 'requests' library. The API requires authentication using OAuth 2.0. You need to obtain an access token and then use it to authenticate subsequent requests. Which TWO of the following statements about handling OAuth 2.0 with 'requests' are correct? (Choose two.)
Hard58You are consuming a REST API that returns data in JSON format. After calling response.json(), you notice the data contains nested dictionaries. What is the most Pythonic way to handle a missing key in the response dictionary safely?
Medium59How do you properly handle a non-200 status code when using 'requests' if you want to avoid manual status code checking?
Medium60You are writing a Python script that must download a large file from a REST API endpoint. The file is several gigabytes, and you want to avoid loading it entirely into memory. Which approach using the requests library is most memory-efficient?
Medium61You are building a custom HTTP client and need to handle persistent connections (keep-alive). What is the primary role of the 'Connection' header?
Hard62Which THREE of the following are valid ways to pass data to a REST API using 'requests'?
Easy63Your team uses a REST API that requires a Bearer token in the Authorization header for every request. You want to configure a `requests.Session` so that all requests made through it automatically include this header, and you also want to reuse the underlying TCP connection across calls. Which approach is correct?
MediumOther domains
All PCPP1 exam domains
Frequently asked questions
- What does the Networking And Restful Apis domain cover on the PCPP1 exam?
- Candidates must write Python code that performs HTTP requests with requests, sends API keys as query parameters, parses JSON, and handles missing nested keys safely. The most important thing is choosing the correct library and using safe dictionary access rather than direct indexing.
- How many questions are in this domain?
- This page lists all 63 Networking And Restful Apis questions in the PCPP1 question bank. The actual exam draws from this domain proportionally to its weighting in the official exam blueprint.
- What is the best way to practise this domain?
- Start with a short focused session (10 questions) to identify gaps, then work through explanations. Repeat with a longer session once the weak areas feel solid.
- Can I practise only Networking And Restful Apis questions?
- Yes — the session launcher on this page filters questions to this domain only. Choose any session length for inline explanations and scoring.