Skip to main content

JavaScript / TypeScript SDK

Use the JavaScript SDK when you want full control from Node.js, Deno, or Bun.

Run the local JavaScript example

Try the SDK against the mock AAP server with AAP_API_KEY=aap_demo_key and fake checkout data.
Install
npm install @rakohq/sdk
quickstart.ts
import { AAP } from '@rakohq/sdk';

const aap = new AAP({ apiKey: 'your-api-key' });

// 1. Search for offers
const { offers, sessionId } = await aap.search({
  vertical: 'sim',
  maxPrice: 10,
  contractMonths: 0,
});

// 2. Recommend an offer (records attribution)
const rec = await aap.recommend({
  sessionId,
  offerId: offers[0].id,
  context: 'User asked for cheap SIM with no contract',
});

// 3. Initiate checkout
const checkout = await aap.checkout({
  sessionId,
  recommendationId: rec.recommendationId,
});

Client

new AAP(config)

OptionTypeRequiredDefault
apiKeystringYes
baseUrlstringNohttps://api.rako.sh

Methods

aap.search(options)

Returns matching offers and a session ID.
OptionTypeDescription
verticalstringsim, broadband, energy, flights, hotels, insurance
providerstringFilter by provider name
maxPricenumberMaximum price
minDataGbnumberMinimum data allowance for SIM offers
contractMonthsnumberContract length, where 0 means rolling

aap.recommend(options)

Record a recommendation. This is the attribution event.
OptionTypeDescription
sessionIdstringSession from search()
offerIdstringOffer to recommend
contextstringWhy this offer was recommended

aap.checkout(options)

Initiate checkout for a recommended offer.
OptionTypeDescription
sessionIdstringSession from search()
recommendationIdstringRecommendation from recommend()
userDetailsobjectOptional user details for checkout

aap.getSession(sessionId)

Get session details including recommendations and conversions.

aap.verifyCode(code)

Verify an AAP Code is authentic.

Mock conversion learning

The runnable SDK example reaches a mock checkout URL. To understand why checkout-link creation is separate from conversion recording, see Mock Conversion Artifact.

npm

GitHub