Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nomics-platform

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nomics-platform - npm Package Compare versions

Comparing version 0.4.2 to 0.5.0

0

bin/nomics-platform.js
#!/usr/bin/env node
require('../').CLI(process.argv.slice(2))
module.exports = {
CLI: require('./lib/cli')
}

@@ -0,0 +0,0 @@ const url = require('url')

4

lib/audit/info.js

@@ -1,3 +0,3 @@

const get = require('./get')
const Result = require('./result')
const axios = require('axios')
const url = require('url')

@@ -8,3 +8,3 @@

try {
const info = await get(u + '/info')
const info = (await axios.get(u + '/info')).data
results.push(new Result(true, true, '/info is valid JSON'))

@@ -11,0 +11,0 @@ results.push(...auditInfoData(info))

@@ -1,3 +0,3 @@

const get = require('./get')
const Result = require('./result')
const axios = require('axios')

@@ -7,3 +7,3 @@ module.exports = async function (u) {

try {
const markets = await get(u + '/markets')
const markets = (await axios.get(u + '/markets')).data
results.push(new Result(true, true, '/markets is valid JSON'))

@@ -10,0 +10,0 @@ results.push(...auditMarketData(markets))

@@ -0,0 +0,0 @@ class Result {

@@ -1,4 +0,3 @@

const get = require('./get')
const Result = require('./result')
const axios = require('axios')
const validTypes = ['market', 'limit', 'ask']

@@ -12,3 +11,3 @@ const validSides = ['buy', 'sell']

try {
markets = await get(u + '/markets')
markets = (await axios.get(u + '/markets')).data
} catch (e) {

@@ -29,3 +28,3 @@ return results

try {
trades = await get(u + path)
trades = (await axios.get(u + path)).data
} catch (e) {

@@ -47,3 +46,3 @@ results.push(new Result(false, true, `${path} failed or not JSON`, e))

try {
trades = await get(u + nextPath)
trades = (await axios.get(u + nextPath)).data
} catch (e) {

@@ -50,0 +49,0 @@ results.push(new Result(false, true, `${nextPath} failed or not JSON`, e))

var audit = require('./audit')
var init = require('./init')

@@ -25,3 +24,2 @@ class UsageError extends Error {}

case 'audit': return audit(options)
case 'init': return init(options)
default: return new UsageError('Unknown command: ' + command)

@@ -35,5 +33,4 @@ }

'Commands:',
'\taudit [url]',
'\tinit'
'\taudit [url]'
].join('\n\t'))
}
{
"name": "nomics-platform",
"version": "0.4.2",
"version": "0.5.0",
"description": "Nomics Platform Toolkit",

@@ -36,6 +36,9 @@ "keywords": [

"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0"
},
"dependencies": {
"axios": "^0.18.0"
}
}

@@ -1,43 +0,119 @@

# Nomics Platform Toolkit for Node.js
# Nomics Platform
## Installation
This repository contains the Nomics Platform Integration Specification as well as an auditing tool to verify compliance with the specification.
`nomics-platform` is a Node.js package. You have multiple options for using it:
To audit your endpoint, install Node.js and run:
Easily run with npx:
```
npx nomics-platform
npx nomics-platform audit https://path-to-your-api-root
```
Or, install globally via npm:
## Exchange Integration Specification
```
npm install -g nomics-platform
```
The following section describes the API that an exchange must implement in order to integrate with the Nomics platform. From the root of your API, you must implement the following endpoints.
Or, install globally via yarn:
### `/info` - Exchange Information
The `/info` endpoint returns information about the exchange as a whole, and is used by Nomics to display information about your exchange to users.
#### Parameters
None
#### Response
JSON object containing the following properties:
* `name`: **Required** The name of the exchange
* `description`: A one paragraph description in plain text (no html)
* `logo`: A URL to your exchange's logo. It should be an SVG or a 500x500 PNG
* `website`: A URL to your exchange
* `twitter`: Twitter username to your exchange (without @)
Example:
```json
{
"name": "Exchange Name",
"description": "A one paragraph description of the exchange in plain text",
"logo": "https://example.com/exchange-logo.png",
"website": "https://example.com",
"twitter": "example"
}
```
yarn global add nomics-platform
```
Or, add it as a `devDependency` in your project's `package.json` to audit as part of your `scripts` or test suite.
### `/markets` - Available Markets
## Usage
The `/markets` endpoint returns a list of all available markets on your exchange and is used to query other endpoints on your API.
Usage is documented within the tool and can be viewed by running it with no arguments:
#### Parameters
None
#### Response
JSON array of objects (one for each market) containing the following properties:
* `id`: **Required** The exchange's ID of the market
* `base`: **Required** The base currency of the market
* `quote`: **Required** The quote currency of the market
Example:
```json
[
{
"id": "BTC-USD",
"base":"BTC",
"quote": "USD"
}, {
"id": "ETH-USDT",
"base": "ETH",
"quote": "USDT"
}
]
```
nomics-platform
```
## Performing Audits on Nomics Platform APIs
### `/trades` - Historical Executed Trades
The `nomics-platform` tool can audit an API to determine its compatibility with the Nomics Platform.
The `/trades` endpoint returns executed trades historically for a given market (provided via parameters). It allows Nomics to ingest all trades from your exchange for all time.
Audit a url directly:
#### Parameters
* `market` **Required** A market ID from the `/markets` endpoint
* `since` A trade ID from a previous `/trades` response. If none is provided, the oldest trades should be returned
#### Response
JSON array of trade object for the given market after (and not including) the trade ID provided, with the following properties:
* `id` **Required** A string ID for the trade that is unique within the scope of the market
* `timestamp` **Required** Timestamp of the trade in RFC3339
* `price` **Required** The price for one unit of the base currency expressed in the quote currency as a string that is parseable to a positive number.
* `amount` **Required** The amount of the base currency that was traded as a string that is parseable to a positive number.
* `order` The ID of the order that was executed to produce this trade
* `type` The type of order that resulted in the trade: [`market`, `limit`]
* `side` The direction of the trade [`buy`, `sell`]
* `raw` The raw data of the trade as represented by the exchange. This can be any JSON encodable data.
Example:
```json
[
{
"id": "123456789",
"timestamp": "2006-01-02T15:04:05.999999999Z07:00",
"price": "123.45678",
"amount": "48.75",
"order": "8afe76fabe8befa",
"type": "market",
"side": "buy",
"raw": [123456789, 1136214245, 123.45678, 48.75, "8afe76fabe8befa", "m"]
}
]
```
npx nomics-platform audit https://path-to-root-of-api/
```
Notes:
* The number of trades returned is up to the exchange's implementation.
* Returning an empty array signifies there are no newer trades than the given `since` ID.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc