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.
Start practicing
Networking And Restful Apis — choose a session length
Free · No account required
Domain overview
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.
Exam objectives
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
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.
Click any question to see the full explanation and answer options, or start a focused practice session above.
When working with raw sockets, what does the 'socket.SOCK_STREAM' constant represent?
2You 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?
3You 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?
4When using the 'socket' module, what is the effect of calling 'socket.settimeout(5.0)' on a socket object?
5In the 'requests' library, which HTTP method is typically used to update an existing resource on a server?
6You 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?
7When 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?
8You are developing a multithreaded HTTP scraper. When using the 'requests' library inside 'threading.Thread' objects, what is the recommended practice for handling session persistence?
9When using 'requests.get()', how can you include a custom HTTP header in your request?
10What is the purpose of the 'socket.shutdown()' method in Python?
11Which status code indicates that a requested resource has been successfully created?
12You are using 'concurrent.futures.ThreadPoolExecutor' to fetch data from multiple REST APIs. What happens if an exception is raised inside a thread?
13You need to send binary data over a socket. Which method should you use on the socket object to ensure all data is sent?
14Which of the following headers is commonly used in REST APIs to indicate the format of the request body?
15In a multithreaded network application, you observe 'ConnectionResetError'. What is the most likely cause when using Python sockets?
16What is the primary difference between the 'socket.AF_INET' and 'socket.AF_INET6' address families?
17Which module provides a high-level API for working with URLs, such as parsing and unparsing them?
18When receiving data from a TCP socket using 'recv(buffer_size)', what does the returned value represent?
19You 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?
20How do you properly handle a non-200 status code when using 'requests' if you want to avoid manual status code checking?
21When implementing a timeout in 'requests.get()', what is the consequence of setting it as a single float (e.g., timeout=5)?
22In Python socket programming, what does the 'SO_REUSEADDR' socket option achieve?
23When sending a JSON payload with 'requests.post()', which argument should you use to automatically set the 'Content-Type' to 'application/json'?
24Which standard Python library module is used for lower-level networking and creating server/client sockets?
25You are building a custom HTTP client and need to handle persistent connections (keep-alive). What is the primary role of the 'Connection' header?
26Which THREE of the following are valid HTTP request methods commonly used in RESTful API design?
27Which THREE of the following are attributes of the 'requests.Response' object?
28You 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'?
29Which TWO of the following are potential pitfalls when using multithreading for network operations in Python?
30Which THREE of the following steps are required to initialize a TCP server socket?
31Which TWO of the following represent common data formats used for REST API request/response payloads?
32Which THREE of the following are valid ways to pass data to a REST API using 'requests'?
33Which TWO of the following statements about the Python 'requests' library are correct?
34Which TWO of the following are commonly used for debugging REST API integrations?
35Which THREE of the following are correct regarding socket buffer sizes?
36Which TWO of the following exceptions might be raised during socket operations?
37Which TWO of the following are true regarding the HTTP 'User-Agent' header?
38Which THREE of the following are standard ways to handle API authentication?
39Which THREE of the following are true regarding the use of 'threading' and 'requests' in Python?
40You 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?
41You 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?
42You 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?
43You 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.)
44A 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?
45You 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?
46You 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?
47You 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?
48You 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.)
49Your 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?
50You 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?
51You 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.)
52You 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?
53You 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?
54You 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?
55You 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?
56You 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.)
57You 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?
58You 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?
59You 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'?
60You 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?
61You 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)`?
62You 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.)
63You 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?
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.
The Courseiva PCPP1 question bank contains 63 questions in the Networking And Restful Apis domain. Click any question to see the full explanation and answer breakdown.
Start with a 10-question focused session to identify your baseline accuracy in this domain. Read every explanation — even for questions you answer correctly — to understand the reasoning. Once you score consistently above 80%, move to a 20–30 question session to confirm depth before moving to the next domain.
Yes — the session launcher on this page draws questions exclusively from the Networking And Restful Apis domain. Choose 10, 20, 30, or 50 questions for a focused session, or click individual questions to review them one by one.
Save your results, see per-domain analytics, and get readiness scores — free, for every certification.
Sign Up FreeFree forever · Every certification included