Skip to main content

No project description provided

Project description

NcellAPI (Unofficial)

NcellAPI is am unofficial Python wrapper for the Ncell API, providing a convenient way to interact with Ncell's services such as checking balance, usage details, free SMS quota, and sending SMS. This library aims to simplify the process of making authenticated requests and handling responses from the Ncell API.

Disclaimer

This library is not affiliated with, endorsed by, or supported by Ncell. Use it at your own risk. The developers of this library are not responsible for any misuse, damage, or issues that may arise from using this software. Always comply with Ncell's terms of service and policies.

Features

  • Login and session management
  • Query account balance
  • Get usage details
  • Check free SMS quota
  • Send SMS
  • Validate SMS before sending
  • Pydantic model support for response validation
  • Conversion of responses to dictionary format

Installation

Installing from PyPI:

pip install ncellapi

Installing from the source

  1. Clone the Repository:
git clone https://github.com/ashishkandu/ncellapi.git

2.Install Poetry: If you don't have Poetry installed, you can install it using the following command:

curl -sSL https://install.python-poetry.org | python3 -
  1. Install Dependencies and the Package: Navigate to the project directory and install the dependencies and the package using Poetry:
cd ncellapi
poetry install
  1. Activate the Virtual Environment: Poetry creates a virtual environment for the project. You can activate it using the following command:
poetry shell
  1. Run Your Code:

Once the virtual environment is activated, you can run your code or scripts that use the ncellapi package.

Usage

Here's an example of how to use the NcellAPI library:

from ncellapi import Ncell

# Initialize the API with your credentials
ncell = Ncell(msisdn=1234567890, password='your_password')

# Login to the Ncell system
login_response = ncell.login()
print(login_response.to_dict())

# Check balance
balance_response = ncell.balance()
print(balance_response.to_dict())

# Get usage details
usage_detail_response = ncell.usage_details()
print(usage_detail_response.to_dict())

# Check free SMS quota
sms_count_response = ncell.free_sms_count()
print(sms_count_response.to_dict())

# Send SMS
send_sms_response = ncell.send_sms(recipient_mssidn=9876543210, message='Hello, this is a test message.')
print(send_sms_response.to_dict())

Documentation

Initialization

from ncellapi import Ncell, InvalidCredentialsError

try:
    ncell = Ncell(msisdn, password)
except InvalidCredentialsError as e:
    print(f"Invalid credentials: {e}")
  • msisdn: Your Ncell mobile number.
  • password: Your Ncell account password.

Login

from ncellapi import NetworkError

try:
    login_response = ncell.login()
    print(login_response.to_dict())
except NetworkError as e:
    print(f"Network error: {e}")

Check Balance

balance_response = ncell.balance()

Get Usage Details

usage_detail_response = ncell.usage_details()

Check Free SMS Quota

sms_count_response = ncell.free_sms_count()

Send SMS

send_sms_response = ncell.send_sms(recipient_mssidn, message, send_time)
  • recipient_mssidn: The recipient's mobile number.
  • message: The message to be sent.
  • send_time: (Optional) The time to send the message.

Handling Errors

The library raises InvalidCredentialsError for invalid credentials and NetworkError for network-related issues. Other errors are logged and handled within the response objects.

from ncellapi import NetworkError

try:
    balance_response = ncell.balance()
    print(balance_response.to_dict())
except NetworkError as e:
    print(f"Network error: {e}")

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any issues or questions, please open an issue on GitHub.

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

ncellapi-0.2.1.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

ncellapi-0.2.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file ncellapi-0.2.1.tar.gz.

File metadata

  • Download URL: ncellapi-0.2.1.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.9.5-100.fc39.x86_64

File hashes

Hashes for ncellapi-0.2.1.tar.gz
Algorithm Hash digest
SHA256 58e9892f4eb3746db20d80410eb656b622bbb64db03662bc4cf99a3f71a397d2
MD5 7d673cb44fa4f4ab9bee9480e41760d3
BLAKE2b-256 50aa26fc1ab4a7dc0de18cf906f931495e104b59eaeefbf64948ffb4ab628783

See more details on using hashes here.

File details

Details for the file ncellapi-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: ncellapi-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.9.5-100.fc39.x86_64

File hashes

Hashes for ncellapi-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9a3793cf7c723cbcceff61adb8cf736ea0d7ea3578855381be2738d23ca44c0f
MD5 b4bf8f697d00a128f0928669d0235154
BLAKE2b-256 ee50773ea7d898141d86363c8f8e81d9412b03f080d701fa1f2d80f93683e322

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