Skip to main content

Interact with PingSMS API

Project description

Python Pingsms API Package

This is a python package for https://pingsms.in API. If you are looking for API usage in PHP click here!

Contents

  1. Installation
  2. Usage
    1. Importing the package
    2. Input
    3. Methods
    4. Examples
    5. Output
  3. Error Codes
  4. Get Api Key

Installation

The package is located at PyPI and can be installed with a pip command. To install the package simply run:-

pip install pingsms-api 

Usage

Importing the package

To start using the package first we need to import the package.
Note: Our package name is pingsms-api but from now on we will be using pingsms only for all our tasks.
To import the package run the following command:-

import pingsms

Input

Only one variable of dictionary data type is sent to the methods. A sample dictionary variable is provided for reference:

"""
Sample Variable
"""
custom_data = {
 "key": "AMjdkshmsaZdoV6PGWoSbejmEgFZ905EdmaanahwqkwNVc ",
 "job_id": "021839426237963",
 "report_date":"2021-06-12",
 "product":"1",
 "language":"1",
 "sender":"PNGSMS",
 "mobile":"1232123451",
 "template":"282222382902",
 "message":"Hello World!"
}

There is a total of 9 elements (known as key:value pairs) allowed in the dictionary. Any additional parameters are ignored.

  1. key : A user is identified by a unique hashed key. This key can be generated from the https://pingsms.in user panel. All pingsms customers have free access to API keys. This is an mandatory field required by all the methods.
  2. job_id : The Job Id number. This parameter is only used in the method get_job_report()
  3. report_date : Date Of Report in YYYY-MM-DD Format.This parameter is used in the method get_job_report() and get_sent_sms_reports()
  4. product : Choose between two product types
    1 - Transactional
    2 - Promotional
    This parameter is only used in the method send_single_sms() and send_multiple_sms(custom_data)
  5. language : Choose between two language formats
    1 - English
    2 - Unicode (Regional Language)
    This parameter is only used in the method send_single_sms() and send_multiple_sms(custom_data)
  6. sender : User's approved 6 characters Sender Id.
    This parameter is only used in the method send_single_sms() and send_multiple_sms(custom_data)
  7. mobile : 10 digit recipient mobile number. (In case of multiple sms mobile numbers should be provide in comma(,) separated form).
    This parameter is only used in the method send_single_sms() and send_multiple_sms(custom_data)
  8. template : Authorised Template number of the user.
    This parameter is only used in the method send_single_sms() and send_multiple_sms(custom_data)
  9. message : Authorised message format against the Template number.
    This parameter is only used in the method send_single_sms() and send_multiple_sms(custom_data)

Methods

There are total of 5 available methods:

  1. get_sms_balance(custom_data) :
    Get Transactional and Promotional Balance of The User.
    Input Parameter's Required:key
    Output: JSON
  2. get_sender_id(custom_data) :
    Get List of Sender Ids of The User.
    Input Parameter's Required:key
    Output: JSON
  3. get_job_report(custom_data) :
    Get Job Report of the User.
    Input Parameter's Required:key,job_id,report_date
    Output: JSON
  4. get_sent_sms_reports(custom_data) :
    Get SMS sent reports of the User.
    Input Parameter's Required:key,report_date,product
    Output: JSON
  5. send_single_sms(custom_data) :
    Send Single SMS.
    Input Parameter's Required:key,sender,mobile,language,product,message, template
    Output: JSON
  6. send_multiple_sms(custom_data) :
    Send Multiple SMS.
    Input Parameter's Required:key,sender,mobile(multiple and comma separated),language,product,message,template
    Output: JSON

Examples

"""
Example 1
"""
import pingsms
custom_data = {
"key": "AMjdkshmsaZdoV6PGWoSbejmEgFZ905EdmaanahwqkwNVc ",
}
pingsms.get_sms_balance(custom_data)
"""
Example 2
"""
import pingsms
custom_data = {
"key": "AMjdkshmsaZdoV6PGWoSbejmEgFZ905EdmaanahwqkwNVc ",
"product":"1",
"language":"1",
"sender":"PNGSMS",
"mobile":"1232123451",
"template":"282222382902",
"message":"Hello World!"
}
pingsms.send_multiple_sms(custom_data)

Output

All outputs are returned in the form of JSON.

"""
Example 1 Output
"""
{
    "code": 201,
    "status": "Success",
    "message": "User balance details found",
    "available_balance": {
        "transactional_balance": 9248,
        "promotional_balance": 1029
    }
}
"""
Example 2 Output
"""
{
    "code": 201,
    "status": "Success",
    "message": "Message Sent",
    "job_id": "11312351841231313"
}

Error Codes

Error Code Meaning
Unauthorized Incorrect API key or the account is blocked.
1 This error occurs when no recipients is found.
2 This error occurs when no sender name is specified.
3 Invalid Sender Id for this domain. This error appears if you use a Sender Id which is not specified for your account.
4 This error occurs when the Language id is missing or not specified. Choose between two language formats 1 - English 2 - Unicode (Regional Language)
5 This error occurs when the Product id is missing or not specified. Choose between two Product types 1 - Transactional 2 - Promotional
6 This error occurs when no Message Content is found. This error occurs when message content is missing.
11 This error occurs when the Message size exceeds the given limit. Please check your account balance and message size.
12 Mobile numbers should not be more than 500. This error occurs when the number of mobile number in multiple SMS exceeds 500.
15 This error occurs when Job Id is missing.
17 This error occurs when the Date is missing.
18 This error occurs when the Date format is invalid. The date should be in YYYY-MM-DD format.
101 This error occurs when the account has Insufficient Balance. Recharge your account to fix this issue.
102 This error occurs when API Key is not specified.
143 This error occurs when the User not found or Inactive.
151 This error occurs when Job Id and date doesn't match or the Job Id is incorrect.
142 Unauthorized IP Address. This error appears when the IP of the server which sent the GET request didn't match the whitelisted IP list.
500 This error occurs usually when the problem is on our end. Kindly, notify us immediately when you face this issue.

Get API Key

     -Sign Up at https://pingsms.in
     -Get API Key from Developer API Tab

API_KEY

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

pingsms-api-1.0.3.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

pingsms_api-1.0.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file pingsms-api-1.0.3.tar.gz.

File metadata

  • Download URL: pingsms-api-1.0.3.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for pingsms-api-1.0.3.tar.gz
Algorithm Hash digest
SHA256 59609020248304a89195487bca426138ea382f84c0a640800e4839de373a73c2
MD5 42e871d2962f4e33ad9c6a2bb73b0ad8
BLAKE2b-256 d13cbbc1e4610e4c3426a08ad00bfcc22794173db57bde43330419434b6da5b0

See more details on using hashes here.

File details

Details for the file pingsms_api-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: pingsms_api-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for pingsms_api-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8696e2994e904f72a2c58d5a1078489d06ad0e863ed0b207b8054a992b7e199b
MD5 37caf73e9618a2a808e8dd29bf29b481
BLAKE2b-256 812ba4fdc363415e435ec1525e0c0c6c54565fa8824d8a8bd1aef80bb43752b0

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