@openrealm/web
TypeScript icon, indicating that this package has built-in type declarations

0.7.0 • Public • Published

@openrealm/hub-web

A fast and easy REST-like interface to work with Openrealm Hubs. Designed to work with Hub and any other Hub that implements the Openrealm protocol.

Features

  • Call any endpoint using a simple HTTP API, including from a browser environment
  • Responses are plain JSON
  • Written entirely in Typescript, with strict types for safety.

Installation

The examples in this package use axios to make HTTP requests, but you can use any library. It is also useful to install the @openrealm/core library which has several helper methods that are useful while working with Openrealm messages.

yarn add axios @openrealm/core
yarn add -D @types/axios 

Documentation

The HTTP API endpoints are documented here.

Getting started: fetching casts

import axios from "axios";

const qid = 2;
const server = "http://nemes.openrealm.xyz:2281";

try {
    const response = await axios.get(`${server}/v1/castsByQid?qid=${qid}`);

    console.log(`API Returned HTTP status ${response.status}`);    
    console.log(`First Cast's text is ${response.messages[0].data.castAddBody.text}`);
} catch (e) {
    // Handle errors
    console.log(response);
}

grpc-Web

grpc-web was an older way of proxying to the grpc API from web environments. This has been deprecated and is no longer supported. You can read the original grpc-web documentation and examples here.

Contributing

Please see our contributing guidelines before making a pull request.

License

MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i @openrealm/web

Weekly Downloads

1

Version

0.7.0

License

MIT

Unpacked Size

1.44 MB

Total Files

6

Last publish

Collaborators

  • wvrld