Skip to main content
Version: 0.9.1

Handle Rate-limits

To avoid excessive overload of our API we limit the rate at which we process your requests. This means your program may from time to time run into a rate limit. To let you gracefully handle retries by waiting until a rate limit resets, we expose the deadline and a done channel much like Go's network context does. Here's how you may use this feature:

var acc *tzpro.Account
for {
var err error
acc, err = tzpro.GetAccount(ctx, tezos.MustParseAddress("tz1irJKkXS2DBWkU1NnmFQx1c1L7pbGg4yhk"))
if err != nil {
if e, ok := tzpro.IsRateLimited(err); ok {
fmt.Printf("Rate limited, waiting for %s\n", e.Deadline())
select {
case <-ctx.Done():
// wait until external context is canceled
err = ctx.Err()
case <-e.Done():
// wait until rate limit reset and retry
continue
}
}
}
break
}

// handle error and/or result here