@ossy/sdk
v0.15.13
Published
Sofware Development Kit for interacting with our services
Readme
@ossy/sdk
API client for Ossy services. Use with @ossy/sdk-react for React hooks.
Installation
npm install @ossy/sdk @ossy/sdk-reactQuick start
import { SDK } from '@ossy/sdk'
const sdk = SDK.of({
workspaceId: 'your-workspace-id',
apiUrl: 'https://api.ossy.se/api/v0', // optional, this is the default
})
// List resources in a folder
const resources = await sdk.resources.list({ location: '/docs' })
// Get a single resource
const resource = await sdk.resources.get({ id: 'resource-id' })Configuration
| Option | Description |
|--------|-------------|
| workspaceId | Your workspace identifier (required for most operations) |
| apiUrl | API base URL (default: https://api.ossy.se/api/v0) |
| authorization | Bearer token for authenticated requests |
API overview
Workspaces
sdk.workspaces.current()— Get current workspacesdk.workspaces.list()— List workspacessdk.workspaces.get({ workspaceId })— Get workspace by IDsdk.workspaces.create(payload)— Create workspacesdk.workspaces.importResourceTemplates(...)— Import resource templatessdk.workspaces.getResourceTemplates(...)— Get resource templates
Resources
sdk.resources.list({ location })— List resources in foldersdk.resources.get({ id })— Get resource by IDsdk.resources.create(payload)— Create resourcesdk.resources.search(query)— Search resourcessdk.resources.remove({ id })— Delete resourcesdk.resources.updateContent(...)— Update resource contentsdk.resources.move(...)— Move resourcesdk.resources.rename(...)— Rename resourcesdk.resources.upload({ location, file })— Upload file
Auth
sdk.auth.signIn(payload)— Sign insdk.auth.signOff()— Sign offsdk.auth.getAuthenticatedUser()— Get current user
Current user
sdk.currentUser.get()— Get current usersdk.currentUser.update(payload)— Update usersdk.currentUser.history()— Get user history
With React
Use @ossy/sdk-react for React hooks (useResource, useResources) and wrap your app in WorkspaceProvider:
import { SDK } from '@ossy/sdk'
import { WorkspaceProvider } from '@ossy/sdk-react'
const sdk = SDK.of({ workspaceId: 'your-workspace-id' })
export const App = () => (
<WorkspaceProvider sdk={sdk}>
<YourApp />
</WorkspaceProvider>
)See @ossy/sdk-react README for hook usage.
