Skip to content

RasepiHQ/rasepi-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rasepi PHP SDK

Official PHP client library for the Rasepi API — a multilingual-first collaborative documentation platform with forced expiry and plugin architecture.

Packagist License: MIT PHP 8.2+

Installation

composer require rasepihq/rasepi-php

Quick Start

use Rasepi\RasepiClient;

$client = new RasepiClient([
    'base_url' => 'https://your-instance.rasepi.com',
    'access_token' => 'your-access-token',
]);

// List hubs
$hubs = $client->hubs()->list();
foreach ($hubs as $hub) {
    echo "{$hub['name']} ({$hub['key']})\n";
}

// Get an entry
$entry = $client->entries()->get($entryId);
echo $entry['title'];

// Create a new entry
$newEntry = $client->entries()->create([
    'hubKey' => 'engineering',
    'key' => 'getting-started',
    'title' => 'Getting Started Guide',
    'content' => '<p>Hello world</p>',
    'originalLanguage' => 'en',
    'expiryDays' => 90,
]);

Authentication

OAuth 2.0 Flow

$client = new RasepiClient(['base_url' => 'https://your-instance.rasepi.com']);

// Step 1: Get the OAuth login URL
$loginUrl = $client->auth()->getLoginUrl('google', 'https://your-app.com/callback');

// Step 2: After user completes OAuth, exchange the code
$tokens = $client->auth()->exchangeCode($authCode);
// Client automatically stores and uses the tokens

// Tokens are refreshed automatically when expired

Token Refresh

$tokens = $client->auth()->refreshToken($refreshToken);

Development Token

$client = new RasepiClient([
    'base_url' => 'http://localhost:5000',
    'dev_token' => ['tenant_id' => $tenantId, 'user_id' => $userId],
]);

API Reference

Hubs

$client->hubs()->list();
$client->hubs()->get('engineering');
$client->hubs()->create(['key' => 'eng', 'name' => 'Engineering', 'defaultExpiryDays' => 90]);
$client->hubs()->update('engineering', ['name' => 'Engineering Docs']);
$client->hubs()->delete('engineering');
$client->hubs()->transferOwnership('engineering', $newOwnerId);

Entries

$client->entries()->listByHub('engineering');
$client->entries()->get($entryId);
$client->entries()->create([...]);
$client->entries()->update($entryId, ['title' => 'Updated']);
$client->entries()->publish($entryId);
$client->entries()->renew($entryId);
$client->entries()->delete($entryId);

Translations

$client->translations()->list($entryId);
$client->translations()->get($entryId, 'de');
$client->translations()->create($entryId, 'de', ['title' => 'Titel', 'content' => '<p>Inhalt</p>']);
$client->translations()->getStatus($entryId, 'de');
$client->translations()->getStaleBlocks($entryId, 'de');
$client->translations()->markUpToDate($entryId, 'de');

Analytics

$client->analytics()->getSummary($entryId);
$client->analytics()->getEvents($entryId, ['skip' => 0, 'take' => 50]);
$client->analytics()->reportTimeSpent($entryId, 120);

AI & Search

$results = $client->ai()->search(['query' => 'how to deploy', 'mode' => 'hybrid']);
$conversation = $client->ai()->createConversation('My Question');
$response = $client->ai()->sendMessage($conversationId, ['content' => 'How to set up CI/CD?']);

Knowledge Portal

$client->portal()->getFeed();
$client->portal()->getTopics();
$client->portal()->getContent('engineering', 'getting-started', 'en');
$client->portal()->search('deployment guide');

Sharing

$link = $client->sharing()->create('getting-started', ['expiresAt' => '2026-04-14T00:00:00Z']);
$links = $client->sharing()->list('getting-started');
$client->sharing()->revoke('getting-started', $linkId);

Error Handling

use Rasepi\Exceptions\RasepiApiException;

try {
    $hub = $client->hubs()->get('non-existent');
} catch (RasepiApiException $e) {
    echo "Error {$e->getStatusCode()}: {$e->getMessage()}\n";
}

Requirements

  • PHP 8.2+
  • ext-json
  • Guzzle HTTP 7.x

License

MIT — see LICENSE for details.

About

Official PHP client library for the Rasepi API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages