NAV Navbar
php ruby python shell
  • Introduction
  • Authentication
  • API Library
  • Send SMS
  • Contacts
  • Groups
  • Account Credit
  • Codes
  • Introduction

    Welcome to the Nasara Mobile API! You can use our API to send SMS and access information about your account.

    We have language API Libraries in PHP, Ruby and Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

    The Nasara Mobile API has two versions. Version one is a simple and straightfoward GET request for sending messages and Version two uses the API which enables you make requests directly from the library. Both versions are documented below.

    Authentication

    An API Key is required to access the API. You must register an account at https://sms.nasaramobile.com, then login to generate an API key from our developer portal developer portal.

    Nasara Mobile expects for the API key to be included in all API requests. API keys can be re-generated anytime from the developer portal. The API Key looks like this:

    Authorization: 5abfab60ccb425abfab60ccb52

    API Library

    Using the API Library is the easiest and fastest way to access the Nasara Mobile API. The Library for a specific programming language can be cloned or downloaded on Github.

    There are libraries for PHP, Ruby and Python, as well as examples.

    https://github.com/NasaraTech

    Send SMS

    To send a message, make a GET request using the url below. Replace relevant information with yours

    Nasara Mobile expects for the API key to be included in all API requests. The API Key looks like this:

    http://sms.nasaramobile.com/api?api_key=xxxxx&sender_id=yoursenderid&phone=02xxx&message=xxxxx

    Version 1

    To send a message, use this code:

      <?php
        $url = "http://sms.nasaramobile.com/api?api_key=[api_key]&&sender_id=[sender_id]&&phone=[phone]&&message=".urlencode([message])."";
        //send message and get response
        $response = file_get_contents($url);
        if($response == '1801'){
            echo "message sent successfully";
        }
      ?>
    
    curl "http://sms.nasaramobile.com/api?api_key=[api_key]&&sender_id=[sender_id]&&phone=[phone]&&message=[message]"
    

    Make sure to replace [all params] with your own.

    Sending SMS is very simple. Make a request using the URL provided below or use the API libraries detailed below.

    GET http://sms.nasaramobile.com/api

    Query Parameters

    Parameter Required Description
    api_key yes API Key for authorization. Generated from developer protal
    sender_id yes Identification of sender. Either a 11-alphanumeric word or phone number
    phone yes The phone number of the receipient. Multiple numbers seperated by comma
    message yes Message to be delivered

    Version 2

      <?
      $request = new HttpRequest();
      $request->setUrl('http://sms.nasaramobile.com/api/v2/sendsms');
      $request->setMethod(HTTP_METH_POST);
    
      $request->setQueryData(array(
        'api_key' => '567c1299197d5567c1299197e1',
        'phone_numbers' => '02441524xx,01662718xx',
        'sender_id' => 'ExampleName',
        'message' => 'hello%20my%20friends%21'
      ));
    
      try {
        $response = $request->send();
    
        echo $response->getBody();
      } catch (HttpException $ex) {
        echo $ex;
      }
    
      ?>
    
    
      curl --request POST \
      --url 'http://sms.nasaramobile.com/api/v2/sendsms?api_key=567c1299197d5567c1299197e1&phone_numbers=02441524xx,01662718xx&sender_id=ExampleName&message=hello%20my%20friends%21'
    
    
    
      import requests
    
      url = "http://sms.nasaramobile.com/api/v2/sendsms"
    
      querystring = {"api_key":"567c1299197d5567c1299197e1","phone_numbers":"02441524xx,01662718xx","sender_id":"ExampleName","message":"hello%20my%20friends%21"}
    
      response = requests.request("POST", url, params=querystring)
    
      print(response.text)
    
    
    
      require 'uri'
      require 'net/http'
    
      url = URI("http://sms.nasaramobile.com/api/v2/sendsms")
    
      http = Net::HTTP.new(url.host, url.port)
    
      request = Net::HTTP::Post.new(url)
      request["content-type"] = 'multipart/form-data'
      request.body = "Content-Disposition: form-data; name=\"api_key\"\r\n\r\n567c1299197d5567c1299197e1\r\nContent-Disposition: form-data; name=\"message\"\r\n\r\nhello there\r\nContent-Disposition: form-data; name=\"sender_id\"\r\n\r\require 'uri'
    require 'net/http'
    
    url = URI("http://sms.nasaramobile.com/api/v2/sendsms?api_key=567c1299197d5567c1299197e1&phone_numbers=02441524xx,01662718xx&sender_id=ExampleName&message=hello%20my%20friends%21")
    
    http = Net::HTTP.new(url.host, url.port)
    
    response = http.request(request)
    puts response.read_body\r\nContent-Disposition: form-data; name=\"phone\"\r\n\r\n23324xxxxxxx,232388920xxx"
    
      response = http.request(request)
      puts response.read_body
    
    

    The above command returns JSON structured like this:

    {
      "status": 200,
      "code": 1816,
      "data": null,
      "message": "Messages processed successfully!",
      "url": "http://sms.nasaramobile.com/api/v2/sendsms"
    }
    

    HTTP Requests

    POST http://sms.nasaramobile.com/api/v2/sendsms

    Query Parameters

    Parameter Required Description
    api_key yes API Key for authorization. Generated from developer protal
    sender_id yes Identification of sender. Either a 11-alphanumeric word or phone number
    phone only if groups/contact_ids not specified The phone number of the receipient. Multiple numbers seperated by comma
    message yes Message to be delivered
    groups no Group IDs seperated by commas
    contact_ids no Contact IDs seperated by commas

    Contacts

    Get Contacts

      <?php
        $request = new HttpRequest();
        $request->setUrl('http://sms.nasaramobile.com/api/v2/contacts');
        $request->setMethod(HTTP_METH_GET);
    
        $request->setQueryData(array(
          'api_key' => '567c1299197d5567c1299197e1'
        ));
    
        try {
          $response = $request->send();
    
          echo $response->getBody();
        } catch (HttpException $ex) {
          echo $ex;
        }
      ?>
    
    
    
      require 'uri'
      require 'net/http'
    
      url = URI("http://sms.nasaramobile.com/api/v2/contacts?api_key=[api_key]")
    
      http = Net::HTTP.new(url.host, url.port)
    
      request = Net::HTTP::Get.new(url)
    
      response = http.request(request)
      puts response.read_body
    
    
      GET /api/v2/contacts?api_key=[api_key] HTTP/1.1
      Host: sms.nasaramobile.com
    
    
    import requests
    
    url = "http://sms.nasaramobile.com/api/v2/contacts"
    
    querystring = {"api_key":"567c1299197d5567c1299197e1"}
    
    response = requests.request("GET", url, params=querystring)
    
    print(response.text)
    
    

    Make sure to replace [all params] with your own.

    This endpoint retrieves all contacts stored in your account

    HTTP Requests

    GET http://sms.nasaramobile.com/api/v2/contacts

    Query Parameters

    Parameter Required Description
    api_key yes API Key for authorization. Generated from developer protal

    The above command returns JSON structured like this:

    {
      "status": 200,
      "code": 1808,
      "data": {
          "contacts": [
              {
                "id": 297367,
                "name": "John doe",
                "phone": 2222111111,
                "email": "",
                "created_at": {
                    "date": "2015-11-14 17:42:24.000000",
                    "timezone_type": 3,
                    "timezone": "UTC"
                },
                "updated_at": {
                    "date": "2015-11-14 17:42:24.000000",
                    "timezone_type": 3,
                    "timezone": "UTC"
                }
            },
            {
                "id": 297368,
                "name": "Jane Doe",
                "phone": 7867821676,
                "email": "",
                "created_at": {
                    "date": "2015-11-14 17:42:24.000000",
                    "timezone_type": 3,
                    "timezone": "UTC"
                },
                "updated_at": {
                    "date": "2015-11-14 17:42:24.000000",
                    "timezone_type": 3,
                    "timezone": "UTC"
                }
            }
          ]
        },
    
        "message": "Contacts fetched successfully!",
        "url": "http://sms.nasaramobile.com/api/v2/contacts?api_key=567c1299197d5567c1299197e1"
    }
    

    Get Contact Details

      <?php
        $request = new HttpRequest();
        $request->setUrl('http://sms.nasaramobile.com/api/v2/contacts/[contact_id]');
        $request->setMethod(HTTP_METH_GET);
    
        $request->setQueryData(array(
          'api_key' => '567c1299197d5567c1299197e1'
        ));
    
        try {
          $response = $request->send();
    
          echo $response->getBody();
        } catch (HttpException $ex) {
          echo $ex;
        }
      ?>
    
    
    
      require 'uri'
      require 'net/http'
    
      url = URI("http://sms.nasaramobile.com/api/v2/contacts/[contact_id]?api_key=[api_key]")
    
      http = Net::HTTP.new(url.host, url.port)
    
      request = Net::HTTP::Get.new(url)
    
      response = http.request(request)
      puts response.read_body
    
    
      GET /api/v2/contacts?api_key=[api_key] HTTP/1.1
      Host: sms.nasaramobile.com
    
    
    import requests
    
    url = "http://sms.nasaramobile.com/api/v2/contacts/[contact_id]"
    
    querystring = {"api_key":"567c1299197d5567c1299197e1"}
    
    response = requests.request("GET", url, params=querystring)
    
    print(response.text)
    
    

    Make sure to replace [all params] with your own.

    This endpoint retrieves all contacts stored in your account

    HTTP Requests

    GET http://sms.nasaramobile.com/api/v2/contacts/[contact_id]

    Query Parameters*

    Parameter Required Description
    api_key yes API Key for authorization. Generated from developer protal

    The above command returns JSON structured like this:

    {
      "status": 200,
      "code": 1811,
      "data": {
          "contact": {
              "id": 297367,
              "name": "John Doe",
              "phone": 2xxxxxxxx,
              "email": "",
              "created_at": {
                  "date": "2015-11-14 17:42:24.000000",
                  "timezone_type": 3,
                  "timezone": "UTC"
              },
              "updated_at": {
                  "date": "2015-11-14 17:42:24.000000",
                  "timezone_type": 3,
                  "timezone": "UTC"
              }
          }
      },
      "message": "Contact details fetched successfully!",
      "url": "http://sms.nasaramobile.com/api/v2/contacts/297367?api_key=567c1299197d5567c1299197e1"
    }
    

    Groups

    Get All Groups

    Retrieve all stored groups

    HTTP Requests

    GET http://sms.nasaramobile.com/api/v2/groups

    Query Parameters

    Parameter Required Description
    api_key yes API Key for authorization. Generated from developer protal

    The above command returns JSON structured like this:

    {
      "status": 200,
        "code": 1812,
        "data": {
          "groups": [
            {
              "id": 112,
              "name": "My Friends",
              "description": "Friends!",
              "total_number_of_contacts": 20,
              "created_at": {
                  "date": "2013-06-15 23:58:05.000000",
                  "timezone_type": 3,
                  "timezone": "UTC"
              },
              "updated_at": {
                  "date": "2015-12-24 16:31:42.000000",
                  "timezone_type": 3,
                  "timezone": "UTC"
              }
          },
          {
            "id": 113,
            "name": "Royal House Chapel",
            "description": "Members of ROSA KNUST",
            "total_number_of_contacts": 109,
            "created_at": {
                "date": "2013-06-15 23:59:19.000000",
                "timezone_type": 3,
                "timezone": "UTC"
            },
            "updated_at": {
                "date": "2013-11-17 17:56:14.000000",
                "timezone_type": 3,
                "timezone": "UTC"
            }
          }
        ]
      },
    
      "message": "groups fetched successfully!",
      "url": "http://sms.nasaramobile.com/api/v2/groups?api_key=567c1299197d5567c1299197e1"
    }
    

    Get Contact Details

      <?php
        $request = new HttpRequest();
        $request->setUrl('http://sms.nasaramobile.com/api/v2/groups/[group_id]');
        $request->setMethod(HTTP_METH_GET);
    
        $request->setQueryData(array(
          'api_key' => '567c1299197d5567c1299197e1'
        ));
    
        try {
          $response = $request->send();
    
          echo $response->getBody();
        } catch (HttpException $ex) {
          echo $ex;
        }
      ?>
    
    
    
      require 'uri'
      require 'net/http'
    
      url = URI("http://sms.nasaramobile.com/api/v2/groups/[group_id]?api_key=[api_key]")
    
      http = Net::HTTP.new(url.host, url.port)
    
      request = Net::HTTP::Get.new(url)
    
      response = http.request(request)
      puts response.read_body
    
    
      GET /api/v2/groups?api_key=[api_key] HTTP/1.1
      Host: sms.nasaramobile.com
    
    
    import requests
    
    url = "http://sms.nasaramobile.com/api/v2/groups/[group_id]"
    
    querystring = {"api_key":"567c1299197d5567c1299197e1"}
    
    response = requests.request("GET", url, params=querystring)
    
    print(response.text)
    
    

    Make sure to replace [all params] with your own.

    This endpoint retrieves all groups stored in your account

    HTTP Requests

    GET http://sms.nasaramobile.com/api/v2/groups/[group_id]

    Query Parameters*

    Parameter Required Description
    api_key yes API Key for authorization. Generated from developer protal

    The above command returns JSON structured like this:

    {
      "status": 200,
      "code": 1815,
      "data": {
          "group": {
            "id": 113,
            "name": "Royal House Chapel",
            "description": "Members of ROSA KNUST",
            "total_number_of_contacts": 109,
            "created_at": {
                "date": "2013-06-15 23:59:19.000000",
                "timezone_type": 3,
                "timezone": "UTC"
            },
            "updated_at": {
                "date": "2013-11-17 17:56:14.000000",
                "timezone_type": 3,
                "timezone": "UTC"
            }
          }
      },
      "message": "Group details fetched successfully!",
      "url": "http://sms.nasaramobile.com/api/v2/groups/297367?api_key=567c1299197d5567c1299197e1"
    }
    

    Account Credit

      <?php
        $request = new HttpRequest();
        $request->setUrl('http://sms.nasaramobile.com/api/v2/accounts/credit');
        $request->setMethod(HTTP_METH_GET);
    
        $request->setQueryData(array(
          'api_key' => '567c1299197d5567c1299197e1'
        ));
    
        try {
          $response = $request->send();
    
          echo $response->getBody();
        } catch (HttpException $ex) {
          echo $ex;
        }
      ?>
    
    
    
      require 'uri'
      require 'net/http'
    
      url = URI("http://sms.nasaramobile.com/api/v2/accounts/credit?api_key=[api_key]")
    
      http = Net::HTTP.new(url.host, url.port)
    
      request = Net::HTTP::Get.new(url)
    
      response = http.request(request)
      puts response.read_body
    
    
      GET /api/v2/accounts/credit?api_key=[api_key] HTTP/1.1
      Host: sms.nasaramobile.com
    
    
    import requests
    
    url = "http://sms.nasaramobile.com/api/v2/accounts/credit"
    
    querystring = {"api_key":"567c1299197d5567c1299197e1"}
    
    response = requests.request("GET", url, params=querystring)
    
    print(response.text)
    
    

    Make sure to replace [all params] with your own.

    This endpoint retrieves the credit in your account

    HTTP Requests

    GET http://sms.nasaramobile.com/api/v2/accounts/credit

    Query Parameters

    Parameter Required Description
    api_key yes API Key for authorization. Generated from developer protal

    The above command returns JSON structured like this:

    {
        "status": 200,
        "code": 1818,
        "data": 11,
        "message": "Account credit fetched successfully!",
        "url": "http://sms.nasaramobile.com/api/v2/accounts/credit?api_key=[api_key]"
    }
    
    

    Data contains credit value

    Codes

    The Kittn API uses the following error codes:

    Code Meaning
    200 Ok Request -- Your request is successful.
    400 Bad Request -- Your request is invalid.
    401 Unauthorized -- Your API key is wrong.
    403 Forbidden -- The kitten requested is hidden for administrators only.
    404 Not Found -- The specified kitten could not be found.
    405 Method Not Allowed -- You tried to access a kitten with an invalid method.
    1801 message sent successfully.
    1802 message sending failed.
    1803 invalid api key.
    1804 not enough credit
    1805 sender id must be more than 1 charater and less than 12 characters.
    1806 phone number must be more than 8 characters.
    1807 message not posted.
    1808 Contacts fetched successfully!
    1810 There was a problem getting details for the given contact ID. Please try again with a valid contact id!
    1811 Contact details fetched successfully!
    1812 Groups fetched successfully!
    1814 There was a problem getting details for the given group ID. Please try again with a valid group id!
    1815 Group details fetched successfully!
    1816 Messages processed successfully!.
    1817 There was an error processing your messages. Please try again!.
    1818 Account credit fetched successfully!
    1819 invalid contact ID. Please try again with a valid contact id!.