Bridge API

A simple API client for Bridge LMS

Usage

To create a new client:

client = BridgeAPI::Client.new(token: "your bridge api token", prefix: "https://yourdomain.bridgeapp.com")

-or-

client = BridgeAPI::Client.new(api_key: "your bridge api key", api_secret:
"your bridge api secret", prefix: "https://yourdomain.bridgeapp.com")

Additional options

Rate Limiting

If you are using BridgeAPI in a multi-threaded environment where you are instantiating several instances of client, you can also supply your client initializer with master_rate_limit: true. This will use a redis keystore to track your rate limits across all instances of client and properly throttle your application as needed.

Token Pools

This supports token pooling to get around rate limiting issues in bridge (but should never be used without Core approval) To use with Tokens:

client = BridgeAPI::Client.new(tokens: ['token1', 'token2'], prefix: "https://yourdomain.bridgeapp.com")

To use with API Keys:

client = BridgeAPI::Client.new(api_keys: {'key1' => 'secret1', 'key2' => 'secret2'}, prefix: "https://yourdomain.bridgeapp.com")

The logic will start with the first token provided, and check against the redis cache to see what its current limit is. If its already under the limit threshold, it will rotate to the next in the pool, and perform the same check. It will do this till it finds one that is not under the threshold, and use it. If none are found, it will sleep for the configured time, and then try to make a call.