-
Notifications
You must be signed in to change notification settings - Fork 433
fix(proxy): enable HTTP/2 support for forwarding #1416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
526108000404604 |
API v2 overviewUnderstand the behavior of APIs in the v2 namespace. The Stripe API provides two namespaces that contain different sets of endpoints:
Key differences between the v1 and v2 namespace
Read more: Sandboxes | Read more: Idempotency | Read more: Event destinations | Read more: List pagination | Read more: Expanding responses | The SDKs that support API v2All server-side SDKs support APIs in the Using API v2 with the Stripe CLIUse To access APIs in the SDK, CLI, and API versioningSDKs and the Stripe CLI automatically include an API version for all requests. After you update your SDK or CLI version, Stripe simultaneously updates the API version of your requests and responses. Include Stripe-Version without SDK or CLIAll API requests to the API For example, a curl request using API version curl -G https://api.stripe.com/v2/core/event_destinations \
-H "Authorization: Bearer {{YOUR_API_KEY}}" \
-H "Stripe-Version: 2024-09-30.acacia" \Using APIs from the v1 and v2 namespaces in the same integrationYou can use any combination of APIs in the Javaimport com.stripe.StripeClient;
StripeClient stripe = new StripeClient("{{YOUR_API_KEY}}");
// Call a v2 API
EventDestination eventDestination = stripe.v2().core().eventDestinations().retrieve("ed_123");
// Call a v1 API
Customer customer = stripe.customers().retrieve("cus_123");Node.jsimport Stripe from 'stripe'
const stripe = new Stripe('{{YOUR_API_KEY}}');
// Call a v2 API
const eventDestination = await stripe.v2.core.eventDestinations.retrieve('ed_123');
// Call a v1 API
const customer = await stripe.customers.retrieve('cus_123');Pythonimport stripe
client = stripe.StripeClient('{{YOUR_API_KEY}}')
# Call a v2 API
event_destination = client.v2.core.event_destinations.retrieve('ed_123')
# Call a v1 API
customer = client.customers.retrieve('cus_123').NETRubyrequire 'stripe'
client = Stripe::StripeClient('{{YOUR_API_KEY}}')
# Call a v2 API
event_destination = client.v2.core.event_destinations.retrieve('ed_123')
# Call a v1 API
customer = client.v1.customers.retrieve('cus_123')PHP$client = new \Stripe\StripeClient('{{YOUR_API_KEY}}');
// Call a v2 API
$eventDestination = $client->v2->core->event_destinations->retrieve('ed_123');
// Call a v1 API
$customer = $client->customers->retrieve('cus_123');Gosc := stripe.NewClient("{{YOUR_API_KEY}}")
// Call a v2 API
eventDestination, err := sc.V2CoreEventDestinations.Retrieve(context.TODO(), "ed_123", nil)
// Call a v1 API
customer, err := sc.V1Customers.Retrieve(context.TODO(), "cus_123", nil)If you’re not using an official SDK or the CLI, always include the namespace in the URL path for your API calls. For example: # Call a v2 API
curl https://api.stripe.com/v2/core/event_destinations
# Call a v1 API
curl https://api.stripe.com/v1/charges -d amount=2000 -d currency=usdList paginationAPIs within the
You can use these URLs to make requests without using our SDKs. Conversely, when you use our SDKs, you don’t need to use these URLs because the SDKs handle auto-pagination automatically. You can’t change list filters after the first request. JavaStripeClient stripe = new StripeClient("{{YOUR_API_KEY}}");
EventDestinationListParams params = EventDestinationListParams.builder().build();
for (EventDestination eventDestination : stripe.v2().core().eventDestinations().list(params).autoPagingIterable()) {
// process event destination object
}Node.jsconst stripe = new Stripe('{{YOUR_API_KEY}}');
stripe.v2.core.eventDestinations.list().autoPagingEach((ed) => {
// process event destination object
});Pythonclient = stripe.StripeClient('{{YOUR_API_KEY}}')
for ed in client.v2.core.event_destinations.list().auto_paging_iter():
# process event destination object.NETRubyclient = Stripe::StripeClient('{{YOUR_API_KEY}}')
client.v2.core.event_destinations.list().auto_paging_each do |event_destination|
# process event destination object
endPHP$client = new \Stripe\StripeClient('{{YOUR_API_KEY}}');
foreach($client->v2->core->event_destinations->all()->autoPagingIterator() as $eventDestination) {
// process event destination object
}Gosc := stripe.NewClient("{{YOUR_API_KEY}}")
params := &stripe.V2CoreEventDestinationListParams{}
for eventDestination, err := range sc.V2CoreEventDestinations.List(context.TODO(), params) {
// handle err
// process event destination object
}Using query parameters in API requestsUse filters on list endpoints to constrain results. Use include parameters on supported GET endpoints to return additional fields in the response. Filters and include parameters let you pass an array of values. When you make direct API requests (not using server-side SDKs or the CLI), you must always specify the index of the array value using bracket notation, even if you only pass a single value. For example, to list all Accounts where the curl -G https://api.stripe.com/v2/core/accounts?applied_configurations[0]=merchant
-H "Authorization: Bearer {{YOUR_API_KEY}}" \
-H "Stripe-Version: 2025-12-15.clover" \To list all Accounts where the configuration is curl -G https://api.stripe.com/v2/core/accounts?applied_configurations[0]=merchant&applied_configurations[1]=customer
-H "Authorization: Bearer {{YOUR_API_KEY}}" \
-H "Stripe-Version: 2025-12-15.clover" \You can use the same pattern for include parameters. For example, to include multiple fields in a response, use the following syntax: curl -G https://api.stripe.com/v2/core/accounts/:id?include[0]=requirements&include[1]=defaults&include[2]=identity
-H "Authorization: Bearer {{YOUR_API_KEY}}" \
-H "Stripe-Version: 2025-12-15.clover" \In some cases, an array is nested within a query parameter. For example, to retrieve a list of payout methods, you can provide an array of values to filter on the curl -G https://api.stripe.com/v2/money_management/payout_methods?usage_status[payments][0]=eligible&usage_status[payments][1]=invalid
-H "Authorization: Bearer {{YOUR_API_KEY}}" \
-H "Stripe-Version: 2025-12-15.preview" \IdempotencyAPIs in the
A request is considered an idempotent replay of another request if the following are all true:
To specify an idempotency key, use the All Idempotency differences between API v1 and API v2API v1 and API v2 idempotency have a few key differences:
Making idempotent requestsUsing the SDK, provide an idempotency key with the For example, to make an API request with a specific idempotency key: JavaStripeClient stripe = new StripeClient("{{YOUR_API_KEY}}");
String idempotencyKey = "unique-idempotency-key";
Example result = stripe.v2().examples().create(
ExampleCreateParams.builder()
.setName("My example")
.build(),
RequestOptions.builder()
.setIdempotencyKey(idempotencyKey)
.build());Node.jsconst stripe = new Stripe('{{YOUR_API_KEY}}');
const idempotencyKey = 'unique-idempotency-key';
const result = await stripe.v2.examples.create({
name: 'My example'
}, {idempotencyKey: idempotencyKey});Pythonclient = stripe.StripeClient('{{YOUR_API_KEY}}')
idempotency_key = 'unique-idempotency-key'
example = client.v2.examples.create(
{ 'name': 'My example' },
{ 'idempotency_key': idempotency_key },
).NETRubyclient = Stripe::StripeClient('{{YOUR_API_KEY}}')
idempotency_key = 'unique-idempotency-key'
result = client.v2.examples.create(
{ 'name': 'My example' },
{ 'idempotency_key': idempotency_key },
)PHP$client = new \Stripe\StripeClient('{{YOUR_API_KEY}}');
$idempotencyKey = 'unique-idempotency-key';
$example = $client->v2->examples->create(
[ 'name' => 'My example' ],
[ 'idempotency_key' => $idempotencyKey ],
);Gosc := stripe.NewClient("{{YOUR_API_KEY}}")
idempotencyKey := "unique-idempotency-key"
sc.V2Examples.Create(context.TODO(), &stripe.V2ExampleCreateParams{
Name: stripe.String("My example"),
Params: stripe.Params{
IdempotencyKey: stripe.String(idempotencyKey),
},
})If you’re not using a SDK or the CLI, requests can include the curl https://api.stripe.com/v2/examples \
-H "Authorization: Bearer {{YOUR_API_KEY}}" \
-H "Stripe-Version: {{STRIPE_API_VERSION}}" \-H "Idempotency-Key: unique-idempotency-key" \
-d <JSON request body>Limitations
|
|
curl https://api.stripe.com/v2/examples |
Fixes #1406. Explicitly enables HTTP/2 transport when skipping verification, resolving the fallback to HTTP/1.1.