Rate Limiting
Each account has a built-in rate limiter and may optionally use queues to streamline the handling of peak sales. These rate limiters are also applicable to the API: order creation (and ticket assignment) is limited globally for an account, so a high demand on the web sales pages will also impact the available capacity on the API (and vice-versa).
This rate limiting can manifest itself when creating orders or when adding tickets to an order: a response status of 429 Rate Limit Exceeded
will be returned.
The rate limiter works with 2 time intervals: per minute and per 5-second interval. The allowed rate per 5-second interval is equal to the rate per minute / 3. So for example: if the rate limit per minute is 60, the rate limit per 5 seconds is 20.
Rate limiting in libraries
Go
A rate limited call will return a RateLimitError
. This error has a Backoff
field which contains the number of seconds to wait before making a new request.
1_, err = orders.Create(c, &ticketmatic.CreateOrder{
2 Events: []int64{
3 777714,
4 },
5 Saleschannelid: 1,
6})
7if err != nil {
8 if e, ok := err.(*ticketmatic.RateLimitError); ok {
9 // Do something useful with e:
10 return fmt.Errorf("Need to sleep for %d seconds\n", e.Backoff)
11 } else {
12 return err
13 }
14}
PHP
A rate limited call will throw a RateLimitException
. This exception has a backoff
field which contains the number of seconds to wait before making a new request.
1try {
2 $order = Orders::create($client, array(
3 "events" => array(
4 777714,
5 ),
6 "saleschannelid" => 1,
7 ));
8} catch (RateLimitException $ex) {
9 $backoff = $ex->backoff;
10 // Sleep for $backoff seconds before retrying.
11}