Skip to content

celluloid-camp/peertube-api

Repository files navigation

@celluloid/peertube-api

A TypeScript client library for the PeerTube REST API, generated from the official OpenAPI specification. This package provides a fully type-safe fetch client for interacting with PeerTube instances.

Features

  • Fully Type-Safe: Complete TypeScript types generated from the PeerTube OpenAPI specification
  • Fetch API: Uses the native Fetch API for HTTP requests
  • Modern: Built with modern TypeScript and ES modules
  • Comprehensive: Supports all PeerTube API endpoints

Installation

pnpm add @celluloid/peertube-api

Or with npm:

npm install @celluloid/peertube-api

Usage

Basic Example

import { createClient } from '@celluloid/peertube-api/client';
import { getVideos } from '@celluloid/peertube-api';

const client = createClient({
  baseUrl: 'https://peertube.example.com',
});

const response = await getVideos({
  client,
  query: {
    start: 0,
    count: 10,
  },
});

console.log(response.data);

With Authentication

import { createClient } from '@celluloid/peertube-api/client';
import { getUserInfo } from '@celluloid/peertube-api';

const client = createClient({
  baseUrl: 'https://peertube.example.com',
  headers: {
    Authorization: 'Bearer YOUR_ACCESS_TOKEN',
  },
});

const userInfo = await getUserInfo({ client });
console.log(userInfo.data);

Custom Configuration

import { createClient } from '@celluloid/peertube-api/client';

const client = createClient({
  baseUrl: 'https://peertube.example.com',
  headers: {
    'User-Agent': 'MyApp/1.0',
  },
  fetch: customFetch,
});

client.setConfig({
  baseUrl: 'https://another-instance.com',
});

API Reference

The client is generated from the PeerTube OpenAPI specification (v8.0.0). All API endpoints are available through the SDK functions exported from @celluloid/peertube-api/client/sdk.

For detailed API documentation, see the PeerTube REST API Reference.

Development

Prerequisites

  • Node.js (v18 or higher)
  • pnpm (v9 or higher)

Setup

  1. Clone the repository
  2. Install dependencies:
pnpm install

Generate Client

pnpm run generate

Build

pnpm run build

Type Checking

pnpm run typecheck

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors