Skip to content

Official Rewrite API typings that are always up to date

License

Notifications You must be signed in to change notification settings

RewriteToday/types

Rewrite Types

@rewritejs/types, an official TypeScript types for the Rewrite API.

This package provides shared resource models, request/response contracts, and route builders used by Rewrite SDKs and applications. It is designed to keep API integrations strongly typed and consistent across projects.

Installation

You can use this package with your favorite package manager

bun add @rewritejs/types
# Or
npm install @rewritejs/types
# Or
pnpm install @rewritejs/types
# Or
yarn add @rewritejs/types

Using

How we document our types

  • Prefix API* Represents general API structures (returned objects, internal models, etc.).

  • Prefix REST<HTTPMethod>* Types used in direct API requests.

    • Suffix Body → request body payload E.g.: RESTPostCreateTemplateBody

    • Suffix QueryParams → query string parameters E.g.: RESTGetListWebhooksQueryParams

    • Suffix Data → data returned by the API E.g.: RESTGetListWebhooksData

Typing API Responses

import { REST } from '@rewritejs/rest';
import { Routes, type RESTGetProjectData } from '@rewritejs/types/v1';

const rest = new REST(process.env.REWRITE_API_KEY);

// Return type: Promise<RESTGetWebhooksData>
async function fetchWebhooks(projectId: string) {
	const data = await rest.get<RESTGetWebhooksData>(Routes.webhooks.list(projectId));
	
	return data
}

Using Route Builders

import { API_BASE_URL, Routes } from '@rewritejs/types/v1';

const projectId = '123';
const webhookId = '999';

// https://api.rewritetoday.com/v1/projects/123/webhooks/999
const url = `${API_BASE_URL}/v1${Routes.webhooks.get(projectId, webhookId)}`;

Made with 🤍 by the Rewrite team.
SMS the way it should be.

About

Official Rewrite API typings that are always up to date

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published