Skip to main content

Client

npm

The Polywrap JavaScript client exists to help developers integrate wrappers into their applications. It's designed to run in any environment that can execute JavaScript (think websites, node scripts, etc.).

Installation#

npm install @web3api/client-js

Usage#

Use an import or require statement, depending on which your environment supports.

import { Web3ApiClient } from "@web3api/client-js";

Then, you will be able to use the Web3ApiClient like so:

// Simply instantiate the Web3ApiClient.
const client = new Web3ApiClient();
// ...And then you'll be able to use the `query`
// method to send GraphQL requests to any Web3API
// that's located at the specified URI.
const result = await client.query({
uri: 'api.example.eth',
query: `query {
doSomething(
variable: $variable
value: "important value"
) {
returnData
}
}`,
variables: {
variable: 555,
},
});