diff --git a/deltachat-jsonrpc/README.md b/deltachat-jsonrpc/README.md index 7e8110652..bbbd40c0f 100644 --- a/deltachat-jsonrpc/README.md +++ b/deltachat-jsonrpc/README.md @@ -52,16 +52,34 @@ npm install npm run build ``` -The JavaScript client is not yet published on NPM (but will likely be soon). Currently, it is recommended to vendor the bundled build. After running `npm run build` as documented above, there will be a file `dist/deltachat.bundle.js`. This is an ESM module containing all dependencies. Copy this file to your project and import the DeltaChat class. +The package is also published on npm under the name [`@deltachat/jsonrpc-client`](https://www.npmjs.com/package/@deltachat/jsonrpc-client). +###### Usage +Stdio server (recommended): ```typescript -import { DeltaChat } from './deltachat.bundle.js' +import { startDeltaChat } from "@deltachat/stdio-rpc-server"; +import { C } from "@deltachat/jsonrpc-client"; + +const dc = await startDeltaChat("deltachat-data"); +console.log(await dc.rpc.getSystemInfo()); +const accounts = await dc.rpc.getAllAccounts() +console.log('accounts', accounts) +dc.close() +``` + +Websocket: +```typescript +import { WebsocketDeltaChat as DeltaChat } from '@deltachat/jsonrpc-client''= + const dc = new DeltaChat('ws://localhost:20808/ws') +console.log(await dc.rpc.getSystemInfo()); const accounts = await dc.rpc.getAllAccounts() console.log('accounts', accounts) ``` +##### Generate TypeScript/JavaScript documentation + A script is included to build autogenerated documentation, which includes all RPC methods: ```sh cd typescript @@ -104,7 +122,7 @@ cd typescript npm run test ``` -This will build the `deltachat-jsonrpc-server` binary and then run a test suite against the WebSocket server. +This will build the `deltachat-rpc-server` binary and then run a test suite against the deltachat-rpc-server (stdio). The test suite includes some tests that need online connectivity and a way to create test email accounts. To run these tests, talk to DeltaChat developers to get a token for the `testrun.org` service, or use a local instance of [`mailadm`](https://github.com/deltachat/docker-mailadm).