Riven exposes a type-safe GraphQL API built with Apollo Server,Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rivenmedia/riven-ts/llms.txt
Use this file to discover all available pages before exploring further.
type-graphql, and Express 5. It is the primary interface for external tools and media servers to query library state, inspect the virtual file system, and trigger actions such as resetting a media item or sharing diagnostic logs. The API is ready after the Bootstrap machine’s Initialising services state completes.
Endpoint and Configuration
The API defaults tohttp://localhost:3000/graphql. Both host and port are configurable:
| Setting | Default | Description |
|---|---|---|
gqlHost | localhost | Hostname the Express server binds to |
gqlPort | 3000 | Port the server listens on |
Authentication Context
Every resolver receives a typed context object. The core context interface extendsGraphQLContext from the plugin SDK:
@CoreContext() parameter decorator, which unpacks the CoreKey-namespaced fields:
Queries
mediaItemById(id: ID!): MediaItemUnion
mediaItemById(id: ID!): MediaItemUnion
Fetches a media item by its UUID. The return type is a GraphQL union
(
Movie | Show | Season | Episode) — the concrete type is determined by the
underlying entity discriminator.mediaItems: [MediaItem!]!
mediaItems: [MediaItem!]!
Lists up to 25 media items from the library. Returns the base
MediaItem
type — use mediaItemById with inline fragments for type-specific fields.This query is limited to 25 results and is intended for administrative
overview rather than bulk export. Use the database directly for large
result sets.
episode(tvdbId, episodeNumber, seasonNumber): Episode
episode(tvdbId, episodeNumber, seasonNumber): Episode
Fetches a specific episode by its TVDB series ID and episode number. When
seasonNumber is omitted, lookup uses absolute episode numbering (useful
for anime titles that use a single continuous count).vfsEntryStat(path: String!): VfsEntryStat
vfsEntryStat(path: String!): VfsEntryStat
Returns FUSE-level file statistics for the given VFS path — equivalent to
calling
stat() on the virtual mount. The size field is a BigInt.vfsEntry(path: String!): FileSystemEntryUnion
vfsEntry(path: String!): FileSystemEntryUnion
Returns the VFS entry at the given path as a union of
MediaEntry or
SubtitleEntry. Returns null if no entry exists at that path.vfsDirectoryEntryPaths(path: String!): [String!]!
vfsDirectoryEntryPaths(path: String!): [String!]!
Lists the paths of all entries under a VFS directory. Useful for
programmatically enumerating the virtual file tree without mounting it
locally.
Mutations
removeItemRequest(id: ID!): Boolean!
removeItemRequest(id: ID!): Boolean!
Removes an item request and all its associated media items from the library.
Also clears any pending BullMQ deduplication jobs for the item so the queue
does not attempt to process it after deletion.Returns Internally this calls
true on success, false if an error occurred (check the server
logs for details).clearDeduplicationJob on both the
process-item-request and process-media-item queues before removing the
database record, then emits riven.item-request.removed into the event bus.resetMediaItem(id: ID!): [MediaItemUnion!]!
resetMediaItem(id: ID!): [MediaItemUnion!]!
Resets a media item (and, for shows, all its child seasons and episodes)
back to a clean state so that the full pipeline can be re-run. Returns the
list of items that were reset.
saveStreamUrl(id: ID!, url: String!): MediaEntry!
saveStreamUrl(id: ID!, url: String!): MediaEntry!
Saves a stream permalink directly on a
MediaEntry, bypassing the normal
debrid acquisition flow. Useful for manually pinning a known-good stream URL
or for recovery when the automatic stream link request has failed.Returns the updated MediaEntry.shareLogs: String!
shareLogs: String!
Resolver Architecture
All resolver classes are registered at startup inapps/riven/lib/graphql/resolvers/index.ts:
type-graphql resolver classes in their manifest. These are merged into the Apollo schema alongside the core resolvers during the startGqlServer bootstrap actor.
Type Safety
All resolvers use
type-graphql decorators, so the schema is derived
directly from TypeScript types. @Arg, @Query, @Mutation, and
@FieldResolver decorators are the single source of truth — no separate
.graphql schema files.Per-Request Entity Manager
The
buildContextFunction forks a new MikroORM EntityManager for every
GraphQL request (database.em.fork()), giving each request its own
identity map and preventing cross-request entity leakage.