Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,66 @@
# Ord API

Implements some types for talking to the `ord` JSON-API.
Simple TypeScript client for `ord` API.
See the [docs](https://docs.ordinals.com/guides/api).

## Installation

Using npm:

```bash
$ npm install ordapi
```

Using yarn:

```bash
$ yarn add ordapi
```

Using pnpm:

```bash
$ pnpm add ordapi
```

Using bun:

```bash
$ bun add ordapi
```

## Usage

```typescript
import { OrdClient, Block } from 'ordapi';

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

useEffect(() => {
// Create client instance
const client = new OrdClient('https://your-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>
<p>Height: {blockInfo.height}</p>
<p>Hash: {blockInfo.hash}</p>
<p>Number of transactions: {blockInfo.transactions.length}</p>
</div>
);
}
```