diff --git a/README.md b/README.md index 1723b0e2e..62f399fd0 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,20 @@ If your beta feature requires a `Stripe-Version` header to be sent, set the `str stripe.add_beta_version("feature_beta", "v3") ``` +### Custom requests + +If you would like to send a request to an undocumented API (for example you are in a private beta), or if you prefer to bypass the method definitions in the library and specify your request details directly, you can use the `raw_request` method on `StripeClient`. + +```python +client = StripeClient("sk_test_...") +response = client.raw_request( + "post", "/v1/beta_endpoint", param=123, stripe_version="2022-11-15; feature_beta=v3" +) + +# (Optional) response is a StripeResponse. You can use `client.deserialize` to get a StripeObject. +deserialized_resp = client.deserialize(response, api_mode='V1') +``` + ### Async Asynchronous versions of request-making methods are available by suffixing the method name diff --git a/examples/raw_request.py b/examples/raw_request.py new file mode 100644 index 000000000..5d142f909 --- /dev/null +++ b/examples/raw_request.py @@ -0,0 +1,15 @@ +from stripe import StripeClient + +# Set your API key here +api_key = "{{API_KEY}}" + +client = StripeClient(api_key) +response = client.raw_request( + "post", + "/v1/beta_endpoint", + param=123, + stripe_version="2022-11-15; feature_beta=v3", +) + +# (Optional) response is a StripeResponse. You can use `client.deserialize` to get a StripeObject. +deserialized_resp = client.deserialize(response, api_mode="V1")