From 4012e834469e95f5a220376fed19cb6e321b1b83 Mon Sep 17 00:00:00 2001 From: Ludo Date: Sun, 6 Jul 2025 22:39:49 +0000 Subject: [PATCH] =?UTF-8?q?Nahr=C3=A1t=20soubory=20do=20=E2=80=9E/?= =?UTF-8?q?=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ server.js | 45 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 README.md create mode 100644 server.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..76b2fb2 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# ICO Lookup API (Node.js) + +This is a minimal Node.js + Express server that acts as an API wrapper around Finančná správa SR's open data interface. +It allows you to look up Slovak companies by their IČO number (company identifier). + +## Features + +- Accepts GET requests with an IČO as query parameter +- Returns company information in JSON format +- Built with Express and Axios +- Hardcoded API key for simplicity + +## Setup Instructions + +1. Download and extract the project +2. Open `server.js` and replace: + +``` +const API_KEY = "your_api_key_here"; +``` + +with your actual API key from [https://iz.opendata.financnasprava.sk](https://iz.opendata.financnasprava.sk) + +3. In the project directory, run: + +```bash +npm install express axios +``` + +4. Start the server: + +```bash +node server.js +``` + +5. Use the API: + +Open your browser or use curl/Postman: + +``` +http://localhost:3000/api/lookup?ico=36215589 +``` + +### Example response + +```json +{ + "meta": {...}, + "data": [...] +} +``` + +## Requirements + +- Node.js 14 or newer +- Internet connection +- Valid API key from Finančná správa SR \ No newline at end of file diff --git a/server.js b/server.js new file mode 100644 index 0000000..53d2255 --- /dev/null +++ b/server.js @@ -0,0 +1,45 @@ +// Simple Node.js + Express API server to look up Slovak companies by IČO +// using the Finančná správa SR open data API + +const express = require("express"); +const axios = require("axios"); + +const app = express(); +const PORT = 3000; + +// Insert your API key from Finančná správa SR below +const API_KEY = "2t5lK487ces7Rc4oEHrIwCjB5DpoZUBChQxCLBiSrwGNdEubKpraAtQLEiJmPXkdjNw5FssYpuO0LXSZpk3U6oqePyFaIGHokg4WNPEM0302X2BK4iXpkFv9Qg7jyeUXh50bWVExVrVSBuOnOQpBzzdJ1k1D54b115MD3y5ticWxvGDLUaqLQgA6nzFgbYOx6dR0ToJUxU714TetLBZCBy0xKSnBaOrxYv10I1gZ1q4rQx4Q8k7BTR6MaP"; + +// Endpoint: GET /api/lookup?ico=XXXXXXXX +// Example: http://localhost:3000/api/lookup?ico=36215589 +app.get("/api/lookup", async (req, res) => { + const ico = req.query.ico; + + // Validate ICO presence + if (!ico) { + return res.status(400).json({ error: "Missing ICO parameter" }); + } + + const url = `https://iz.opendata.financnasprava.sk/api/data/ds_dsrdp/search?page=1&column=ico&search=${ico}`; + + try { + // Make a request to Finančná správa API + const response = await axios.get(url, { + headers: { + accept: "application/json", + key: API_KEY + } + }); + + // Return the fetched JSON data + res.json(response.data); + } catch (error) { + // Handle errors (e.g. invalid API key, server down) + res.status(500).json({ error: error.message }); + } +}); + +// Start the server +app.listen(PORT, () => { + console.log(`API server is running at http://localhost:${PORT}`); +}); \ No newline at end of file