Skip to main content

Unofficial Python API Wrapper of Ncell

Project description

📞Unofficial Python API Wrapper of Ncell

NcellPy

Stars Issues Contributors

This is the unofficial python API wrapper of Ncell App.

⚠️ Disclaimer: This project is in no way affiliated with, authorized, maintained, sponsored or endorsed by Ncell or any of its affiliates or subsidiaries. This is an independent and unofficial API. Use at your own risk.

Installation

  • Install via PyPi

    pip install ncellapp
    
  • Install from the source

    git clone https://github.com/hemantapkh/ncellapp && cd ncellapp && python setup.py sdist && pip install dist/*
    

Note: You may need to change the pip to pip3 or python to python3 on the above command depending on your system.

Start guide

Quick Examples

1. Getting a Token

>>> from ncellapp import register

>>> reg = register('98140*****')
>>> reg.generateOtp()
<Response [OTP1000]>
>>> reg.validateOtp('569845')
<Response [OTP1000]>
>>> reg.token
'eyJt...'

2. Viewing the balance

>>> from ncellapp import ncell

>>> account = ncell(token='eyJtc...', autoRefresh=True)
>>> balance = account.balance()
>>> balance.content
{'queryBalanceResponse': {'smsBalanceList': [], 'dataBalanceList': [], 'creditBalanceDetail': {'expiryDate': 'Sep 12 2021 23:59:59', 'freeSmsCount': 10, 'tariffPlanRateOffNet': 0.0, 'balance': 4.89793, 'unBilledAmount': 0.0, 'tariffPlanName': 'Sajilo', 'lastLoanTakenDate': 'Mar 23 2021 08:22:54', 'lastRechargeDate': 'Apr 27 2021 00:36:58', 'loanAmount': 0.0, 'creditUom': 'Rs.', 'tariffPlanRateOnNet': 0.0}, 'msisdn': '98140*****', 'voiceBalanceList': [], 'paidMode': 'Prepaid'}}

3. Sending a free SMS

>>> sms = account.sendFreeSms(980799****, 'Hey there!, I am sending you an SMS with Python!')
>>> sms.content
{'sendFreeSMSResponse': {'description': 'Operation succeeded', 'status': 'success', 'statusCode': '0'}}
>>> sms.responseHeader
{'responseDesc': 'Success', 'requestId': '1626770987071NCELL968', 'responseDescDisplay': 'SMS1000', 'responseCode': '200', 'timestamp': '2021-07-20T14:34:47.12712'}

4. Manually refreshing the token and storing the refreshed token (Not recommended)

# This function will be executed after refreshing the token
>>>def storeToken(token):
...     with open('token','w') as f_in:
...         f_in.write(token)

# Creating an object of ncell which contains 'afterRefresh' and 'args' arguments.
# See the documentation for more information.
>>> ac = ncellapp.ncell(token=token, afterRefresh=[__name__, 'storeToken'], args=['__token__'])

# Token expired
>>> ac.balance()
<Response [LGN2001]>

# Manually refreshing the token
>>> ac.refreshToken()
<Response [OTP1000]>

# Viewing the balance after manually refreshing the token
>>> ac.balance()
<Response [BAL1000]>

5. Refreshing the token automatically and storing the refreshed Token (Recommended)

# This function will be executed after refreshing the token.
>>>def storeToken(token):
    with open('token','w') as f_in:
        f_in.write(token)

# Creating an object of ncell and setting autoRefresh=True. 
# See documentation for more information.
>>> ac = ncellapp.ncell(token=token, autoRefresh=True, afterRefresh=[__name__, 'storeToken'], args=['__token__'])

# Token will be refreshed and stored automatically if it expires
>>> ac.balace()
<Response [BAL1000]>

Detailed documentation

The documentation of ncellapp is available here.

Contributing

Any contributions you make are greatly appreciated.

For minor fix, you can directly create a pull request and for adding a new feature, let's first discuss about it.

Thanks to every contributors who have contributed in this project.

License

Distributed under the MIT License. See LICENSE for more information.


Author/Maintainer: Hemanta Pokharel

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ncellapp-2.0.2.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ncellapp-2.0.2-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file ncellapp-2.0.2.tar.gz.

File metadata

  • Download URL: ncellapp-2.0.2.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ncellapp-2.0.2.tar.gz
Algorithm Hash digest
SHA256 265efd409344f24d7817438b7ef3eed915212dd420e113e5f9d0ee7ac9ff531e
MD5 304267b6ae512524e37ee170f503b613
BLAKE2b-256 6a5e13e5a68e36b77b30bbec185391dd545e91dda8a5ef0393c71118c33478d2

See more details on using hashes here.

File details

Details for the file ncellapp-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: ncellapp-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ncellapp-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6c373cc0f5c8f01f0c6951d4e5226105865d4b7e23cf152f59cb32819a0abcfa
MD5 8dd8ac230274aa049ef429cbeba9892b
BLAKE2b-256 b5ca56b0c5458c7067e477614a912816b285bcf5025ba31a2e57addb929e7e5d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page