Skip to content

raphjaph/ordapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

30038ea · Feb 13, 2025

History

24 Commits
Feb 4, 2025
Feb 13, 2025
Feb 10, 2025
Feb 6, 2025
Jan 28, 2025
Feb 13, 2025
Feb 4, 2025
Feb 6, 2025
Feb 13, 2025
Jan 28, 2025
Feb 12, 2025
Feb 13, 2025
Jan 31, 2025

Repository files navigation

Ord API

Simple TypeScript client for ord API. See the docs.

npm version npm downloads License CI Status

Installation

Using npm:

$ npm install ordapi

Using yarn:

$ yarn add ordapi

Using pnpm:

$ pnpm add ordapi

Using bun:

$ bun add ordapi

Import

Import the client and types depending on your needs:

// Using default import
import OrdClient from 'ordapi';

const client = new OrdClient('https://ord-server.com');
const block = await client.getBlock(0);
// Using both client and types
import OrdClient, { Inscription } from 'ordapi';

async function getInscription(id: string): Promise<Inscription> {
  const client = new OrdClient('https://ord-server.com');
  return await client.getInscription(id);
}

Usage

import OrdClient, { Block } from 'ordapi';

function App() {
  const [blockInfo, setBlockInfo] = useState<Block | null>(null);

  useEffect(() => {
    // Create client instance
    const client = new OrdClient('https://ord-server.xyz');

    // Fetch genesis block info
    async function fetchBlock() {
      try {
        const block = await client.getBlock(0);
        setBlockInfo(block);
      } catch (err) {
        console.error('Failed to fetch block:', err);
      }
    }

    fetchBlock();
  }, []);

  return (
    <div>
      <h1>Genesis Block</h1>
      {blockInfo && (
        <>
          <p>Height: {blockInfo.height}</p>
          <p>Hash: {blockInfo.hash}</p>
          <p>Number of transactions: {blockInfo.transactions.length}</p>
        </>
      )}
    </div>
  );
}

Publish release

  • update package.json version
  • update version in docs/generateHtml.ts
  • update all dependencies (bun update)
  • prepare the CHANGELOG
  • open release PR on github
  • bun publish