----++ ----++ ---+++
---+++ ---++ ---++
----+--- ----- --------- --------++ ------ ----- ----++-----
---------+ --------++----------++--------+++--------+ --------++---++---++++
---+++---++ ++++---++---+++---++---+++---++---+++---++---++---++------++++
----++ ---++--------++---++----++---++ ---++---++ ---+---++ -------++
----+----+---+++---++---++----++---++----++---++---+++--++ --------+---++
---------++--------+++--------+++--------++ -------+++ -------++---++----++
+++++++++ +++++++++- +++---++ ++++++++ ++++++ ++++++ ++++ ++++
--------+++
+++++++
The official Java SDK for the Bagdock API — manage facilities, contacts, tenancies, invoices, marketplace listings, and loyalty programs using the JDK 17+ HttpClient.
Maven:
<dependency>
<groupId>com.bagdock</groupId>
<artifactId>bagdock-java</artifactId>
<version>0.1.0</version>
</dependency>Gradle:
implementation 'com.bagdock:bagdock-java:0.1.0'import com.bagdock.sdk.Bagdock;
import java.util.Map;
var client = new Bagdock(System.getenv("BAGDOCK_API_KEY"));
// List operator facilities
var facilities = client.operator().listFacilities();
// Create a contact
var contact = client.operator().createContact(Map.of(
"email", "jane@example.com",
"first_name", "Jane",
"last_name", "Doe"
));
// Search marketplace
var results = client.marketplace().search();| Method | Description |
|---|---|
listFacilities() |
List facilities |
getFacility(id) |
Get a facility |
listContacts() |
List contacts |
createContact(data) |
Create a contact |
listListings() |
List listings |
listTenancies() |
List tenancies |
listUnits() |
List units |
listInvoices() |
List invoices |
| Method | Description |
|---|---|
search() |
Search marketplace locations |
getListing(id) |
Get a listing |
createRental(data) |
Create a rental |
getRental(id) |
Get a rental |
| Method | Description |
|---|---|
listMembers() |
List loyalty members |
getMember(id) |
Get a member |
awardPoints(data) |
Award points |
listRewards() |
List rewards |
import com.bagdock.sdk.BagdockApiException;
try {
client.operator().getFacility("fac_nonexistent");
} catch (BagdockApiException e) {
System.err.printf("API error %d: %s%n", e.getStatusCode(), e.getErrorCode());
}The SDK supports three authentication modes: API keys, OAuth access tokens, and OAuth2 client credentials.
Bagdock bagdock = new Bagdock(System.getenv("BAGDOCK_API_KEY"));Bagdock bagdock = Bagdock.withAccessToken("eyJhbGciOiJSUzI1NiIs...");Bagdock bagdock = Bagdock.withClientCredentials(
"oac_your_client_id",
"bdok_secret_your_secret",
new String[]{"facilities:read", "contacts:read"}
);Use OAuthHelper for authorization code (PKCE), token exchange, and device flow. These primitives pair well with Bagdock connect webviews for external integrations such as access control, security, and insurance.
import com.bagdock.sdk.oauth.OAuthHelper;
import java.util.Map;
OAuthHelper.PKCEPair pkce = OAuthHelper.generatePKCE();
String url = OAuthHelper.buildAuthorizeUrl("oac_...", "https://your-app.com/callback", pkce.codeChallenge, "openid contacts:read", null, null);
Map<String, Object> tokens = OAuthHelper.exchangeCode("oac_...", code, redirectUri, pkce.codeVerifier, null, null);
Map<String, Object> device = OAuthHelper.deviceAuthorize("bagdock-cli", "developer:read", null);
System.out.printf("Open %s and enter: %s%n", device.get("verification_uri"), device.get("user_code"));
Map<String, Object> deviceTokens = OAuthHelper.pollDeviceToken("bagdock-cli", (String) device.get("device_code"), 5, 600, null);| Option | Type | Default | Description |
|---|---|---|---|
apiKey |
String |
— | API key via new Bagdock(apiKey) (overload with baseUrl) |
accessToken |
String |
— | OAuth bearer token via Bagdock.withAccessToken(accessToken) |
clientId / clientSecret / scopes |
String / String / String[] |
— | Client-credentials flow via Bagdock.withClientCredentials(...); optional issuer and baseUrl overload |
baseUrl |
String |
https://api.bagdock.com/api/v1 |
API base URL |
MIT — see LICENSE