Command line and SDK
The rivier command and the TypeScript client, both generated from the same operation list.
Command shape
A command is the words of an operation: area, thing, action. Path and query values are flags. --body takes JSON, @file or - for standard input. rivier ops lists every command, and a word after it filters the list. --help on any command shows the route it calls and the level it needs.
rivier ops invoice
rivier contacts contact list
rivier keys key list --helpEnvironment
- RIVIER_API_KEY
- The key or token to call with. Also --key.
- RIVIER_API_URL
- The API address. The default is https://api.rivier.ai. Also --url.
- RIVIER_ORG_ID
- The organisation for organisation commands, so it need not be repeated. Also --orgId.
Exit codes
0 is success. 1 is a server or network failure. 2 is a usage error: an unknown command, a missing value or a body that is not JSON. 3 means the API refused the call; the code and its explanation are printed. Reads wait and retry when the rate limit asks them to.
TypeScript client
The client has one method per operation, named with the same words as the command, and no dependencies. A refusal throws RivierError with status, message and body. Reads retry on 429 after the wait the API names.
import { createClient, RivierError } from "@rivier/sdk";
const rivier = createClient({
baseUrl: "https://api.rivier.ai",
apiKey: process.env.RIVIER_API_KEY,
});
try {
const contacts = await rivier.contacts.contact.list();
console.log(contacts);
} catch (err) {
if (err instanceof RivierError) console.error(err.status, err.message);
else throw err;
}Getting the package
The command and the client ship together as @rivier/sdk. The package is not on the public npm registry yet. Until it is, every command has the same REST call beside it in the API reference, and both do exactly the same thing.