Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

@iota/http-client

Package Overview
Dependencies
3
Maintainers
6
Versions
41
Issues
File Explorer

Advanced tools

@iota/http-client

Send commands to IRI over HTTP.

    1.0.0-beta.30latest

Version published
Maintainers
6
Yearly downloads
15,180
decreased by-50.63%

Weekly downloads

Changelog

Source

v1.0.0-beta.30

Important Changes:

  • tips parameter is no longer needed for getInclusionState api call
  • getLatestInclusion api call has been removed
  • No threshold parameter is required in getBalances api call
  • getTips api call has been removed

Changelog

  • Fix: Ignore null trytes during trytes to ascii conversion (#480)
  • Update: Remove threshold parameter from getBalances() (#481)
  • Update: Remove getTips() api (#483)
  • Update: Remove tips parameter from getInclusionStates() (#484)
  • Update: Remove getLatestInclusion (#484)
  • Chore: Update crypto-js in @iota/core (#460)
  • Chore: Update build scripts for @iota/pearl-diver-react-native (#501, #502)

Readme

Source

@iota/http-client

Sends commands to IRI over HTTP. Allows to create a network provider compatible with functions in @iota/core.

Installation

Install using npm:

npm install @iota/http-client

or using yarn:

yarn add @iota/http-client

API Reference

http-client.createHttpClient([settings])

Summary: Creates an HTTP client to access the IRI API.

ParamTypeDefaultDescription
[settings]Object{}
[settings.provider]Stringhttp://localhost:14265URI of an IRI node to connect to
[settings.apiVersion]String | number1IOTA API version to be sent in the X-IOTA-API-Version header.
[settings.requestBatchSize]number1000Number of search values per request

This method creates an HTTP client that you can use to send requests to the IRI API endpoints.

To send requests to the IRI node, use the send() method.

Returns: HTTP client object
Example

let settings = { provider: 'http://mynode.eu:14265' } let httpClient = HttpClient.createHttpClient(settings);

http-client.send(command, [uri], [apiVersion])

Fulil: Object - Response
Reject: Error - Request error

ParamTypeDefault
commandCommand
[uri]Stringhttp://localhost:14265
[apiVersion]String | Number1

Sends an http request to a specified host.

Returns: Promise

http-client~createHttpClient(command)

Summary: Sends an API request to the connected IRI node.
Fulfil: Object response - The response from the IRI node
Reject: Object error - The connected IOTA node's API returned an error. See the list of error messages

ParamTypeDescription
commandObjectThe request body for the API endpoint

This method uses the HTTP client to send requests to the IRI API endpoints.

To create an HTTP client, use the createHttpClient() method.

Example

let httpClient = HttpClient.createHttpClient(settings); httpClient.send({command:'getNodeInfo'}) .then(response => { console.log(response); }) .catch(error => { console.log(error); })

http-client~setSettings([settings])

Summary: Updates the settings of an existing HTTP client.

ParamTypeDefaultDescription
[settings]Object{}
[settings.provider]Stringhttp://localhost:14265URI of an IRI node to connect to
[settings.apiVersion]String | number1IOTA API version to be sent in the X-IOTA-API-Version header.
[settings.requestBatchSize]number1000Number of search values per request.

This method updates the settings of an existing HTTP client.

To create an HTTP client, use the createHttpClient() method.

Example

let settings = { provider: 'https://nodes.devnet.thetangle.org:443' } let httpClient = http.createHttpClient(settings); httpClient.send({command:'getNodeInfo'}).then(res => { console.log(res) }).catch(err => { console.log(err) }); httpClient.setSettings({provider:'http://newnode.org:14265'}); httpClient.send({command:'getNodeInfo'}).then(res => { console.log(res) }).catch(err => { console.log(err) })

Keywords

Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc