API NSD

A web service that offers access via an interface for reference data and data about corporate actions with three versions of interrelations

Buy   Test access

GetNews beta

Information messages related with securities, companies and actions with personal accounts

-
name type description req.
Select the fields you need (expand all)
title_ru string Заголовок на русском языке Yes
title_en string Заголовок на английском языке Yes
body_ru string Тело новости на русском языке (HTML) Yes
body_en string Тело новости на английском языке (HTML) Yes
pub_date string Дата публикации Yes
news_date string Дата новости Yes
content_id_out integer Идентификатор новости Yes
data object Связанный объект данных Yes
Download

{
  "type": "array",
  "items": {
    "$ref": "#/definitions/Message"
  },
  "definitions": {
    "Message": {
	  "type": "object",
	  "properties": {
		"title_ru": {
		  "title": "Заголовок RU",
		  "description": "Заголовок на русском языке",
		  "type": "string"
		},
		"title_en": {
			  "title": "Заголовок EN",
			  "description": "Заголовок на английском языке",
			  "type": "string"
			},
		"body_ru": {
			  "title": "Тело RU",
			  "description": "Тело новости на русском языке (HTML)",
			  "type": "string"
			},
		"body_en": {
			  "title": "Тело EN",
			  "description": "Тело новости на английском языке (HTML)",
			  "type": "string"
			},
		"pub_date": {
			  "title": "Дата публикации",
			  "description": "Дата публикации",
			  "type": "string"
			},
		"news_date": {
			  "title": "Дата новости",
			  "description": "Дата новости",
			  "type": "string"
			},
		"content_id_out": {
			  "title": "ID",
			  "description": "Идентификатор новости",
			  "type": "integer"
			},
		"data": {
			  "title": "Данные",
			  "description": "Связанный объект данных",
			  "type": "object",
			  "properties": {}
			}
	  }, 
	  "required": [
		"title_ru",
		"title_en",
		"body_ru",
		"body_en",
		"pub_date",
		"news_date",
		"content_id_out",
		"data"
	  ]
	}
  }
}

URL



Ask the developer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using Newtonsoft.Json.Linq;
using ClosedXML.Excel;

namespace ApiSample
{
    class Program
    {
        public const string ApiUrl = "http://172.23.24.198:5000/securities?limit=100";
        public static HashSet<string> SetOfIsins = new HashSet<string>(new[] { "RU0007202057", "RU0007202545", "RU0007201018", "RU0007202032" });
        public const string FileName = "coupons.xlsx";

        static void Main(string[] args)
        {
            Console.WriteLine("Загрузка данных...");
            var wc = new WebClient() { Encoding = Encoding.UTF8, };
            var json = wc.DownloadString(ApiUrl);

            var bonds = JArray.Parse(json);
            var filteredBonds = bonds.Where(b => SetOfIsins.Contains((string)b["isin"])).ToList();

            Console.WriteLine("Формирование Excel...");
            GenerateExcel(filteredBonds);
            Console.WriteLine("Готово!");
        }

        private static void GenerateExcel(List<JToken> input)
        {
            var workbook = new XLWorkbook();
            workbook.Use1904DateSystem = true;
            var ws = workbook.Worksheets.Add("Coupons info");

            ws.Column(1).Width = 16;
            ws.Column(2).Width = 70;
            ws.Column(3).Width = 50;
            ws.Column(4).Width = 35;
            ws.Column(5).Width = 16;

            var columns = new[] { "ISIN", "Название", "Эмитент", "Корпоративное действие", "Дата" };
            foreach (var j in Enumerable.Range(0, columns.Length))
            {
                ws.Cell(1, j + 1).Value = columns[j];
                ws.Cell(1, j + 1).Style.Fill.BackgroundColor = XLColor.FromTheme(XLThemeColor.Accent6);
            }

            var data = new List<List<JToken>>();
            foreach (var bond in input) {
                var corpActions = bond["corp_actions"]?.ToArray();
                if (corpActions == null || corpActions.Length == 0)
                continue;

            foreach (var c in corpActions)
                try
                {
                    data.Add(new List<JToken>() { bond["isin"], bond["name_full"], bond["issuer"]["name_full"],
                        c["corp_action_type"]["name"], c["action_date_plan"] });
                } catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    continue;
                }
            }

            for (int i = 0; i < data.Count; i++)
                for (int j = 0; j < columns.Length; j++)
                {
                    ws.Cell(i + 2, j + 1).SetValue<string>(Convert.ToString(data[i][j]));
                    ws.Cell(i + 2, j + 1).Style.Fill.BackgroundColor = i % 2 == 0 ? XLColor.FromTheme(XLThemeColor.Accent6, 0.5) : XLColor.FromTheme(XLThemeColor.Accent6, 0.8);
                }

            ws.RangeUsed().SetAutoFilter();

            workbook.SaveAs(FileName);
            System.Diagnostics.Process.Start(FileName);
        }
    }
}
        
package ru.nsd.example;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.json.JSONArray;
import org.json.JSONObject;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
import java.io.FileOutputStream;
import java.io.IOException;

public class RestClientExample {

    private static final String NSD_DATA_HOST = "http://172.23.24.198:5000";
    private static final String METHOD_NAME = "securities";
    private static final String RESULT_EXCEL_PATH = "C:/Temp/securities100.xls";

    public static void main(String[] args) {
        saveExcel(getFirstHundredSecurities());
    }

    private static JSONArray getFirstHundredSecurities() {
        Client client = Client.create(new DefaultClientConfig());
        WebResource webResource = client.resource(UriBuilder.fromUri(NSD_DATA_HOST).build());
        String jsonData = webResource.path(METHOD_NAME).queryParam("limit", "100")
        .accept(MediaType.APPLICATION_JSON_TYPE).get(String.class);
        return new JSONArray(jsonData);
    }

    private static void saveExcel(JSONArray securities) {
        try {
            FileOutputStream stream = new FileOutputStream(RESULT_EXCEL_PATH);
            HSSFWorkbook workbook = generateExcel(securities);
            workbook.write(stream);
            stream.close();
        } catch (IOException ex) {
            System.out.println(ex);
        }
    }

    private static HSSFWorkbook generateExcel(JSONArray securities) {
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet();
        int rownum = 1;

        HSSFRow headRow = sheet.createRow(rownum++);
        headRow.createCell(0).setCellValue("ISIN");
        headRow.createCell(1).setCellValue("Полное наименование");

        for (Object obj : securities) {
            JSONObject json = (JSONObject) obj;
            HSSFRow row = sheet.createRow(rownum++);
            row.createCell(0).setCellValue(json.optString("isin"));
            row.createCell(1).setCellValue(json.optString("name_full"));
        }

        return workbook;
    }
}