The operations type from your OpenAPI specification
Debug utility to inspect operation metadata at runtime.
This method helps during development to understand how operations are classified and can be useful for debugging type inference issues.
Creates a reactive query for GET/HEAD/OPTIONS operations.
This method creates a TanStack Query with automatic type inference, caching, and reactive updates. Only accepts operation IDs that correspond to query operations.
The operation key from your operations type
Operation ID (must be a GET/HEAD/OPTIONS operation)
OptionalpathParamsOrOptions: GetPathParameters<Ops, Op> extends Record<string, never>Path parameters (for parameterized routes) or query options
OptionaloptionsOrNull: QQueryOptions<Ops, Op>Additional query options when path parameters are provided separately
Reactive query result with data, loading state, error handling, etc.
// Simple query without parameters
const { data: pets, isLoading } = api.useQuery('listPets')
// Query with path parameters
const { data: pet } = api.useQuery('getPet', { petId: '123' })
// Query with options
const { data: pets } = api.useQuery('listPets', {
enabled: computed(() => shouldLoad.value),
onLoad: (data) => console.log('Loaded:', data)
})
Creates a reactive mutation for POST/PUT/PATCH/DELETE operations.
This method creates a TanStack Query mutation with automatic cache invalidation, optimistic updates, and type-safe request/response handling. Only accepts operation IDs that correspond to mutation operations.
The operation key from your operations type
Operation ID (must be a POST/PUT/PATCH/DELETE operation)
OptionalpathParamsOrOptions: GetPathParameters<Ops, Op> extends Record<string, never>Path parameters (for parameterized routes) or mutation options
OptionaloptionsOrNull: QMutationOptions<Ops, Op>Additional mutation options when path parameters are provided separately
Reactive mutation result with mutate, mutateAsync, status, etc.
// Simple mutation without path parameters
const createPet = api.useMutation('createPet', {
onSuccess: (data) => console.log('Created:', data),
onError: (error) => console.error('Failed:', error)
})
// Mutation with path parameters
const updatePet = api.useMutation('updatePet', { petId: '123' })
// Execute mutations
await createPet.mutateAsync({ data: { name: 'Fluffy', species: 'cat' } })
await updatePet.mutateAsync({ data: { name: 'Updated Name' } })
Generic endpoint composable that automatically detects operation type.
This is a universal method that returns either a query or mutation based on the operation's HTTP method. It provides the same functionality as useQuery/useMutation but with automatic type detection, making it useful for generic or dynamic scenarios.
The operation key from your operations type
Any valid operation ID from your API specification
OptionalpathParamsOrOptions: GetPathParameters<Ops, Op> extends Record<string, never>Path parameters (for parameterized routes) or operation-specific options
OptionaloptionsOrNull: IsQueryOperation<Ops, Op> extends trueAdditional options when path parameters are provided separately
Query result for GET/HEAD/OPTIONS operations, mutation result for others
// Automatically becomes a query for GET operations
const listEndpoint = api.useEndpoint('listPets')
// TypeScript infers this has query properties: .data, .isLoading, .refetch(), etc.
// Automatically becomes a mutation for POST operations
const createEndpoint = api.useEndpoint('createPet')
// TypeScript infers this has mutation properties: .mutate(), .mutateAsync(), etc.
// Use based on the detected type
const petData = listEndpoint.data // Query data
await createEndpoint.mutateAsync({ data: { name: 'Fluffy' } }) // Mutation execution
Type representing an instance of the OpenAPI client returned by useOpenApi.
This interface defines all the methods available on the API client instance, providing type-safe access to queries, mutations, and generic endpoints based on your OpenAPI specification.
Template: AxiosConfig
The axios request configuration type (defaults to AxiosRequestConfig)
Example