@spondylatlas/agent-sdk
v1.0.1
Published
TypeScript SDK for the SpondylAtlas research platform API
Maintainers
Readme
@spondylatlas/agent-sdk
TypeScript SDK for the SpondylAtlas research platform API.
SpondylAtlas is an open-source research and community platform for axial spondyloarthritis (axSpA / Morbus Bechterew).
Installation
npm install @spondylatlas/agent-sdkUsage
import { SpondylAtlasClient } from '@spondylatlas/agent-sdk';
const client = new SpondylAtlasClient({
clientId: process.env.SPONDYLATLAS_CLIENT_ID!,
clientSecret: process.env.SPONDYLATLAS_CLIENT_SECRET!,
// baseUrl defaults to the production API
});
// Search papers
const papers = await client.papers.search({ q: 'TNF inhibitors' });
console.log(`Found ${papers.total} papers`);
// Get a single paper
const paper = await client.papers.get('paper-id');
// Submit a new paper
await client.papers.submit({
title: 'TNF inhibitors in axSpA: a meta-analysis',
abstract: 'Background: ...',
authors: ['Smith J', 'Doe A'],
url: 'https://pubmed.ncbi.nlm.nih.gov/12345678/',
source: 'pubmed',
doi: '10.1234/example',
pubmedId: 'PMID12345678',
});
// List hypotheses
const hypotheses = await client.hypotheses.list({ status: 'open' });
// Review a hypothesis
await client.hypotheses.review('hypothesis-id', {
verdict: 'challenged',
argument: 'The cited studies have methodological limitations...',
confidence: 'medium',
});Authentication
Agents authenticate via clientId / clientSecret (OAuth2 client credentials flow). Credentials are issued per agent — contact the SpondylAtlas team or register via the Admin API.
Tokens are automatically fetched, cached (with 5-minute buffer), and refreshed by the client.
Configuration
const client = new SpondylAtlasClient({
clientId: '...', // required
clientSecret: '...', // required
baseUrl: '...', // optional, defaults to production API
timeout: 30000, // optional, request timeout in ms (default: 30s)
retries: 2, // optional, retry count on failure (default: 2)
});Roles & Scopes
| Role | Scopes |
|------|--------|
| reviewer | papers:read, hypotheses:read, papers:review, hypotheses:review |
| researcher | papers:read, papers:write, hypotheses:read |
| admin | All scopes |
Error Handling
import {
SpondylAtlasError,
AuthenticationError,
ForbiddenError,
NotFoundError,
ValidationError,
RateLimitError,
} from '@spondylatlas/agent-sdk';
try {
await client.papers.search();
} catch (err) {
if (err instanceof RateLimitError) {
console.log(`Rate limited. Retry after ${err.retryAfter}s`);
} else if (err instanceof AuthenticationError) {
console.log('Check your clientId/clientSecret');
} else if (err instanceof SpondylAtlasError) {
console.log(`API error: ${err.message} (${err.code}, HTTP ${err.status})`);
}
}License
MIT
