Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qertis/request-json-rpc2
Simplified JSON-RPC2 request client.
https://github.com/qertis/request-json-rpc2
json-rpc-api json-rpc-client json-rpc2 json-rpc2-client jsonrpc-client jsonrpc2 rpc
Last synced: 28 days ago
JSON representation
Simplified JSON-RPC2 request client.
- Host: GitHub
- URL: https://github.com/qertis/request-json-rpc2
- Owner: qertis
- License: mit
- Created: 2023-01-02T09:22:13.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-05T18:17:19.000Z (7 months ago)
- Last Synced: 2024-05-18T23:40:30.904Z (6 months ago)
- Topics: json-rpc-api, json-rpc-client, json-rpc2, json-rpc2-client, jsonrpc-client, jsonrpc2, rpc
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/request-json-rpc2
- Size: 113 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# REQUEST JSON RPC2
> Simplified JSON-RPC 2.0 CJS and ESM client## Super simple to use
Request JSON-RPC 2 is designed to be the simplest way possible to make JSON-RPC 2 calls.
```javascript
import requestJsonRpc2 from 'request-json-rpc2';const result = await requestJsonRpc2({
url: String,
body: {
method: String,
params: Array | Object,
},
});
```## Powerful sample
```javascript
const result = await requestJsonRpc2({
url: '/api',
body: {
id: '1234567890',
method: 'record',
params: {
"$schema": "http://json-schema.org/draft-04/schema#",
"$id": "https://example.com/employee.schema.json",
"title": "Record of employee",
"description": "This document records the details of an employee",
"type": "object",
"properties": {
"id": {
"description": "A unique identifier for an employee",
"type": "number",
},
},
},
},
headers: {
'Accept': 'application/schema+json',
},
});
```## HTTP Authentication
Includes basic or bearer.
```javascript
const result = await requestJsonRpc2({
url: '/api',
body: {
method: 'YOUR_METHOD',
params: ['auth hello world'],
},
auth: {
'user': 'username',
'pass': 'password',
'sendImmediately': false,
},
});
```## JWT
JSON Web Token example.
```javascript
const result = await requestJsonRpc2({
url: '/api',
body: {
method: 'YOUR_METHOD',
params: ['JWT hello world'],
},
jwt: 'ewogICJhbGciOiAiSFMyNTYiLAogICJ0eXAiOiAiSldUIgp9.ewogICJuYW1lIjogIlJlcXVlc3QgSlNPTi1SUEMgMi4wIgp9',
});
```## Signature
> Ed25519Signature2018
```javascript
const result = await requestJsonRpc2({
url: '/api',
body: {
method: 'YOUR_METHOD',
params: ['signature hello world'],
},
signature: {
"@context": ["https://w3id.org/security/v2"],
"id": "did:example:123456789abcdefghi#keys-1",
"type": "Ed25519VerificationKey2018",
"controller": "did:example:123456789abcdefghi",
"expires": "2023-01-08T16:02:20Z",
"publicKeyBase58": "H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV",
},
});
```## Testing
See [tests directory](https://github.com/qertis/request-json-rpc2/tree/master/tests).