Skip to main content

@web3api/client-js

npm

The Web3API JavaScript client exists to help developers integrate Web3API 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 '@polywrap/client-js';

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

async function main() {
// 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,
},
});
}