Silgi
Integrations

OpenAPI Client

Consume any OpenAPI endpoint as a typed Silgi client.

Use OpenAPILink to consume any OpenAPI-described API through the Silgi client interface. Bring your own spec — Silgi maps operations to procedure calls.

Setup

import {  } from 'silgi/client/openapi'
import {  } from 'silgi/client'
import type {  } from './petstore.types' // generated types

const  = <>({
  : [
    new ({
      : 'https://petstore.example.com',
      : import('./petstore.json'),
    }),
  ],
})

const  = await .pets.list()
const  = await .pets.get({ : '1' })

Inline spec

Pass the spec object directly if you already have it:

import  from './petstore.json'

new OpenAPILink({
  : 'https://petstore.example.com',
  ,
})

Custom headers

new OpenAPILink({
  : 'https://api.example.com',
  : import('./spec.json'),
  : () => ({
    : `Bearer ${getToken()}`,
  }),
})

What's next?

On this page