# 💰 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/8f/64/ed83583f404e9d6f19c6f85d1d9f625f6820f2eeb4b2451e5aed0cf10492/nse-0.2.8.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.8",
"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": "a34206c34859167bb20c232f23e2ec84f4a5a48465527e00100e9bcf8c08f1ed",
"md5": "ef1f97021909414ced39de34c42007b0",
"sha256": "1438f036d235a7898a5b05d253384d515b47aebb339b1e612969f04ad58492be"
},
"downloads": -1,
"filename": "nse-0.2.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ef1f97021909414ced39de34c42007b0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 21663,
"upload_time": "2024-03-28T16:25:35",
"upload_time_iso_8601": "2024-03-28T16:25:35.808788Z",
"url": "https://files.pythonhosted.org/packages/a3/42/06c34859167bb20c232f23e2ec84f4a5a48465527e00100e9bcf8c08f1ed/nse-0.2.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8f64ed83583f404e9d6f19c6f85d1d9f625f6820f2eeb4b2451e5aed0cf10492",
"md5": "8e37268a9bea3cd53cf9a38e13e2cbf9",
"sha256": "7fe6d57a35e36e1c0590024e6966abcac46d69c8e452632951fb6dfc7765f859"
},
"downloads": -1,
"filename": "nse-0.2.8.tar.gz",
"has_sig": false,
"md5_digest": "8e37268a9bea3cd53cf9a38e13e2cbf9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 33989,
"upload_time": "2024-03-28T16:25:37",
"upload_time_iso_8601": "2024-03-28T16:25:37.631664Z",
"url": "https://files.pythonhosted.org/packages/8f/64/ed83583f404e9d6f19c6f85d1d9f625f6820f2eeb4b2451e5aed0cf10492/nse-0.2.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-28 16:25:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "BennyThadikaran",
"github_project": "NseIndiaApi",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "nse"
}