Skip to content
oraqle

World GDP

by Oraqle · 1 source · a report every 1 d

Signed by Oraqle from the provider’s APIQuantum-safeSLH-DSA + ed25519
Per call
$0.02
sold in packs
Smallest payment
$0.05
what Oraqle settles on chain
A report every
1 d
from 1 source
Recent reports
Measuring · 1 of 7 days
sent, measured by Oraqle
Calls, 30 d
0

Endpoint

GET /v1/feeds/oraqle/world-gdp-current-usd/latest

Bought a pack on this feed? Your code spends it with one header. Make an API key, then use the first example below.

One call
$0.02, sold in packs
Pack of 10
$0.20, valid 30 days
Pack of 100
$2.00, valid 30 days
History page
5 calls
Pays
7btUBXjJdt…FEB8KAWV

API key

terminal
# For a pack you already bought. Make a key in the dashboard, under API keys.
curl https://oraqle.tech/gw/v1/feeds/oraqle/world-gdp-current-usd/latest \
  -H "Authorization: Bearer <your API key>"

# The calls left in your packs.
curl https://oraqle.tech/gw/v1/packs \
  -H "Authorization: Bearer <your API key>"

HTTP

terminal
# 1. Ask. The answer is 402 with the price, in the PAYMENT-REQUIRED header.
curl -i https://oraqle.tech/gw/v1/feeds/oraqle/world-gdp-current-usd/latest

# 2. Partially sign the USDC transfer it describes (x402 exact on Solana),
#    then ask again. Oraqle's facilitator pays the network fee: no SOL needed.
curl https://oraqle.tech/gw/v1/feeds/oraqle/world-gdp-current-usd/latest \
  -H "PAYMENT-SIGNATURE: <base64 payment payload>"

TypeScript

buy.ts
import {readFileSync} from 'node:fs'
import {Oraqle} from '@oraqle/sdk'

// A keypair file made for this buyer. It holds USDC and needs no SOL to pay.
const secretKey = Uint8Array.from(JSON.parse(readFileSync('buyer.json', 'utf8')))
const oraqle = new Oraqle({gatewayUrl: 'https://oraqle.tech/gw', secretKey, maxSpendUsdc: 5_000_000n})

const report = await oraqle.read('oraqle/world-gdp-current-usd') // pays in USDC, or spends a pack, by itself
report.value      // 0 decimals, a bigint
report.checks     // eleven, all passed: both signatures, the signer and its keys, this feed, decimals, payload, age

TypeScript, with an API key

read.ts
import {Oraqle} from '@oraqle/sdk'

// No wallet on the server: the key spends calls you bought ahead.
const oraqle = new Oraqle({gatewayUrl: 'https://oraqle.tech/gw', apiKey: process.env.ORAQLE_API_KEY})

const report = await oraqle.read('oraqle/world-gdp-current-usd') // one call from your pack, nothing signed
report.value      // 0 decimals, a bigint
report.callsLeft  // what the pack still holds

Solana program (Anchor)

lib.rs
// Cargo.toml: oraqle = { git = "<the Oraqle repository>", features = ["cpi"] }
use anchor_lang::prelude::*;
use oraqle::cpi::accounts::VerifyReport;
use oraqle::program::Oraqle;
use oraqle::state::Report;

declare_id!("<your program id>");

/// World GDP: the Oraqle feed account this program trusts, and no other.
pub const FEED: Pubkey = pubkey!("AAVNYL1RHGpdrgaEDTeY6wGWbCgT1VwE5v5krA9hePHc");

#[program]
pub mod example {
    use super::*;

    /// The transaction carries Oraqle's ed25519 instruction (the report's
    /// signature) immediately before this one.
    pub fn settle(ctx: Context<Settle>, report: Report) -> Result<()> {
        let verified = oraqle::cpi::verify_report(
            CpiContext::new(
                ctx.accounts.oraqle_program.key(),
                VerifyReport {
                    feed: ctx.accounts.feed.to_account_info(),
                    instructions: ctx.accounts.instructions.to_account_info(),
                },
            ),
            report,
            172_800_000, // max age in ms: refuse anything older
        )?
        .get();
        // verified.value is an i128 scaled by 0 decimals;
        // verified.signer and verified.signer_kind say who signed it.
        msg!("value {}", verified.value);
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Settle<'info> {
    /// CHECK: pinned by address here; Oraqle checks its owner and seeds.
    #[account(address = FEED)]
    pub feed: UncheckedAccount<'info>,
    /// CHECK: the instructions sysvar, pinned by address.
    #[account(address = anchor_lang::solana_program::sysvar::instructions::ID)]
    pub instructions: UncheckedAccount<'info>,
    pub oraqle_program: Program<'info, Oraqle>,
}

TypeScript, on chain

settle.ts
import {readFileSync} from 'node:fs'
import {Transaction} from '@solana/web3.js'
import {Oraqle} from '@oraqle/sdk'
import {ed25519Instruction, toProgramReport} from '@oraqle/program'
import {ORAQLE_PROGRAM_ID, reportMessage} from '@oraqle/shared'

// A keypair file made for this buyer. It holds USDC and needs no SOL to pay.
const secretKey = Uint8Array.from(JSON.parse(readFileSync('buyer.json', 'utf8')))
const oraqle = new Oraqle({gatewayUrl: 'https://oraqle.tech/gw', secretKey})
const report = await oraqle.read('oraqle/world-gdp-current-usd')
const {signer, signature} = report.envelope

// Your program's instruction, right after the signature it relies on.
const tx = new Transaction().add(
  ed25519Instruction(signer, reportMessage(ORAQLE_PROGRAM_ID, report.report), signature),
  await yourProgram.methods.settle(toProgramReport(report.report)).accounts({/* feed, instructions, oraqleProgram */}).instruction(),
)

// Or Oraqle's own check, with nothing of yours: the signature, then verify_report.
const check = new Transaction().add(...(await report.verifyReportIxs({maxAgeMs: 172800000})))

Response schema

schema.json
{
  "type": "object",
  "title": "World GDP",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "required": [
    "value",
    "observedAtMs"
  ],
  "properties": {
    "value": {
      "type": "string"
    },
    "observedAtMs": {
      "type": "string"
    }
  }
}