Python library for GST's E-invoicing portal
This is the python library for interacting with GST's E-invoicing portal.
Documentation
Usage
Install the library:
pip install gst-e-invoicing
Use it in your code:
from gst_irn import Session, get_invoice, get_seller_dtls
from gst_irn.codes import States
with open('public_key.pem') as f:
public_key = f.read()
session = Session(
'GSTIN',
client_id='CLIENT_ID',
client_secret='CLIENT_SECRET',
username='USERNAME',
password='PASSWORD',
public_key=public_key,
# use the sandbox url, or production url
# or pass-through APIs provided by GSPs
base_url='https://einv-apisandbox.nic.in',
)
session.generate_token()
# create invoice object
# can also use the helper functions for the same
invoice = {
"Version": "1.1",
"TranDtls": {"TaxSch": "GST", "SupTyp": "B2B"},
"DocDtls": {
"Typ": "inv",
"No": "221",
"Dt": "21/09/2021",
},
"SellerDtls": {
"Gstin": "09GSTNUMBER1Z5",
"LglNm": "PARTY NAME",
"Addr1": "Seller Address",
"Loc": "City",
"Pin": 111111,
"Stcd": States.UTTAR_PRADESH.value,
},
"BuyerDtls": {
"Gstin": "37GSTNUMBER2ZP",
"LglNm": "BUYER NAME",
"Pos": States.KOLKATA.value,
"Addr1": "Buyer Address",
"Loc": "City",
"Pin": 555555,
"Stcd": States.KOLKATA.value,
},
"ItemList": [
{
"SlNo": "1",
"IsServc": "Y",
"HsnCd": "998431",
"UnitPrice": 100,
"IgstAmt": 12,
"TotAmt": 100,
"AssAmt": 100,
"GstRt": 12.0,
"TotItemVal": 112,
}
],
"ValDtls": {"TotInvVal": 112, "AssVal": 100, "IgstVal": 12},
"EwbDtls": {"Distance": 10},
}
# submit and get the e-invoice
einvoice = session.generate_einvoice(invoice)
# access irn and qr-code
print(einvoice['Irn'])
# prints irn
# print qr-code
from gst_irn.qr import get_qr_code_image_html
qr_code_image = get_qr_code_image_html(einvoice['SignedQRCode'])
qr_code_image
# prints <img src="...">
Find the full documentation here: https://mittal-analytics.github.io/gst-e-invoicing/
Development
Setting up dev environment:
# create and activate virtual env
python3 -m venv .venv
source .venv/bin/activate
# install requirements
pip install '.[dev]'
# provide credentials
cp .env.sample .env
# edit and update the credentials in .env file
vi .env
# running tests
python -m unittest
Releasing
just release
Metadata
Release files for gst-e-invoicing 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gst_e_invoicing-0.9.0.tar.gz | 22.7 kB | Without provenance | Details for gst_e_invoicing-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gst_e_invoicing-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for gst_e_invoicing-0.9.0-py3-none-any.whl |
Total release size: 43.1 kB
Release files / gst_e_invoicing-0.9.0.tar.gz
| Download URL | gst_e_invoicing-0.9.0.tar.gz |
|---|---|
| Size | 22.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9188820350293fc48edbdf879ea691c8fc9a6d0a4c260181f2ec7e3bc3cdf37
|
|
BLAKE2b-256 checksum How to use checksums |
33d813da917b1095ccc7240dbf4d22840fa5a1d28e220cc38ae81f2c1cce8a5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / gst_e_invoicing-0.9.0-py3-none-any.whl
| Download URL | gst_e_invoicing-0.9.0-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc2e2d4e071d2a306842b342ce421282ba9203dc306f65f1dd73dcf709c1f120
|
|
BLAKE2b-256 checksum How to use checksums |
2e0693bc58d17b422729579dbd2432bebad52d1b29073c7fa02ed4ea549df59d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for gst-e-invoicing 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.