Get started
The gater API provides endpoints for managing entitlements, including operations for setting/resetting, incrementing usage, and checks.
Try gater locally using the e6r emulator
The fastest (and free) way to try out gater is through its emulated e6r environment. To get started please run e6r in Docker:
docker run -p 3612:3612 @e6rdev/e6r # access gater at http://localhost:3612/m/gater
1. Set the entitlement
Use the /set
endpoint to configure how the user entitlement behaves.
const gater = axios.create({
baseURL: "http://localhost:3612/m/gater", // prod: https://api.gater.dev :P
headers: {
"X-Api-Key": process.env.GATER_SECRET,
"Content-Type": "application/json",
},
});
// set entitlement, e.g. user = 'uid', feature = 'app_tokens', quota = 1000;
await gater.post("/set", { user, feature, quota });
Note: this will automatically set a namespace for any user or feature behind the scenes.
2. Check Entitlement
Use the /check
endpoint to see the current status of the user's entitlement.
// check entitlement: ✅ { ok: true, usage: 0 }
await gater.get("/check", { params: { user, feature } });
3. Increment Entitlement
Whenever you want to increment the metered usage for this entitlement call /increment
// increment usage, e.g. amount = quota + 1;
await gater.post(`/increment`, { user, feature, amount });
// check again: ❌ { ok: false, usage: 1001 }
await gater.get("/check", { params: { user, feature } });