Skip to content

TypeScript SDK

The @rfp-hub/sdk package provides a typed TypeScript client for the RFP Hub API. It uses the native fetch API with zero external dependencies.

Installation

The SDK is a workspace package within the rfp-hub monorepo. It is not yet published to npm.

# Within the monorepo, it's available via npm workspaces:
# No install needed — just import it
import { RfpHubClient } from '@rfp-hub/sdk';

npm publish is planned for a future release.

Quick Start

import { RfpHubClient } from '@rfp-hub/sdk';
 
const client = new RfpHubClient({
  baseUrl: 'https://rfp-hub-api.fly.dev',
});
 
const { data, meta } = await client.searchOpportunities({
  q: 'privacy',
  ecosystem: 'ethereum',
});
 
console.log(`Found ${meta.total} opportunities`);

Constructor

new RfpHubClient(options: ClientOptions)
OptionTypeRequiredDescription
baseUrlstringYesAPI base URL (e.g., https://rfp-hub-api.fly.dev)
apiKeystringNoAPI key for authenticated endpoints (sent as X-API-Key header)

Methods

searchOpportunities(params?)

Search and list funding opportunities.

searchOpportunities(
  params?: Partial<SearchOpportunities>
): Promise<PaginatedResponse<FundingOpportunity>>

Parameters — all optional:

ParamTypeDescription
qstringFull-text search query
typestringFilter by rfpType
statusstringFilter by status
ecosystemstringFilter by ecosystem
funderstringFilter by source slug
categorystringFilter by category
tagstringFilter by tag
min_budgetnumberMinimum budget
max_budgetnumberMaximum budget
closing_afterDateOnly closing after this date
closing_beforeDateOnly closing before this date
sortstringSort field
(default: created_at:desc)
pagenumberPage number (default: 1)
limitnumberResults per page (default: 20, max: 100)
cursorstringCursor for keyset pagination

Returns: { data: FundingOpportunity[], meta: { total, page, limit, hasMore } }


getOpportunity(id)

Get a single opportunity by ID.

getOpportunity(id: string): Promise<FundingOpportunity>

Throws on 404.


createOpportunity(data)

Create a new opportunity. Requires API key.

createOpportunity(data: CreateOpportunity): Promise<FundingOpportunity>

updateOpportunity(id, data)

Update an existing opportunity. Requires API key.

updateOpportunity(id: string, data: UpdateOpportunity): Promise<FundingOpportunity>

Partial update — only include fields you want to change.


listSources()

List all active funding sources.

listSources(): Promise<{ data: FundingSource[] }>

getSource(id)

Get a single funding source by ID.

getSource(id: string): Promise<FundingSource>

submitOpportunity(data)

Submit a community opportunity for review. No API key needed.

submitOpportunity(data: CreateSubmission): Promise<{
  message: string;
  submissionId: string;
}>

Error Handling

All methods throw on non-2xx responses:

try {
  const opp = await client.getOpportunity('invalid-id');
} catch (err) {
  // Error: RFP Hub API error 404: {"error":"Opportunity not found"}
  console.error(err.message);
}

Types

All types are re-exported from @rfp-hub/schema:

import type {
  FundingOpportunity,
  FundingSource,
  SearchOpportunities,
  CreateOpportunity,
  UpdateOpportunity,
  CreateSubmission,
} from '@rfp-hub/schema';