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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gst_e_invoicing-0.9.0.tar.gz
(22.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gst_e_invoicing-0.9.0.tar.gz.
File metadata
- Download URL: gst_e_invoicing-0.9.0.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9188820350293fc48edbdf879ea691c8fc9a6d0a4c260181f2ec7e3bc3cdf37
|
|
| MD5 |
9788973f28ed67b492b9658752c500e6
|
|
| BLAKE2b-256 |
33d813da917b1095ccc7240dbf4d22840fa5a1d28e220cc38ae81f2c1cce8a5e
|
File details
Details for the file gst_e_invoicing-0.9.0-py3-none-any.whl.
File metadata
- Download URL: gst_e_invoicing-0.9.0-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc2e2d4e071d2a306842b342ce421282ba9203dc306f65f1dd73dcf709c1f120
|
|
| MD5 |
4c80d1d4275fac0d2a80a3d5fd9be152
|
|
| BLAKE2b-256 |
2e0693bc58d17b422729579dbd2432bebad52d1b29073c7fa02ed4ea549df59d
|