Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sprinkle-sdk

TypeScript SDK for the Sprinkle developer cloud platform.

Includes a fully typed React Query client, Zod validation schemas, and the OpenAPI spec that drives them both.

Packages

Package Description
@sprinkle/client React Query hooks and typed fetch client
@sprinkle/zod Zod schemas generated from the OpenAPI spec
@sprinkle/spec OpenAPI 3.1 specification and codegen config

Installation

# React projects
pnpm add @sprinkle/client @tanstack/react-query

# Validation only
pnpm add @sprinkle/zod zod

Quick start

import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { useGetProjects, useCreateApiKey } from '@sprinkle/client';

const client = new QueryClient();

function App() {
  return (
    <QueryClientProvider client={client}>
      <Dashboard />
    </QueryClientProvider>
  );
}

function Dashboard() {
  const { data: projects } = useGetProjects();
  return <pre>{JSON.stringify(projects, null, 2)}</pre>;
}

Configuration

Set your API base URL and key before using the client:

import { setBaseUrl, setApiKey } from '@sprinkle/client';

setBaseUrl('https://api.sprinkle.network');
setApiKey('sk_live_...');

Codegen

The client and Zod schemas are generated from the OpenAPI spec using Orval.

cd packages/spec
pnpm codegen   # Regenerate client and schemas from openapi.yaml

Development

pnpm install
pnpm build       # Build all packages
pnpm typecheck   # Type-check all packages

Contributing

See CONTRIBUTING.md.

License

MIT. See LICENSE.

About

TypeScript SDK, React Query client, and Zod schemas for the Sprinkle API

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages