Skip to main content

Crate dtrpg_sdk

Crate dtrpg_sdk 

Source
Expand description

§DriveThruRPG SDK

A Rust SDK for interacting with the DriveThruRPG API.

§Overview

This crate provides types and structures for authenticating with, configuring, and making requests to the DriveThruRPG API. It covers:

  • Configuration — supplying your application key, API base URL, and API version via Config.
  • Authentication — representing token responses, active sessions, and session state via AuthTokenResponse, AuthSession, and AuthState.
  • Error handling — structured errors for SDK-level, session-level, and HTTP failures via SdkError, AuthSessionError, and ClientError.
  • SDK entry pointDriveThruRpgSdk ties configuration and session lifecycle together and vends a LibraryClient once authenticated.
  • Library accessLibraryClient provides an async HTTP client for all library endpoints (ordered products, product lists, download preparation).
  • Library types — Rust model types for every API-defined library schema, such as OrderProductItem, ProductListItem, and their supporting structures.

§Quick Start

use dtrpg_sdk::{Config, DriveThruRpgSdk, AuthTokenResponse};

let mut sdk = DriveThruRpgSdk::with_config(Config::new("my-app-key"));

// After receiving an auth response from the API:
let response = AuthTokenResponse::new("jwt-token", "refresh-token", 1_800_000_000);
let session = sdk.apply_auth_response(response).unwrap();
assert_eq!(session.token(), "jwt-token");

// Create an authenticated library client:
let client = sdk.library_client().unwrap();
// client.list_order_products(Default::default()).await ...

Re-exports§

pub use auth::AuthSession;
pub use auth::AuthState;
pub use auth::AuthTokenResponse;
pub use auth::SessionTransition;
pub use config::Config;
pub use error::AuthSessionError;
pub use error::SdkError;
pub use library::ClientError;
pub use library::FileChecksum;
pub use library::IncludedItem;
pub use library::LibraryClient;
pub use library::LibraryItemsParams;
pub use library::OrderProductAttribute;
pub use library::OrderProductAttributes;
pub use library::OrderProductDescription;
pub use library::OrderProductFile;
pub use library::OrderProductFilter;
pub use library::OrderProductHistoryEntry;
pub use library::OrderProductInfo;
pub use library::OrderProductItem;
pub use library::OrderProductItemResponse;
pub use library::OrderProductListResponse;
pub use library::OrderProductOrder;
pub use library::OrderProductPublisher;
pub use library::OrderProductRelationships;
pub use library::PageParams;
pub use library::PaginationMeta;
pub use library::ProductListAttributes;
pub use library::ProductListCollectionResponse;
pub use library::ProductListItem;
pub use library::ProductListItemCreateRequest;
pub use library::ProductListItemCreateResponse;
pub use library::ProductListItemsResponse;
pub use library::PublisherAttributes;
pub use library::PublisherItem;
pub use library::RelationshipData;
pub use library::RelationshipRef;
pub use openapi::OPERATIONS;
pub use openapi::OpenApiOperation;
pub use sdk::DriveThruRpgSdk;

Modules§

auth
Authentication: session types, application-key exchange, and website credential login.
config
SDK configuration types.
error
Error types for the DriveThruRPG SDK.
library
Library domain: request/response model types and the async LibraryClient.
openapi
Build-generated OpenAPI metadata.
sdk
The primary SDK entry point.