DEV Community

Cover image for Building with Fractal Bitcoin: OKX OS Integration Guide
Julian Martinez
Julian Martinez

Posted on

Building with Fractal Bitcoin: OKX OS Integration Guide

πŸ“Œ This guide covers everything you need to integrate OKX OS Fractal Bitcoin APIs into your applications

πŸ”— Essential Links

πŸ“š API Documentation

API Purpose Link
Collections Get Ordinals collection list Docs
Activities Get trade history Docs
Inscriptions Get valid inscriptions Docs

πŸ› οΈ API Endpoints

Implementation Note: These endpoints are implemented in ordinals-server.cjs, which handles request signing and authentication with the OKX API. The server acts as a proxy, adding necessary headers and signatures before forwarding requests to OKX's endpoints.

1. Get Ordinals Collections

Endpoint:

GET /api/ordinals
Enter fullscreen mode Exit fullscreen mode

Properties:

{
    "limit": "20",      // default: 20
    "slug": "string",   // optional
    "isBrc20": false    // default: false
}
Enter fullscreen mode Exit fullscreen mode

OKX Endpoint: /api/v5/mktplace/nft/fractal-ordinals/collections

2. Get Valid Inscriptions

Endpoint:

POST /api/inscriptions
Enter fullscreen mode Exit fullscreen mode

Request Body:

{
    "slug": "string",
    "walletAddress": "string",
    "limit": "10",         // default: 10
    "isBrc20": false,      // optional
    "cursor": "string",    // optional
    "sort": "string"       // optional
}
Enter fullscreen mode Exit fullscreen mode

OKX Endpoint: /api/v5/mktplace/nft/fractal-ordinals/get-valid-inscriptions

3. Get Trade History

Endpoint:

POST /api/trade-history
Enter fullscreen mode Exit fullscreen mode

Request Body:

{
    "slug": "string",
    "limit": "10",                    // default: 10
    "sort": "desc",                   // default: desc
    "isBrc20": true,                  // default: true
    "cursor": "string",               // optional
    "tradeWalletAddress": "string",   // optional
    "type": "string",                 // optional
    "orderSource": "string"           // optional
}
Enter fullscreen mode Exit fullscreen mode

OKX Endpoint: /api/v5/mktplace/nft/fractal-ordinals/trade-history

πŸ’» Technical Stack

  • Frontend: React + TypeScript
  • Backend: Express.js
  • Security Features:
    • CORS enabled
    • CryptoJS for signing
    • Environment variables
  • API: Axios
  • Error Handling: Full logging

πŸš€ Getting Started

Prerequisites

Setup Steps

1.Clone repository

git clone https://github.com/Julian-dev28/ordinals-react-app-ts.git
Enter fullscreen mode Exit fullscreen mode

2.Configure environment

OKX_API_KEY=
OKX_API_SECRET=
OKX_API_PASSPHRASE=
Enter fullscreen mode Exit fullscreen mode

3.Install dependencies

npm install
Enter fullscreen mode Exit fullscreen mode

4.Start the proxy server

node ordinals-server.cjs
Enter fullscreen mode Exit fullscreen mode

5.Run the app

npm run dev
Enter fullscreen mode Exit fullscreen mode

πŸ“ Project Structure

./
β”œβ”€β”€ ordinals-server.cjs      # Proxy API service
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/         
β”‚   β”‚   β”œβ”€β”€ OrdinalsFetcher.tsx
β”‚   β”‚   β”œβ”€β”€ RetrieveInscriptions.tsx
β”‚   β”‚   └── TradeHistory.ts
β”‚   └── services/
β”‚       └── okxServices.ts
Enter fullscreen mode Exit fullscreen mode

🀝 Support & Community

πŸ“ Contributing Guidelines

  1. Fork repository
  2. Create feature branch
  3. Submit pull request

⚑ Quick Tips

  • Use environment variables for security
  • Check API response codes
  • Monitor console messages

Top comments (0)