openfigi / api-examples Goto Github PK
View Code? Open in Web Editor NEWExamples of programs that interact with the OpenFIGI services via their APIs.
License: Apache License 2.0
Examples of programs that interact with the OpenFIGI services via their APIs.
License: Apache License 2.0
the single string constructor of OpenFIGIRequest can cause misleading results because of how it tries to split the market and exchange codes from the ticker.
For instance a request for
new OpenFIGIRequest("USX US Equity")
will return the FIGI for "X US Equity" instead.
Is it possible to do a quick search through the API, similar to https://openfigi.com/search?
I can't seem to get the same results.
Hello,
For months I have been able to use the OpenFIGI API v2 service for finding FIGIs for futures. I specify the following in my request to https://api.openfigi.com/v2/search
:
query
: the two letter market code along with the expiry monthexchCode
: the market that the future is traded onsecurityType
: "Future"expiration
: a JSON array of two dates. The first date being the start of the month prior to expiration, the second date being the end of the month after the expiration.This results in a response of 200 with a JSON object that has the contents of {"data": []}
.
This query returns the security successfully:
query
: "HIJ0"exchCode
: "HKG"securityType
: "Future"The response is: "{"data":[{"figi":"BBG00S1J0LJ8","name":"HANG SENG IDX FUT Apr20","ticker":"HIJ0","exchCode":"HKG","compositeFIGI":null,"uniqueID":"IX51238762-0","securityType":"Physical index future.","marketSector":"Index","shareClassFIGI":null,"uniqueIDFutOpt":"HIJ0 ELEC Index","securityType2":"Future","securityDescription":"HIJ0 ELEC"}]}"
However, if I add expiration
to the query, for the same future security which expires in April, I don't see the same result:
query
: "HIJ0"exchCode
: "HKG"securityType
: "Future"expiration
: ["2020-03-01", "2020-05-01"]This query results in a response of {"data": []}
.
How come expiration
no longer works?
Financial identifiers are mostly cryptic. That makes the Long Security Description
field that's sometimes optionally available if one selects a market sector other than All
very valuable. However, it's unavailable via the API; only the truncated Security Description
is provided.
For example, https://www.openfigi.com/search#!?simpleSearchString=CAD%20Canadian%20Government%20Bond%20B&page=1&filters=&pageSize=100&marketSector=Index&facets=COUNTRY_ISO:,,CA&sort=LONG_COMP_NAME shows only CAD Canadian Government Bond B
for every row in the Security Description
column, but the Long Security Description
column shows CAD Canadian Government Bond BVAL Yield Curve 30 Year
, CAD Canadian Government Bond BVAL Yield Curve 7 Year
, etc. This is crucial to be able to understand what identifiers we're working with.
Please include the Security Long Description
in the mapping and search API output.
Example PHP code would be very useful.
Hi All,
I'm new to Python and AWS lambda function, I was trying to run my python code through Lambda function to perform mapping to FIGI identifiers and save the output (mapped file) to S3 bucket. My code reads input of ISIN identifiers from another file from another S3 bucket. What I did is the following.
My code kept giving me error in lambda despite trying python3.8, 3.9 and 3.10 versions. none resolved the problem
Errors: it doesn't find openFigiClient from neither openfigi or pyopenfigi modules, after doing everything code shows below error:
esponse
{
"errorMessage": "Unable to import module 'lambda_function': cannot import name 'OpenFigiClient' from 'pyopenfigi' (/var/task/pyopenfigi/init.py)",
"errorType": "Runtime.ImportModuleError",
"requestId": "b5b5eb4a-109f-4175-b8f8-4500cfb8b9fe",
"stackTrace": []
}
Code is below:
import boto3
import csv
from pyopenfigi import OpenFigiClient
def lambda_handler(event, context):
# Initialize S3 client
s3_client = boto3.client('s3')
# Initialize OpenFIGI client with your API key
figi_client = OpenFigiClient(api_key='MyAPIKeyhere')
# Get the input CSV file from S3 bucket X
response = s3_client.get_object(Bucket='Mystorag2', Key='input.csv')
input_csv = response['Body'].read().decode('utf-8').splitlines()
csv_reader = csv.DictReader(input_csv)
# Initialize the output CSV file
output_csv = []
# Process each row of the input CSV to generate mappings with FIGI code
for row in csv_reader:
# Initialize the FIGI request with the CUSIP/ISIN symbol
request = [{'idType': 'ID_CUSIP', 'idValue': row['CUSIP']},
{'idType': 'ID_ISIN', 'idValue': row['ISIN']}]
# Perform the FIGI lookup
response = figi_client.mapping(request)
# Extract the relevant FIGI code from the response
figi_code = response[0]['data'][0]['figi']
# Add to the output CSV
output_csv.append({'CUSIP': row['CUSIP'], 'ISIN': row['ISIN'], 'FIGI': figi_code})
# Write the output CSV file to S3 bucket Y
csv_filename = 'output.csv'
csv_data = '\n'.join([','.join(row.values()) for row in output_csv])
s3_client.put_object(Bucket='corp-action-output', Key=csv_filename, Body=csv_data)
# Return a success response
return {
'statusCode': 200,
'body': 'Successfully generated mapping with FIGI code.'
}
Can someone please help?
Hi,
I am trying to pull in mapping data for Govt
bonds that have not matured:
{
'idType': 'BASE_TICKER',
'idValue': 'DGB',
'securityType2': 'Govt',
'maturity': ['2019-11-22', null]
}
As described in the documentation, this only gives me bonds with a maturity between 2019-11-22 and 2020-11-22.
Two questions I have:
maturity
array as an "after/before pair", so it is easy to get all un-matured bonds for a BASE_TICKER
as-of a certain date if before is left null
?Thanks!
Hi,
we are successfully pulling back option data using the ID_EXCH_SYMBOL as the key.
With a small number of instruments, we're unsure what the exchange symbol should be, though we happen to have some contract-level Bloomberg values that we can find an example contract with.
For example, we can pull back the contract we need using an ID_FULL_EXCHANGE_SYMBOL value of "GE3M9 C9675". However, the ID_EXCH_SYMBOL for that contract's instrument is not included in the results. Please could you tell me if there is a way to find it? We need the ID_EXCH_SYMBOL value so we can fetch data where we don't already have the Bloomberg or trading system code (and where we specify other information such as the strike price with separate attributes).
We have already tried what we think the exchange calls our example instruments without luck. I hope this makes sense but in summary we need to fetch ID_EXCH_SYMBOL amongst the results please.
Thanks,
Tristan
The following request:
[ { "idType": "ID_BB_GLOBAL", "idValue": "BBG000F0PF65" } ]
Results in:
[ { "error": "No identifier found." } ]
Yet I am positive this is a valid FIGI for TWX US Equity which was acquired by T US on 2018/06/15. What the point of a global identifier that never changes if you can't retrieve the values via the API? My Bloomberg terminal seems to have no issue looking up this data.
Is there any example mapping a figi code to the company website/homepage/url?
Hello,
Is it possible to return the OCC Symbol and OPRA Symbol on API?
Thanks
I am curious if this API can be used within Google Sheets via the script editor? There is a class called UrlFetchApp provided by Apps Script which allows one to communicate with hosts across the internet and am curious if this API would work with that?
My use case is that I have a list of securities and their corresponding CUSIPs and want to use that as the key to find the correct ticker with the API. I'm using this as a learning project for myself to better understand how to use APIs so please bear with me if this seems quite basic.
Thanks in advance!
You maintain the ISIN, SEDOL, CUSIP on an instrument (because we can search by it), why not return this as part of the response and have a more complete lookup solution?
Ok, so here is the sample code that I am working with:
curl --location --request POST 'https://api.openfigi.com/v2/search' \
--header 'Content-Type: application/json' \
--data-raw '{
"query": "ibm",
"exchCode":"US",
"securityType": "Common Stock"
}'
I would like to be able to search for multiple security types with a single API call. Such as:
curl --location --request POST 'https://api.openfigi.com/v2/search' \
--header 'Content-Type: application/json' \
--data-raw '{
"query": "ibm",
"exchCode":"US",
"securityType": ["Common Stock","Mutual Fund"]
}'
Or even across multiple exchCode
s, like something like this:
curl --location --request POST 'https://api.openfigi.com/v2/search' \
--header 'Content-Type: application/json' \
--data-raw '{
"query": "ibm",
"exchCode":["CHICAGO", "NASDAQ", "NEW YORK", "NYSE AMERICAN", "OTC US", "OTC BB", "PINK SHEETS", "TORONTO", "US"],
"securityType": ["Common Stock","Mutual Fund"]
}'
Right now, as I see it, I would have to do an API call for every iteration of exchCode
and securityType
and then combine the results, which could take a significant number of api calls. Is there some way to be able to do this as a single API call?
I would like to see an example of how to pull the FIGI in Stata. Thank you!
I work in ETDs and I'm trying to pass an expiration date (or maturity date) using an adaption of the C# example project. I've added strike and optionType attributes successfully but I can't seem to get either a maturityDate or expirationDate working. Anyone have working JSON for this? I get an HTTP500 from OpenFigi, with no detail on the error server side.
This JSON fails:
{"idType":"ID_EXCH_SYMBOL","idValue":"SNAP","exchCode":"US","optionType":"Put","securityType":"Equity Option","securityType2":"Option","expiration":["2018-01-19","2018-01-19"],"strike":[12.0,12.5]}]
(as does the similar version with expirationDate)
...but this JSON, without a maturityDate or expirationDate filter succeeds.
{"idType":"TICKER","idValue":"SNAP 01/19/18 P12.5","exchCode":"US","marketSecDes":"Equity","optionType":"Put","securityType":"Equity Option"},{"idType":"ID_EXCH_SYMBOL","idValue":"SNAP","exchCode":"US","optionType":"Put","securityType2":"Option","strike":[12.0,12.0]}
Any working JSON for options (or even futures) with a working maturityDate or expirationDate attribute please?
Thanks in advance.
Hello,
May I find please a C/C++ sample code using Open-FIGI/api ?
Thanks,
Marwen.
As described here:
https://en.wikipedia.org/wiki/OpenAPI_Specification
and championed here..
https://www.openapis.org/
This would allow the API to be used by Microsoft PowerApp connectors without custom code as well as opening up connection to PowerBI
Thanks in advance for your effort!
M
I would like to see an example of how to pull the FIGI for a list of ticker symbols in matlab. Thank you!
ResponseWriter::operator() incorrectly assumes that the input data is null terminated, leading to garbage being written in the result string. example of a correctly working implementation:
class ResponseWriter {
public:
const std::string& response() {
return resp;
}
size_t operator() (curlpp::Easy *handle, char* ptr, size_t size_always_1, size_t nmemb) {
resp.append(ptr,ptr+nmemb);
return nmemb;
}
private:
std::string resp;
};
I have seen on https://www.openfigi.com/api#get-schema that there is an endpoint (GET https://api.openfigi.com/schema) for getting the OpenAPI specification. However, this specification is for v1. I am wondering if there is an OpenAPI specification available for v3.
I have just seen that the spec I mentioned above already contains v3 (such as in descriptions and the base path). However, the two endpoints
POST /v3/search
POST /v3/filter
are missing.
Hello,
Thank you for your hard work. I notice you can pass an ISIN as a valid query ID but ISIN is not returned by the api, is it possible to return ISIN as a field?
Hello! Im trying to understand if it's possible to find the FIGI of an Issuer from the FIGI of a bond?
Ive a list of bond FIGI that need to figure out who's the issuer for.
I'm new to the API so apologies for the basic question. I would like to try the search endpoint working and cannot find any example code in this repo or elsewhere online. I had assumed this would just require changing the openfigi_url =
line to look like openfigi_url = 'https://api.openfigi.com/v2/search'
but that throws an HTTP Error 400: Bad Request message.
How should I use this endpoint? Related, does the search method look inside of all fields or only the ticker field? The example on the openfigi project page only shows matches on ticker.
Hi,
I am trying to get more information from OpenFigi on bonds. When I used the symbol provided by the ETF in OpenFigi Quick Search, it shows up.
But when I try to get it using the API, it can't find it. Could someone help me with this? Thanks a lot!
job = {
"query": "BY7RB31"
}
handler = urllib.request.HTTPHandler()
opener = urllib.request.build_opener(handler)
openfigi_url = 'https://api.openfigi.com/v2/search'
request = urllib.request.Request(openfigi_url, data=bytes(json.dumps(job), encoding='utf-8'))
request.add_header('Content-Type','application/json')
if openfigi_apikey:
request.add_header('X-OPENFIGI-APIKEY', openfigi_apikey)
request.get_method = lambda: 'POST'
connection = opener.open(request)
if connection.code != 200:
raise Exception('Bad response code {}'.format(str(response.status_code)))
res = json.loads(connection.read().decode('utf-8'))
print(res)
>>{'data': []}
Hello,
Is there a way to provide an identifier (e.g. an ISIN for IBM) and ask for only the primary listing to be returned?
Thanks
OpenFigi now apparently requires Tls12 to be set; this isn't the default in .NET
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
The test code doesn't work unless this is included.
Context: Client application with authenticated with API key.
2 issues with requests having couple thousands results:
next
contains 0 symbols. See BLOCK A in the sample response.Request
https://api.openfigi.com/v3/filter
parameters: {
"micCode": "XNMS",
"marketSecDes": "Equity"
}
Sample response
.... **BLOCK A**
<Response [200 OK]>
{'data': [{'figi': 'BBG00W9MJKF0', 'name': 'GEMINI THERAPEUTICS INC', 'ticker': 'GMTX', 'exchCode': 'UQ', 'compositeFIGI': 'BBG00W9MJK79', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG00W9MJL04', 'securityType2': 'Common Stock', 'securityDescription': 'GMTX'}, {'figi': 'BBG00WBPG4K3', 'name': 'HARMONY BIOSCIENCES HOLDINGS', 'ticker': 'HRMY', 'exchCode': 'UQ', 'compositeFIGI': 'BBG00WBPG4C2', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG00WBPG548', 'securityType2': 'Common Stock', 'securityDescription': 'HRMY'}, {'figi': 'BBG00WFBY5R0', 'name': 'NANO-X IMAGING LTD', 'ticker': 'NNOX', 'exchCode': 'UQ', 'compositeFIGI': 'BBG00RDSZ6J2', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG00RDSZ6K0', 'securityType2': 'Common Stock', 'securityDescription': 'NNOX'}, {'figi': 'BBG00WFDP0Q8', 'name': 'KYMERA THERAPEUTICS INC', 'ticker': 'KYMR', 'exchCode': 'UQ', 'compositeFIGI': 'BBG00SDHC8D1', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG00SDHC8F9', 'securityType2': 'Common Stock', 'securityDescription': 'KYMR'}, {'figi': 'BBG00WRF65R9', 'name': 'UNIVERSE PHARMACEUTICALS INC', 'ticker': 'UPC', 'exchCode': 'UQ', 'compositeFIGI': 'BBG00WRF65K6', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG00WRF66B4', 'securityType2': 'Common Stock', 'securityDescription': 'UPC'}, {'figi': 'BBG00WWF0QQ4', 'name': 'FUSION FUEL GREEN PLC-A', 'ticker': 'HTOO', 'exchCode': 'UQ', 'compositeFIGI': 'BBG00VZRQFB9', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG00VZRQFC8', 'securityType2': 'Common Stock', 'securityDescription': 'HTOO'}, {'figi': 'BBG00WXXSW36', 'name': 'METACRINE INC', 'ticker': 'MTCR', 'exchCode': 'UQ', 'compositeFIGI': 'BBG009R3Z5S4', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG009R3Z5T3', 'securityType2': 'Common Stock', 'securityDescription': 'MTCR'}], 'next': 'QW9Fc1FrSkhNREJYV0ZoVFZ6Y3kgNjM=.KvA7GTys1c3Zxh2r/FreUfqgnuD7W/cYqJzZ4hFSFGY=', 'total': 7942}
<Response [200 OK]>
{'data': [], 'next': 'QW9Fc1FrSkhNREJZTVUweE1EZzMgNjQ=.fnXeVH+PcwPBN4SB3dR4NprYeTKGfJ8ej1zN3KXyp1g=', 'total': 7942}
<Response [200 OK]>
{'data': [], 'next': 'QW9Fc1FrSkhNREJZTVZBeE1FZ3cgNjU=.TADybkuQWKQG1yIR7E3lPIpLoOIQYHJBW7rSCuMYf7Y=', 'total': 7942}
<Response [200 OK]>
{'data': [], 'next': 'QW9Fc1FrSkhNREJZTVZBNFExTTEgNjY=.CLHeR7D9w1bmO9WLk+X4mwni2uojjBmcrWMnvvSEe9Q=', 'total': 7942}
<Response [200 OK]>
{'data': [], 'next': 'QW9Fc1FrSkhNREJZTVZCS1dsTXkgNjc=.pihvjZW8EhBBabqlXASKoFFjXLqidZdPY+W//er0rOQ=', 'total': 7942}
<Response [200 OK]>
{'data': [], 'next': 'QW9Fc1FrSkhNREJZTVZFNFNEQXkgNjg=.gTtTZBMl463PaCXlHf9SfhZKWnuiWxAQtDlqJeOq0Rs=', 'total': 7942}
<Response [200 OK]>
{'data': [], 'next': 'QW9Fc1FrSkhNREJZTVZOR05GRXggNjk=.Qd320bMU4Y+1QCJKYmVlFsnr3m1lpXI0aqEfVP3DXLY=', 'total': 7942}
<Response [200 OK]>
{'data': [], 'next': 'QW9Fc1FrSkhNREJZTVZOUVZESXggNzA=.0l/a/5QmFr8uMzl81LDQfemmgrOliOjf9A0ONqUdrRI=', 'total': 7942}
<Response [200 OK]>
{'data': [], 'next': 'QW9Fc1FrSkhNREJZTVZOYVdWUXcgNzE=.teWblLvOQLezxXgW3IMxKGjfEPiWkhwsT9d5yJwPv8Q=', 'total': 7942}
<Response [200 OK]>
{'data': [{'figi': 'BBG00X3GR1T5', 'name': 'SUMMIT THERAPEUTICS INC', 'ticker': 'SMMT', 'exchCode': 'UQ', 'compositeFIGI': 'BBG00X3GQL76', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG00X3GQL94', 'securityType2': 'Common Stock', 'securityDescription': 'SMMT'}, {'figi': 'BBG00X5FVRL1', 'name': 'GRAYBUG VISION INC', 'ticker': 'GRAY', 'exchCode': 'UQ', 'compositeFIGI': 'BBG0088HHJ97', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG0088HHJB4', 'securityType2': 'Common Stock', 'securityDescription': 'GRAY'}, {'figi': 'BBG00X5FXL69', 'name': 'PMV PHARMACEUTICALS INC', 'ticker': '1202456D', 'exchCode': 'UQ', 'compositeFIGI': 'BBG00X5FXL05', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG007NM4862', 'securityType2': 'Common Stock', 'securityDescription': '1202456D'}, {'figi': 'BBG00X9DZT61', 'name': 'ONCORUS INC', 'ticker': 'ONCR', 'exchCode': 'UQ', 'compositeFIGI': 'BBG00DDYJ7N1', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG00DDYJ7P9', 'securityType2': 'Common Stock', 'securityDescription': 'ONCR'}, {'figi': 'BBG00XCD19L1', 'name': 'AZIYO BIOLOGICS INC-CLASS A', 'ticker': 'AZYO', 'exchCode': 'UQ', 'compositeFIGI': 'BBG00BRBB838', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG00BRBB847', 'securityType2': 'Common Stock', 'securityDescription': 'AZYO'}, {'figi': 'BBG00XK4JQH0', 'name': 'ARRAY TECHNOLOGIES INC', 'ticker': 'ARRY', 'exchCode': 'UQ', 'compositeFIGI': 'BBG001V4SF46', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG002MX7TQ9', 'securityType2': 'Common Stock', 'securityDescription': 'ARRY'}], 'next': 'QW9Fc1FrSkhNREJZU3pSS1VWTTQgNzI=.g74pWALMBSGKBB4xxSj8BlmLN+DU6Iye+DanzjJT9UQ=', 'total': 7942}
.... **BLOCK B**
{'data': [{'figi': 'BBG011CK9Q65', 'name': 'OCEAN BIOMEDICAL INC', 'ticker': 'OCEA', 'exchCode': 'UQ', 'compositeFIGI': 'BBG011CK9Q01', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG011CK9QV7', 'securityType2': 'Common Stock', 'securityDescription': 'OCEA'}, {'figi': 'BBG011DY3218', 'name': 'SERA PROGNOSTICS INC', 'ticker': 'SERA', 'exchCode': 'UQ', 'compositeFIGI': 'BBG001J19ZJ7', 'securityType': 'Common Stock', 'marketSector': 'Equity', 'shareClassFIGI': 'BBG001V0FR24', 'securityType2': 'Common Stock', 'securityDescription': 'SERA'}], 'total': 7942}
Your API is good but the data is not that reliable - Figi is meant to be unique, however, I have found quite a few securities that have two figis - For example
figi: BBG000CX7XG6
figi: BBG000CX7XX7
These are linked to the same exact security - how can we tell from the API result which is the correct figi to use
for example, I input FIGI and get cusip and sedol return
I am getting a error like acces-control-allow-origin header is not present in the requested resource , I am trying to request this api from my angular project .
Hi,
Is it possible to get third party identifier (eg. CUSIP) from FIGI using the API?
Thanks a lot!
Im using openfigi to get symbol from isin. It works great, exept it returns the ticker symbol without any whitespace. See following example
ISIN: SE0000115446 // volvo b stocks
OpenFIGI gives 'VOLVB'
Correct symbol should be 'VOLV B'
What am I missing here?
Sending this:
.\curl -X POST 'https://api.openfigi.com/v1/mapping' -k -H 'Content-Type: text/json' -H 'api_key_here' --data '[{"idType":"ID_WERTPAPIER","idValue":"851399","exchCode":"US"}]'
And getting back:
Request body must be a valid JSON array.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.