FINTERACTIONS.COM RESTAPI
  • OVERVIEW
  • VERIFICATION
  • SECURITIES
  • TRANSACTIONS
  • ORDERS
  • SIMPLIFIED ORDERS
  • BOOK SNAPSHOT
Powered by GitBook
On this page

SECURITIES

The Securities section of the RESTAPI allows subscribers to perform various operations related to securities, including listing, retrieving details, adding, and modifying securities

Endpoints

1. Get Currency List

  • HTTP Request Type: GET

  • Route: /firestapi/securities?deposit=true

  • URL / Body Parameters: None

  • Info: Lists all the currencies registered in the system, including FIAT and Cryptocurrency.

2. Get Tradeable Pairs

  • HTTP Request Type: GET

  • Route: /firestapi/securities?pair=true

  • URL / Body Parameters: None

  • Info: Lists all the tradeable pairs. This is the same route as above with a different URL parameter.

3. Get Instrument Details

  • HTTP Request Type: GET

  • Route: /firestapi/securities/:security

  • URL / Body Parameters: :security - the symbol of the security.

  • Info: Provides details of an individual pair. The route will check if the entered symbol is tradable or not before returning the information.

  • HTTPS Body Example: N/A

  • WS Example:

json

{
  "type": "get_instrument",
  "security": "BTCUSD"
}

4. Add New Security

  • HTTP Request Type: POST

  • Route: /firestapi/securities

  • URL / Body Parameters:

    • REQUIRED:

      • security: String

      • type: String ["deposit", "trading", "crypto-pair"]

      • fractionbase: Number

    • OPTIONAL:

      • description: String

      • name: String

    • REQUIRED IF TYPE trading:

      • clearinginstrument: String

    • OPTIONAL IF TYPE trading:

      • comm: Number

      • priceprecision: Number

    • REQUIRED IF TYPE crypto-pair:

      • firstpair: String

      • secondpair: String

    • OPTIONAL IF TYPE crypto-pair:

      • priceprecision: Number

  • Info: Adds a new security. When creating a crypto-pair, this request will throw an error if the firstpair + secondpair does not equal the security string.

  • HTTPS Body Example:

json

{
  "security": "BIRD",
  "type": "deposit",
  "fractionbase": 1000000,
  "name": "BIRDMAN COIN"
}

OR

json

{
  "security": "BIRD",
  "type": "trading",
  "fractionbase": 1,
  "name": "BIRDMAN STOCK",
  "priceprecision": 100
}

OR

json

{
  "security": "BIRDUSD",
  "type": "crypto-pair",
  "fractionbase": 1000000,
  "firstpair": "BIRD",
  "secondpair": "USD",
  "priceprecision": 100
}

WS Example:

json

{
  "type": "registersymbol",
  "security": "TESTSYMBOL1",
  "description": "Info",
  "fractionbase": "1",
  "attr": {"name": "TESTSYMBOL1"}
}

OR

json

{
  "type": "registersymbol",
  "security": "TESTSYMBOL1",
  "clearinginstrument": "USD",
  "istradingsymbol": true,
  "description": "Info",
  "comm": "1",
  "fractionbase": "1",
  "priceprecision": "1",
  "commissioninstrument": "USD",
  "attr": {"name": "TESTSYMBOL1"}
}

OR

json'

{
  "type": "registersymbol",
  "security": "TESTSYMBOL1USD",
  "description": "Test",
  "fractionbase": "1",
  "priceprecision": "1",
  "pairseppos": "11",
  "attr": {"name": "TESTSYMBOL1USD"}
}

5. Modify Existing Security

  • HTTP Request Type: POST

  • Route: /firestapi/securities/:security

  • URL / Body Parameters:

    • OPTIONAL:

      • fractionbase: Number (### HEAVY WARNING IF YOU HAVE LIVE ORDERS ###)

      • description: String

      • name: String

      • priceprecision: Number

    • OPTIONAL IF TYPE trading:

      • comm: Number

  • Info: Edits an existing security. The route checks if the security being edited exists, then follows similar constraints for the create route based on the type of security ("deposit", "trading", "crypto-pair").

  • HTTPS Body Example:

json

{
  "security": "BIRDUSD",
  "type": "crypto-pair",
  "fractionbase": 10000,
  "priceprecision": 10
}

OR

json

{
  "type": "modifyinstrument",
  "security": "BIRDUSD",
  "fractionbase": 10000,
  "priceprecision": 10
}

Example Implementation in Express.js

Here's an example of how you might implement these endpoints in an Express.js application:

javascript

const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const session = require('express-session');

const app = express();

app.use(bodyParser.json());
app.use(cookieParser());
app.use(session({
  secret: 'your_secret_key',
  resave: false,
  saveUninitialized: true,
  cookie: { secure: true } // Use secure cookies in production
}));

// Dummy data for demonstration purposes
const securities = [
  { security: 'BTCUSD', type: 'crypto-pair', fractionbase: 1000000, firstpair: 'BTC', secondpair: 'USD', priceprecision: 100 },
  // Add more securities as needed
];

// Get Currency List
app.get('/firestapi/securities', (req, res) => {
  if (req.query.deposit === 'true') {
    // Return the list of currencies
    res.status(200).json(securities.filter(s => s.type === 'deposit'));
  } else if (req.query.pair === 'true') {
    // Return the list of tradeable pairs
    res.status(200).json(securities.filter(s => s.type === 'crypto-pair'));
  } else {
    res.status(400).send('Invalid query parameter');
  }
});

// Get Instrument Details
app.get('/firestapi/securities/:security', (req, res) => {
  const security = securities.find(s => s.security === req.params.security);
  if (security) {
    res.status(200).json(security);
  } else {
    res.status(404).send('Security not found or not tradable');
  }
});

// Add New Security
app.post('/firestapi/securities', (req, res) => {
  const { security, type, fractionbase, description, name, clearinginstrument, comm, priceprecision, firstpair, secondpair } = req.body;

  // Perform necessary validations here

  securities.push({ security, type, fractionbase, description, name, clearinginstrument, comm, priceprecision, firstpair, secondpair });
  res.status(201).send('Security added successfully');
});

// Modify Existing Security
app.post('/firestapi/securities/:security', (req, res) => {
  const { security } = req.params;
  const { fractionbase, description, name, priceprecision, comm } = req.body;

  const existingSecurity = securities.find(s => s.security === security);
  if (existingSecurity) {
    // Perform updates and necessary validations here
    Object.assign(existingSecurity, { fractionbase, description, name, priceprecision, comm });
    res.status(200).send('Security updated successfully');
  } else {
    res.status(404).send('Security not found');
  }
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

This example sets up the specified routes using Express.js, handles getting currency lists, getting instrument details, adding new securities, and modifying existing securities. It includes the necessary validations and error handling for the endpoints.

PreviousVERIFICATIONNextTRANSACTIONS

Last updated 9 months ago