Name | pyopenfigi JSON |
Version |
0.0.2
JSON |
| download |
home_page | |
Summary | Unofficial Python wrapper for the OpenFIGI API |
upload_time | 2023-04-25 14:18:09 |
maintainer | |
docs_url | None |
author | tlouarn |
requires_python | >=3.10 |
license | MIT License Copyright (c) [2023] [tlouarn] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
openfigi
api
bloomberg
figi
python
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# PyOpenFigi
Unofficial Python wrapper for the [OpenFIGI API](https://www.openfigi.com/api) v3.
The wrapper is build with `requests` for HTTP requests and `Pydantic` for object modeling.
## API description
The OpenFIGI API can be used with or without API key.
Getting an API key is free and loosens the [rate limits](https://www.openfigi.com/api#rate-limit).
| endpoint | description |
|----------|--------------------------------------------------------------------------------------------|
| mapping | Map third-party identifiers to FIGIs |
| search | Search for FIGIs using keywords and optional filters |
| filter | Search for FIGIs using keywords and optional filters (contains the total number of results |
## Installation
PyOpenFigi is published on PyPi. To install it, simply run:
```commandline
pip install pyopenfigi
```
## Usage
### The `mapping` endpoint
Maps third-party identifiers to FIGIS.
The method takes a list of `MappingJob` objects as argument and returns a list of `MappingJobResult`. The result of
the request located at index i in the list of mapping jobs is located at index i in the list of results.
```python
from pyopenfigi import OpenFigi, MappingJob
mapping_job = MappingJob(id_type="TICKER", id_value="IBM", exch_code="US")
mapping_jobs = [mapping_job]
results = OpenFigi().map(mapping_jobs)
```
```commandline
>>> results
[MappingJobResultFigiList(data=[FigiResult(figi='BBG000BLNNH6', security_type='Common Stock', market_sector='Equity', ticker='IBM', name='INTL BUSINESS MACHINES CORP', exch_code='US', share_class_figi='BBG001S5S399', composite_figi='BBG000BLNNH6', security_type2='Common Stock', security_description='IBM', metadata=None)])]
```
### The `MappingJob` object
The `MappingJob` object only has 2 required fields which are `id_type` and `id_value`. The other fields are optional
but subject to specific rules in case they are provided. The rules are modeled with `Pydantic`.
There is a list of examples for common use cases.
### The _Enum-like_ properties
Some of the properties in the `MappingJob` objects are "enum-like". For each of these properties, it is possible to
retrieve the current list of accepted values via specific methods:
| property | method | description |
|-----------------|--------------------------|-------------|
| id_type | `get_id_types()` | |
| exch_code | `get_exch_codes()` | |
| mic_code | `get_mic_codes()` | |
| currency | `get_currencies()` | |
| market_sec_des | `get_market_sec_des()` | |
| security_type | `get_security_types()` | |
| security_type_2 | `get_security_types_2()` | |
| state_code | `get_state_codes()` | |
### The `filter` endpoint
Note: max 15000 results (all US tickers)
## Troubleshooting
### Exceptions
Several kinds of errors can occur.
The `MappingJob` and `Query` are modeled as *Pydantic* objects and therefore need to be properly instantiated.
If an error occurs, a `ValidationError` from *Pydantic* will be raised.
In case these objects are instantiated programmatically, it could be worth checking for exceptions as follows:
```python3
from pydantic import ValidationError
from pyopenfigi import MappingJob
tickers = ["IBM", "XRX", "TSLA", None, "MSFT"]
mapping_jobs = []
for ticker in tickers:
try:
mapping_job = MappingJob(id_type="TICKER", id_value=ticker, exch_code="US")
mapping_jobs.append(mapping_job)
except ValidationError:
print(f"Error when trying to build a MappingJob with {ticker=}")
continue
```
In case the status code of the HTTP response is not 200, an HTTPError exception will be raised.
```python
from pyopenfigi import OpenFigi
from pyopenfigi.exceptions import HTTPError
try:
results = OpenFigi().map(mapping_jobs)
except HTTPError as e:
print(f"{e}")
```
Raw data
{
"_id": null,
"home_page": "",
"name": "pyopenfigi",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "openfigi,api,bloomberg,figi,python",
"author": "tlouarn",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/e2/fc/7100c8859c239a0ea9d03b5fc311a228ca5ad871042020b09f55920ca4d9/pyopenfigi-0.0.2.tar.gz",
"platform": null,
"description": "# PyOpenFigi\r\n\r\nUnofficial Python wrapper for the [OpenFIGI API](https://www.openfigi.com/api) v3.\r\n\r\nThe wrapper is build with `requests` for HTTP requests and `Pydantic` for object modeling.\r\n\r\n## API description\r\n\r\nThe OpenFIGI API can be used with or without API key.\r\nGetting an API key is free and loosens the [rate limits](https://www.openfigi.com/api#rate-limit).\r\n\r\n| endpoint | description |\r\n|----------|--------------------------------------------------------------------------------------------|\r\n| mapping | Map third-party identifiers to FIGIs |\r\n| search | Search for FIGIs using keywords and optional filters |\r\n| filter | Search for FIGIs using keywords and optional filters (contains the total number of results |\r\n\r\n## Installation\r\n\r\nPyOpenFigi is published on PyPi. To install it, simply run:\r\n\r\n```commandline\r\npip install pyopenfigi\r\n```\r\n\r\n## Usage\r\n\r\n### The `mapping` endpoint\r\n\r\nMaps third-party identifiers to FIGIS.\r\nThe method takes a list of `MappingJob` objects as argument and returns a list of `MappingJobResult`. The result of\r\nthe request located at index i in the list of mapping jobs is located at index i in the list of results.\r\n\r\n```python\r\nfrom pyopenfigi import OpenFigi, MappingJob\r\n\r\nmapping_job = MappingJob(id_type=\"TICKER\", id_value=\"IBM\", exch_code=\"US\")\r\nmapping_jobs = [mapping_job]\r\nresults = OpenFigi().map(mapping_jobs)\r\n```\r\n```commandline\r\n>>> results\r\n[MappingJobResultFigiList(data=[FigiResult(figi='BBG000BLNNH6', security_type='Common Stock', market_sector='Equity', ticker='IBM', name='INTL BUSINESS MACHINES CORP', exch_code='US', share_class_figi='BBG001S5S399', composite_figi='BBG000BLNNH6', security_type2='Common Stock', security_description='IBM', metadata=None)])]\r\n```\r\n\r\n### The `MappingJob` object\r\n\r\nThe `MappingJob` object only has 2 required fields which are `id_type` and `id_value`. The other fields are optional\r\nbut subject to specific rules in case they are provided. The rules are modeled with `Pydantic`.\r\n\r\nThere is a list of examples for common use cases.\r\n\r\n### The _Enum-like_ properties\r\n\r\nSome of the properties in the `MappingJob` objects are \"enum-like\". For each of these properties, it is possible to\r\nretrieve the current list of accepted values via specific methods:\r\n\r\n| property | method | description |\r\n|-----------------|--------------------------|-------------|\r\n| id_type | `get_id_types()` | |\r\n| exch_code | `get_exch_codes()` | |\r\n| mic_code | `get_mic_codes()` | |\r\n| currency | `get_currencies()` | |\r\n| market_sec_des | `get_market_sec_des()` | |\r\n| security_type | `get_security_types()` | |\r\n| security_type_2 | `get_security_types_2()` | |\r\n| state_code | `get_state_codes()` | |\r\n\r\n### The `filter` endpoint\r\n\r\nNote: max 15000 results (all US tickers)\r\n\r\n## Troubleshooting\r\n\r\n### Exceptions\r\n\r\nSeveral kinds of errors can occur.\r\n\r\nThe `MappingJob` and `Query` are modeled as *Pydantic* objects and therefore need to be properly instantiated. \r\nIf an error occurs, a `ValidationError` from *Pydantic* will be raised. \r\nIn case these objects are instantiated programmatically, it could be worth checking for exceptions as follows:\r\n\r\n```python3\r\nfrom pydantic import ValidationError\r\n\r\nfrom pyopenfigi import MappingJob\r\n\r\ntickers = [\"IBM\", \"XRX\", \"TSLA\", None, \"MSFT\"]\r\n\r\nmapping_jobs = []\r\nfor ticker in tickers:\r\n try:\r\n mapping_job = MappingJob(id_type=\"TICKER\", id_value=ticker, exch_code=\"US\")\r\n mapping_jobs.append(mapping_job)\r\n except ValidationError:\r\n print(f\"Error when trying to build a MappingJob with {ticker=}\")\r\n continue\r\n```\r\n\r\nIn case the status code of the HTTP response is not 200, an HTTPError exception will be raised.\r\n\r\n```python\r\nfrom pyopenfigi import OpenFigi\r\nfrom pyopenfigi.exceptions import HTTPError\r\n\r\ntry:\r\n results = OpenFigi().map(mapping_jobs)\r\n\r\nexcept HTTPError as e:\r\n print(f\"{e}\")\r\n```\r\n\r\n\r\n\r\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) [2023] [tlouarn] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Unofficial Python wrapper for the OpenFIGI API",
"version": "0.0.2",
"split_keywords": [
"openfigi",
"api",
"bloomberg",
"figi",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b25e6475877739bad0eb9441fd8c1c5b39a9b3e44f5a11aa44908e3d0ea81058",
"md5": "fd549383ee9e69aa7d0b86f63268b3a6",
"sha256": "117f6acbe88396b81e4a0b2ddb6f3cdbbf1fe6d161bdd519997961e89b51d4cb"
},
"downloads": -1,
"filename": "pyopenfigi-0.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fd549383ee9e69aa7d0b86f63268b3a6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 9302,
"upload_time": "2023-04-25T14:18:07",
"upload_time_iso_8601": "2023-04-25T14:18:07.531802Z",
"url": "https://files.pythonhosted.org/packages/b2/5e/6475877739bad0eb9441fd8c1c5b39a9b3e44f5a11aa44908e3d0ea81058/pyopenfigi-0.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e2fc7100c8859c239a0ea9d03b5fc311a228ca5ad871042020b09f55920ca4d9",
"md5": "b81d7fbbd63a048195a801d4be10860d",
"sha256": "6077b11966db5003dc041cebcecb709318e51b24826275ddd1bce03022b5d0cc"
},
"downloads": -1,
"filename": "pyopenfigi-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "b81d7fbbd63a048195a801d4be10860d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 11214,
"upload_time": "2023-04-25T14:18:09",
"upload_time_iso_8601": "2023-04-25T14:18:09.795226Z",
"url": "https://files.pythonhosted.org/packages/e2/fc/7100c8859c239a0ea9d03b5fc311a228ca5ad871042020b09f55920ca4d9/pyopenfigi-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-25 14:18:09",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "pyopenfigi"
}