An open API service indexing awesome lists of open source software.

https://github.com/raphjaph/ordapi

Typescript library for talking to the `ord` JSON API.
https://github.com/raphjaph/ordapi

api-client bitcoin inscriptions javascript javascript-library ordinals runes typescript

Last synced: about 1 year ago
JSON representation

Typescript library for talking to the `ord` JSON API.

Awesome Lists containing this project

README

          

# Ord API

Simple TypeScript client for `ord` API.
See the [docs](https://docs.ordinals.com/guides/api).

[![npm version](https://img.shields.io/npm/v/ordapi.svg)](https://www.npmjs.com/package/ordapi)
[![npm downloads](https://img.shields.io/npm/dm/ordapi.svg)](https://www.npmjs.com/package/ordapi)
[![License](https://img.shields.io/npm/l/ordapi.svg)](https://github.com/raphjaph/ordapi/blob/master/LICENSE)
[![CI Status](https://github.com/raphjaph/ordapi/workflows/CI/badge.svg)](https://github.com/raphjaph/ordapi/actions)

## 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
```

## Import

Import the client and types depending on your needs:

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

const client = new OrdClient('https://ord-server.com');
const block = await client.getBlock(0);
```

```typescript
// Using both client and types
import OrdClient, { Inscription } from 'ordapi';

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

## Usage

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

function App() {
const [blockInfo, setBlockInfo] = useState(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 (


Genesis Block


{blockInfo && (
<>

Height: {blockInfo.height}


Hash: {blockInfo.hash}


Number of transactions: {blockInfo.transactions.length}


>
)}

);
}
```

### 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`