GithubHelp home page GithubHelp logo

json_rpc's Introduction

JSON-RPC Client and Server Build Status

Use and provide services using JSON-RPC!

Transports

Transport Client Server
HTTP Yes Planned
Websocket Planned Planned
TCP Yes Yes

Custom transports can be easily created. Have a look at JsonRpc::TcpClient.

Features

  • Multi-transport
  • Doesn't require trailing new-line after JSON documents
  • Lenient towards non-conform implementations
  • Built-in protection
    • Flood-protection
    • Against huge documents
    • Configurable!

Usage

Here's a quick HTTP client getting your bitcoin testnet wallets balance:

# Sample code for Bitcoin RPC:
require "json_rpc"

# Set up the HTTP client
http_client = HTTP::Client.new("localhost", 18332)
http_client.basic_auth "rpc_user", "rpc_password"

# Turn it into a JSON-RPC client
client = JsonRpc::HttpClient.new http_client

# Check your balance!
pp client.call(JsonRpc::Response(Float64), "getbalance")

Source

But there's more to find in samples/:

For a simple case, see tcp_client.cr and tcp_server.cr.

If you want to see a full application, have a look at tcp_chat.cr.

Installation

Add this to your application's shard.yml:

dependencies:
  json_rpc:
    github: Papierkorb/json_rpc

Contributing

  1. Fork it ( https://github.com/Papierkorb/json_rpc/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Running tests

  1. Install dependencies: shards install
  2. Run them: crystal spec

Contributors

  • Papierkorb Stefan Merettig - creator, maintainer

Have a nice day!

Connect all the things

json_rpc's People

Contributors

papierkorb avatar watsy0007 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.