# ala-api2

> Application programming interface to ALA blockchain nodes.

Latest version **2.0.1** (published 2019-12-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install ala-api2
pnpm add ala-api2
yarn add ala-api2
bun add ala-api2
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2019-12-17 |
| First published | 2019-12-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | aladinnetwork |
| Keywords | ALADIN, Blockchain, API |

## Links

- npm: https://www.npmjs.com/package/ala-api2
- Repository: https://github.com/ALADIN-Network/ala-api2
- Homepage: https://github.com/ALADIN-Network/ala-api2#readme
- Issues: https://github.com/ALADIN-Network/ala-api2/issues
- npm.io page: https://npm.io/package/ala-api2

## Dependencies (3)

- [ala-json2](https://npm.io/package/ala-json2.md) ^2.0.2
- [camel-case](https://npm.io/package/camel-case.md) ^3.0.0
- [isomorphic-fetch](https://npm.io/package/isomorphic-fetch.md) ^2.2.1

## Recent versions

- 2.0.1 (latest) — 2019-12-17

## README

[![Build Status](https://travis-ci.org/ALAIO/ala-api2.svg?branch=master)](https://travis-ci.org/ALAIO/ala-api2)
[![NPM](https://img.shields.io/npm/v/ala-api2.svg)](https://www.npmjs.org/package/ala-api2)

# Ala API

Application programming interface to ALA blockchain nodes.  This is mostly for read-only API calls.  If you decide you need to sign transactions, your better off using this API in the [alaexplorerjs](https://github.com/ALADIN-Network/alaexplorerjs) package.

# Requirement

Build and run [alad](https://github.com/ALADIN-Network/ala) or direct requests to a public testnet or production node.

## Usage

```javascript
api = require('ala-api2') // Or api = require('./src')

testnet = api.Testnet() // See ./src/testnet.js for configuration

// Any API call without a callback parameter will print documentation: description,
// parameters, return value, and possible errors.  All methods and documentation
// are created from JSON files in alaexplorerjs/json/api/v1..
testnet.getInfo()

// A Promise is returned if a callback is not provided.
testnet.getInfo({}).then(result => console.log(result))
testnet.getBlock(1).then(result => console.log(result))

// For callbacks instead of Promises provide a callback
callback = (err, res) => {err ? console.error(err) : console.log(res)}

// The server does not expect any parameters only the callback is needed
testnet.getInfo(callback)

// Parameters are added before the callback
testnet.getBlock(1, callback)

// Parameters can be an object
testnet.getBlock({block_num_or_id: 1}, callback)
testnet.getBlock({block_num_or_id: 1}).then(result => console.log(result))
```

## Configuration

```js
api = require('ala-api2') // Or api = require('./src')

options = {
  httpEndpoint: 'http://127.0.0.1:8888', // default
  debug: false
}

testnet = api.Testnet(options)
```

## API Documentation

API methods and documentation are generated from:
* [chain.json](https://github.com/ALADIN-Network/ala-json2/blob/master/api/v1/chain.json)
* [account_history.json](https://github.com/ALADIN-Network/ala-json2/blob/master/api/v1/account_history.json)

## Environment

Node 6+ and browser (browserify, webpack, etc)

## TODO

Automate code-coverage after a public testnet is available.

---
_Source: https://npm.io/package/ala-api2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
