OrdinalsBot Node.js Library
The OrdinalsBot Node library provides convenient access to the OrdinalsBot API from
applications written in JavaScript.
Documentation
You can find examples here. For more information refer to our API docs.
Installation
Install the package with:
npm install ordinalsbot --save
or
yarn add ordinalsbot
Import and intialization
The package needs to be configured with your account's API key which you can get by opening a ticket in our Discord for now. Our developer dashboard is coming soon...
import { MarketPlace, Inscription } from "ordinalsbot";
let inscription = new Inscription("API_KEY", "dev");
let marketplace = new MarketPlace("API_KEY", "dev");
Usage
try {
const order = await inscription.createOrder({
files: [
{
size: 10,
type: "plain/text",
name: "my-text-inscription-file.txt",
dataURL: "data:plain/text;base64,dGVzdCBvcmRlcg==",
},
],
lowPostage: true,
receiveAddress: "",
fee: 11,
});
console.log("Order: ", order);
} catch (error) {
console.log("Exception: ", error);
}
try {
const listing = await marketplace.getListing();
console.log("Marketplaces: ", listing);
} catch (e) {
console.log("Exception: ", e);
}
Using Promises
Every method returns a chainable promise which can be used instead of a regular
callback:
inscription
.createOrder({
files: [
{
size: 10,
type: "plain/text",
name: "my-text-inscription-file.txt",
dataURL: "data:plain/text;base64,dGVzdCBvcmRlcg==",
},
],
lowPostage: true,
receiveAddress: "",
fee: 11,
})
.then((order) => {
console.log("Order: ", order);
})
.catch((error) => {
console.log("Exception: ", error);
});
marketplace
.getListing()
.then((listings) => {
console.log("Order: ", listings);
})
.catch((error) => {
console.log("Exception: ", error);
});