# 💰 NseIndiaApi
An unofficial Python API for the NSE India stock exchange.
Python version: >= 3.8
If you ❤️ my work so far, please 🌟 this repo.
## 👽 Documentation
[https://bennythadikaran.github.io/NseIndiaApi](https://bennythadikaran.github.io/NseIndiaApi)
## Updates
**v0.2.8:** Add methods for listing upcoming, current and past IPOs. [See Docs](https://bennythadikaran.github.io/NseIndiaApi/usage.html#list-ipos)
## 🔥 Usage
**Install with Pip**
```bash
pip install -U nse
```
The class accepts a single argument `download_folder`, a `str` filepath, or a `pathlib object`. The folder stores cookie and any downloaded files.
**Simple example**
```python
from nse import NSE
from pathlib import Path
# Working directory
DIR = Path(__file__).parent
nse = NSE(download_folder=DIR)
status = nse.status()
advDec = nse.advanceDecline()
nse.exit() # close requests session
```
**Using with statement**
```python
with NSE(download_folder=DIR) as nse:
status = nse.status()
advDec = nse.advanceDecline()
```
**Catching errors**
```python
from nse import NSE
from datetime import datetime
with NSE('./') as nse:
try:
bhavFile = nse.equityBhavcopy(date=datetime.now())
dlvFile = nse.deliveryBhavcopy(date=datetime.now())
raise RuntimeError('Some error') # force an exception
except RuntimeError as e:
# continue execution or exit the script
print(repr(e))
# execution continues if handled without exit
actions = nse.actions()
# NSE request session closed - continue processing
```
## Samples folder
The `src/samples` folder contains sample outputs of various methods. The filenames match the method names. The output has been truncated in some places but demonstrates the overall structure of responses.
Raw data
{
"_id": null,
"home_page": null,
"name": "nse",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "nse, nse-stock-data, stock-market-api, stock-news-api",
"author": "Benny Thadikaran",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/4c/95/d8c3344ef747bc517c92e0c912e330fad79cc5ce89b8135c43a52a76b66e/nse-0.2.9.tar.gz",
"platform": null,
"description": "# \ud83d\udcb0 NseIndiaApi\n\nAn unofficial Python API for the NSE India stock exchange.\n\nPython version: >= 3.8\n\nIf you \u2764\ufe0f my work so far, please \ud83c\udf1f this repo.\n\n## \ud83d\udc7d Documentation\n\n[https://bennythadikaran.github.io/NseIndiaApi](https://bennythadikaran.github.io/NseIndiaApi)\n\n## Updates\n\n**v0.2.8:** Add methods for listing upcoming, current and past IPOs. [See Docs](https://bennythadikaran.github.io/NseIndiaApi/usage.html#list-ipos)\n\n## \ud83d\udd25 Usage\n\n**Install with Pip**\n\n```bash\npip install -U nse\n```\n\nThe class accepts a single argument `download_folder`, a `str` filepath, or a `pathlib object`. The folder stores cookie and any downloaded files.\n\n**Simple example**\n\n```python\nfrom nse import NSE\nfrom pathlib import Path\n\n# Working directory\nDIR = Path(__file__).parent\n\nnse = NSE(download_folder=DIR)\n\nstatus = nse.status()\n\nadvDec = nse.advanceDecline()\n\nnse.exit() # close requests session\n```\n\n**Using with statement**\n\n```python\nwith NSE(download_folder=DIR) as nse:\n status = nse.status()\n\n advDec = nse.advanceDecline()\n```\n\n**Catching errors**\n\n```python\nfrom nse import NSE\nfrom datetime import datetime\n\nwith NSE('./') as nse:\n try:\n bhavFile = nse.equityBhavcopy(date=datetime.now())\n dlvFile = nse.deliveryBhavcopy(date=datetime.now())\n raise RuntimeError('Some error') # force an exception\n except RuntimeError as e:\n # continue execution or exit the script\n print(repr(e))\n\n # execution continues if handled without exit\n actions = nse.actions()\n\n# NSE request session closed - continue processing\n```\n\n## Samples folder\n\nThe `src/samples` folder contains sample outputs of various methods. The filenames match the method names. The output has been truncated in some places but demonstrates the overall structure of responses.\n",
"bugtrack_url": null,
"license": null,
"summary": "Unofficial Python Api for NSE India stock exchange",
"version": "0.2.9",
"project_urls": {
"Bug Tracker": "https://github.com/BennyThadikaran/NseIndiaApi/issues",
"Homepage": "https://github.com/BennyThadikaran/NseIndiaApi"
},
"split_keywords": [
"nse",
" nse-stock-data",
" stock-market-api",
" stock-news-api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f8831f6d35691c07ad07b81e810f8cb4366e120c4b260f2cb4543e5f22361e56",
"md5": "7fb7be768e3e3ccc32e79d37fc3c41ae",
"sha256": "6442d81da83e0d138c34d039dec818a47a30bd6c64391468a6fd8120c37c7395"
},
"downloads": -1,
"filename": "nse-0.2.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7fb7be768e3e3ccc32e79d37fc3c41ae",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 22343,
"upload_time": "2024-05-11T09:33:56",
"upload_time_iso_8601": "2024-05-11T09:33:56.618084Z",
"url": "https://files.pythonhosted.org/packages/f8/83/1f6d35691c07ad07b81e810f8cb4366e120c4b260f2cb4543e5f22361e56/nse-0.2.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4c95d8c3344ef747bc517c92e0c912e330fad79cc5ce89b8135c43a52a76b66e",
"md5": "e419798fff5705440aa0db8a26b300c4",
"sha256": "4086a08e4d65176b23f4c901df52c8bf6873fd8e83e53845ccd9316a8b8cf4f5"
},
"downloads": -1,
"filename": "nse-0.2.9.tar.gz",
"has_sig": false,
"md5_digest": "e419798fff5705440aa0db8a26b300c4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 23090,
"upload_time": "2024-05-11T09:33:58",
"upload_time_iso_8601": "2024-05-11T09:33:58.203463Z",
"url": "https://files.pythonhosted.org/packages/4c/95/d8c3344ef747bc517c92e0c912e330fad79cc5ce89b8135c43a52a76b66e/nse-0.2.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-11 09:33:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "BennyThadikaran",
"github_project": "NseIndiaApi",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "nse"
}