paypalhttp is a lightweight, low-level HTTP client library developed by PayPal, designed to wrap API calls to REST APIs. It provides basic HTTP request and response serialization capabilities (JSON, multipart, form-encoded, text). The current stable version is 1.0.1, and it maintains a stable release cadence as a foundational utility for higher-level PayPal SDKs.
pip install paypalhttpVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate a basic `HttpClient`, define a GET request, and execute it against a public test API (`httpbin.org`). It highlights the low-level nature of `paypalhttp`, where you define the base URL and manage request details yourself. In a real PayPal integration, `paypalhttp.HttpClient` is typically subclassed to handle authentication and specific PayPal API base URLs.
Use a higher-level PayPal SDK (e.g., `paypal-checkout-serversdk` for checkout or `paypal-payouts-sdk` for payouts) which leverages `paypalhttp` internally and handles API-specific concerns and authentication.
When integrating with PayPal APIs, always use `paypalhttp` through a wrapper like `paypalcheckoutsdk.core.PayPalHttpClient` or implement your own `HttpClient` subclass to manage base URLs and inject authentication headers correctly.
After executing a request, always check `response.status_code` to determine if the API call was successful (typically `2xx`). Parse `response.result` for API-specific error details when the status code indicates an error.
Thoroughly review the PayPal API documentation for the specific endpoint you are calling to ensure your request body's structure, required fields, and data types (e.g., string vs. number, correct currency codes, maximum lengths) precisely match the API's expectations. Use a JSON validator to check for syntax errors.
Verify that your Client ID and Secret are correct and match the target environment (sandbox or live). Ensure they are properly base64-encoded and included in the 'Authorization' header as a Bearer token when obtaining an access token, and that the access token is correctly used for subsequent requests.
Access the deserialized response data via the `response.result` attribute. If the `response.result` itself is a dictionary-like object, then you can use `.get()` on it. For example: `data = response.result.get('some_key')` or `print(response.result)` to inspect its structure.Install the `paypalhttp` library using pip: `pip install paypalhttp`. If you are using a virtual environment, ensure it is activated before installation. If the issue persists, check your Python environment and `PYTHONPATH` settings.