Skip to content

Commit

Permalink
Add Custom requests section to README (#1405)
Browse files Browse the repository at this point in the history
  • Loading branch information
jar-stripe authored Oct 1, 2024
1 parent de20eeb commit 206b394
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions examples/raw_request.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 206b394

Please sign in to comment.