---
title: Http Module
slug: signum/http-module
docTags: 
createdAt: 2022-08-30T21:23:48.000Z
---

::Image[]{src="https://api.archbee.com/api/optimize/l2AIpSUU6srSQmG1-K2bb/5NpfdGTjC2O7YckI6hySi_http.png" size="20" width="512" height="512" position="center" showCaption="false"}

| API Reference                                                                                    | [SignumJS Http](https://signum-network.github.io/signumjs/modules/http.html)                                                                   |
| ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| NPM Package                                                                                      | [@signumjs/http](https://www.npmjs.com/package/@signumjs/http)                                                                                 |
| CDN URL[](https://cdn.jsdelivr.net/npm/@signumjs/crypto@1.0.0-rc.31/dist/signumjs.crypto.min.js) | [https://cdn.jsdelivr.net/npm/@signumjs/http/dist/signumjs.http.min.js](https://cdn.jsdelivr.net/npm/@signumjs/http/dist/signumjs.http.min.js) |
| IIFE namespace                                                                                   | `sig$http`                                                                                                                                     |



## Installation

:::CodeblockTabs
npm

```shell
npm i @signumjs/http
```

yarn

```shell
yarn add @signumjs/http
```

\<script/>

```html
<script src='https://cdn.jsdelivr.net/npm/@signumjs/http/dist/signumjs.http.min.js'></script>

<!--  namespace is sig$http -->
<script >
    const coingeckoClient = sig$http.HttpClientFactory.createHttpClient("https://api.coingecko.com/api/v3/coins")
   // make your request with the relative url
   coingeckoClient
   .get('signum?tickers=false&community_data=false&developer_data=false&market_data=true')
   .then(({response}) => {
        console.info(response.market_data.current_price.btc * 10e7), ' SATS (BTC)')
   })
   .catch(console.error)
</script>
```
:::

## Basic Usage

The Http Module is a thin wrapper around the isomorphic HTTP library [axios](https://github.com/axios/axios). It mainly unifies responses such that its use is consistent

:::CodeblockTabs
```javascript
const {HttpClientFactory} = require('@signumjs/http')

function formatCurrency(value) {
    return (value).toFixed(4)
}

async function checkSignumTicker() {
    try {
        // create your client using the factory...
        const coingeckoClient = HttpClientFactory.createHttpClient("https://api.coingecko.com/api/v3/coins")

        // make your request with the relative url
        const {response} = await coingeckoClient.get('signum?tickers=false&community_data=false&developer_data=false&market_data=true')
        console.info(formatCurrency(response.market_data.current_price.btc * 10e7), ' SATS (BTC)')
        console.info(formatCurrency(response.market_data.current_price.usd), ' USD')
        console.info(formatCurrency(response.market_data.current_price.eur), ' EUR')
    } catch (e) {
        // if the request fails the error is of type HttpError
        console.error(e)
    }
}

(async () => {
    await checkSignumTicker();
})();
```

\<script/>

```javascript
async function checkSignumTicker() {
    try {
        // create your client using the factory...
        const coingeckoClient = sig$http.HttpClientFactory.createHttpClient("https://api.coingecko.com/api/v3/coins")

        // make your request with the relative url
        const {response} = await coingeckoClient.get('signum?tickers=false&community_data=false&developer_data=false&market_data=true')
        console.info(formatCurrency(response.market_data.current_price.btc * 10e7), ' SATS (BTC)')
        console.info(formatCurrency(response.market_data.current_price.usd), ' USD')
        console.info(formatCurrency(response.market_data.current_price.eur), ' EUR')
    } catch (e) {
        // if the request fails the error is of type HttpError
        console.error(e)
    }
}

checkSignumTicker();
```
:::
