@ardent-africa/sdk
v1.1.0
Published
Typed, read-only client for the Ardent Africa public API (/public/v1).
Maintainers
Readme
@ardent-africa/sdk
A tiny, typed, read-only client for the Ardent Africa public API (/public/v1). Campaigns, petitions, events, jobs, review entities and TrustScore, marketplace listings, blog posts, public profiles, and platform stats. No write access, no PII.
Install
npm install @ardent-africa/sdkWorks in Node 18+ and modern browsers (uses the global fetch).
Usage
import { ArdentClient } from '@ardent-africa/sdk';
// The key is optional (keyless works at a lower rate tier). Create one at
// https://ardent.africa/dashboard/developer
const ardent = new ArdentClient({ apiKey: process.env.ARDENT_API_KEY });
const { data, total } = await ardent.listCampaigns({ limit: 5, category: 'Education' });
const campaign = await ardent.getCampaign('clean-water-for-tamale');
const stats = await ardent.getStats();Methods
listCampaigns · getCampaign · listPetitions · getPetition · listEvents · getEvent ·
listJobs · getJob · listReviewEntities · getReviewEntity · listServices · getService ·
listCategories · listBlog · getBlogPost · getProfile · getStats.
List methods return { data, page, limit, total }.
Errors
Non-2xx responses throw an ArdentApiError with code, message, status, and ref:
import { ArdentApiError } from '@ardent-africa/sdk';
try {
await ardent.getCampaign('does-not-exist');
} catch (err) {
if (err instanceof ArdentApiError && err.code === 'NOT_FOUND') { /* … */ }
}Options
new ArdentClient({
apiKey: 'ardent_pk_…', // optional
baseUrl: 'https://api.ardent.africa/public/v1', // override for staging
fetch: customFetch, // optional fetch impl
});Develop
npm install
npm run typecheck
npm test
npm run build # emits dist/ (ESM + CJS + d.ts)The types mirror the published OpenAPI contract; the API is additive within v1, so treat response objects as open.
License
MIT
