OpenFIGI API Examples
repository·main·Indexed 42 days ago
https://github.com/openfigi/api-examplesA collection of code examples in multiple programming languages—including C# (.NET 8.0), Java, JavaScript (Node.js v22.11.0), Python 3.12, Swift 6.0, Bash, and PowerShell—demonstrating how to interact with the OpenFIGI API to retrieve Financial Instrument Global Identifiers (FIGIs) for securities.
What's inside OpenFIGI
- This repository provides simple, language-specific examples demonstrating how to obtain FIGIs (Financial Instrument Global Identifiers) for securities using the OpenFIGI API. It serves as a reference for developers looking to integrate OpenFIGI capabilities into their applications using various programming languages such as Java, JavaScript, and Python.
Run the OpenFIGI Python3 example locally
mainTo run the example script on your local machine, ensure you have
Python 3.12installed. The script is designed to run without any external libraries and has been tested withPython 3.12.7.If you have an API key, you can export it as an environment variable before running the script to authenticate your requests.
# Optional: Export your API key export OPENFIGI_API_KEY=<YOUR_KEY_HERE> python3 example.pyRun OpenFIGI shell examples using Bash and curl
mainTo run the OpenFIGI shell examples in a Bash environment, ensure you have
bashandcurlinstalled. You can optionally export your API key to an environment variable namedOPENFIGI_API_KEYbefore execution.# Optional: Export your API key export OPENFIGI_API_KEY=<YOUR_KEY_HERE> ./curl.sh # OR bash ./curl.shRun the OpenFIGI Swift example using Docker
mainIf you prefer using Docker, you can build and run the example in a containerized environment. This requires
Dockerto be installed on your system.To run without an API key:
- Build the image with the tag
openfigi-swift. - Run the container, mounting the current directory to
/OpenFIGIinside the container.
To run with an API key, pass the
OPENFIGI_API_KEYenvironment variable using the-eflag.# Build the image docker build --tag 'openfigi-swift' . # Run without API key docker run --rm -it --volume ./:/OpenFIGI 'openfigi-swift' swift example.swift # Run with API key docker run --rm -it --volume ./:/OpenFIGI -e OPENFIGI_API_KEY=<YOUR_KEY_HERE> 'openfigi-swift' swift example.swift- Build the image with the tag
Run the OpenFIGI Java example using Docker
mainIf you prefer using Docker, ensure
Dockeris installed. You can build the image and run the example by mounting the current directory to the container. You can provide your API key via an environment variable during thedocker runcommand.# Build the image docker build --tag 'openfigi-java' . # Run without API key docker run --rm -it --entrypoint java --volume ./:/OpenFIGI 'openfigi-java' ./example.java # Run with API key docker run -e OPENFIGI_API_KEY=<YOUR_KEY_HERE> --rm -it --entrypoint java --volume ./:/OpenFIGI 'openfigi-java' ./example.javaRun OpenFIGI Javascript example using Docker
mainIf you prefer to use a containerized environment, you can build and run the example using Docker.
Prerequisites
Dockermust be installed on your system.
Execution Steps
- Build the image: Tag the image as
openfigi-js. - Run the container: Use the
--entrypointflag to execute the script and mount the current directory to/OpenFIGIinside the container. - Using an API Key: To pass your API key to the container, use the
-eflag to set theOPENFIGI_API_KEYenvironment variable.
# Build the image docker build --tag 'openfigi-js' . # Run without API key docker run --rm -it --entrypoint ./example.mjs --volume ./:/OpenFIGI 'openfigi-js' # Run with API key docker run --rm -it --entrypoint ./example.mjs --volume ./:/OpenFIGI 'openfigi-js' -e OPENFIGI_API_KEY=<YOUR_KEY_HERE>Run the OpenFIGI Python3 example using Docker
mainIf you prefer using Docker, you can build and run the example in a containerized environment. This requires
Dockerto be installed.- Build the image with the tag
openfigi-python. - Run the container, mounting the current directory to
/OpenFIGIinside the container. - To use an API key, pass it using the
-eflag to set theOPENFIGI_API_KEYenvironment variable.
# Build the image docker build --tag 'openfigi-python' . # Run without API key docker run --rm -it --entrypoint ./example.py --volume ./:/OpenFIGI 'openfigi-python' # Run with API key docker run --rm -it --entrypoint ./example.py --volume ./:/OpenFIGI 'openfigi-python' -e OPENFIGI_API_KEY=<YOUR_KEY_HERE>- Build the image with the tag
Run the OpenFIGI Swift example locally
mainTo run the Swift example locally, ensure you have
Swift 6.0installed. The script is designed to run without external dependencies and has been tested withSwift 6.0.3on Ubuntu 24.04.1 LTS.If you have an API key, you can export it as an environment variable before running the script to authenticate your requests.
# Optional: Export your API key export OPENFIGI_API_KEY=<YOUR_KEY_HERE> swift example.swiftRun OpenFIGI shell examples using PowerShell
mainTo run the OpenFIGI shell examples in a PowerShell environment, ensure
powershellis installed. You can optionally export your API key to an environment variable namedOPENFIGI_API_KEYbefore execution.# Optional: Export your API key export OPENFIGI_API_KEY=<YOUR_KEY_HERE> ./example-powershell.ps1 # OR pwsh ./example-powershell.ps1Run OpenFIGI Javascript example with Node.js
mainThis example script is designed to run in a Node.js environment without requiring any external libraries. It has been tested with Node.js
v22.11.0.Prerequisites
nodemust be installed on your system.
Execution Steps
- Set your API Key (Optional): To use your own credentials, export the
OPENFIGI_API_KEYenvironment variable. - Run the script: Execute the script using
node example.mjsor./example.mjs.
# Optional: Export your API key export OPENFIGI_API_KEY=<YOUR_KEY_HERE> # Run the script ./example.mjs # OR node example.mjsRun the OpenFIGI API C# example using Docker
mainIf you prefer using Docker, you can build and run the example in a containerized environment.
Prerequisites
Dockerinstalled
Execution Steps
- Build the Docker image:
docker build --tag 'openfigi-dotnet' . - Run the container. You must mount the current directory to
/OpenFIGIinside the container to provide the script context.
Without an API Key:
docker run --rm -it --entrypoint ./example.csx --volume ./:/OpenFIGI 'openfigi-dotnet'With an API Key: Pass your key using the
-eflag:docker run --rm -it --entrypoint ./example.csx --volume ./:/OpenFIGI 'openfigi-dotnet' -e OPENFIGI_API_KEY=<YOUR_KEY_HERE>docker build --tag 'openfigi-dotnet' . docker run --rm -it --entrypoint ./example.csx --volume ./:/OpenFIGI 'openfigi-dotnet' # OR: If you have acquired an API Key docker run --rm -it --entrypoint ./example.csx --volume ./:/OpenFIGI 'openfigi-dotnet' -e OPENFIGI_API_KEY=<YOUR_KEY_HERE>Run the OpenFIGI Java example locally
mainTo run the Java example on your local machine, ensure you have
jdkinstalled. The script is designed to be built by JDK and run on the JVM without external libraries. While this example uses no external dependencies, it is recommended that end users use a JSON library for serializing requests and deserializing responses in their own implementations.# Optional: Export your API key export OPENFIGI_API_KEY=<YOUR_KEY_HERE> java ./example.java