Airtime API (Data and Airtime)

Sell MTN, Vodacom, Cell C airtime via an airtime API

Easily order and receive Vodacom, Cell C, MTN and Telkom Airtime or Data in real time from one source.

Freepaid’s API provides seamless, real time access to a wide range of pinned and pinless prepaid products at our transparent, competitive prices. This state-of-the-art programming interface does all the heavy lifting for you. It puts the programming power into your hands, freeing you to put your energy into your own development. Its clean, simple structure cuts down on implementation times and support queries. And once integrated, your application will be supported by unprecedented speed and reliability. Access fee is R99.00 per month plus VAT.

API Overview

You can order PINLESS airtime (direct recharge) or data through this API or you can order a PINNED airtime voucher which is sent to you in the form of a PIN number.

To get started you will need to register an account. During registration, we send a ‘user number’ to your Mobile phone via SMS and it will be needed in all future API calls on the Live Server.

Once logged in there be sure to go to EDIT MY DETAILS and complete your company information. The information you enter will be used to populate your Tax Invoices (which are also available online).

Then add FREEPAID as a beneficiary on your bank account and deposit funds into the FREEPAID bank account at FNB using only the MOBILE NUMBER that you registered with as the reference number. If you put your Company name or anything else as the reference it will cause a delay since your funds to go to a suspense account and this will have to get rectified manually later.

However, if the reference number is inserted correctly on the EFT then the funds will be allocated to your wallet within seconds of reaching the FREEPAID bank account. This is an automated process and works 24/7. Note that transfers from banks other than FNB can take longer to reach us.

Once the credit is available (we send SMS notification) you can then proceed to order airtime at the wholesale rate via the API. The dealer cost price of each voucher will be deducted from your balance as you transact and the remaining balance in your wallet will be returned with every webservice call.

API Specification

We use a SOAP API

The full WSDL is here: https://ws.freepaid.co.za/airtimeplus/?wsdl

The full documentation is here https://ws.freepaid.co.za/airtimeplus/

Step 1: Register on the Live server

Register on the Live Server http://services.freepaid.co.za and use your live credentials to start testing.

You will receive a OTP (one time pin) via SMS. Save the 7 digit number in that SMS as it will be required in each webservice call when ordering from the Live server. The password (which must also be included in each request) will be the one you entered into the Live website during registration.

Once you have done this, send an email to apisupport@freepaid.co.za with the following subject:
Freepaid | the number you registered with | Sandbox API

We will then allocate money so you can test your calls on the LIVE server.

Step 2: Setting up your environment

FREEPAID uses PHP, but you're free to use whatever you're comfortable with. We also use a modified PHP NuSOAP library which you can find here. It has been modified to make sure it works with PHP 7

On Live use the Live api endpoint: https://ws.freepaid.co.za/airtimeplus/

To fetch the balance you will use a call like this:


            require_once( "nusoap.php" );
              $client = new nusoap_client( "https://ws.freepaid.co.za/airtimeplus/" );
              $err = $client->getError( );
              if( $err ){
                print "<p><b>Constructor error: ".$err."</b></p>";
              }
              else {
                $request = array(
                  "user" => "USERXXXX",  # USER number, NOT cell number
                  "pass" => "PASSXXXX",
                );
                $result = $client->call( "fetchBalance", array( "request" => $request ) );
                if( $client->fault ){
                  print "<p><b>Error: <pre>";
                  print_r( $result );
                  print "</pre></b></p>";
                }
                else {
                  $err = $client->getError( );
                  if( $err ){
                    print "<p><b>Error: ".$err."</b></p>";
                  }
                  else {
                    print "<pre>";
                    print_r( $result );
                    print "</pre>";
                  }
                }
              }

Step 3: Getting to understand the process flow.

The API gives you the ability to order two kinds of vouchers, PINNED and PINLESS.

A PINNED voucher means you can deliver an airtime value by means of a 12 digit PIN which you can deliver electronically or print or send by SMS or whatever.

PINLESS relies on a direct top up of the MSISDN of your customer or client at Network level. In addition data bundles can be delivered as well. This saves the consumer the hassle of converting airtime to a data bundle which is a confusing process for many people.

We prefer pinless for security and other reasons.

Airtime vouchers are available in PINNED or PINLESS format. When you order PINNED vouchers you can only order vouchers that exist on the list of denominations that the Networks have chosen to create.

Below are some common values you may be familiar with...


            CELLC R10.00
            CELLC R25.00
            CELLC R35.00

            MTN R10.00
            MTN R15.00
            MTN R30.00

            VODACOM R10.00
            VODACOM R12.00
            VODACOM R29.00
            

However the PINLESS method for ordering Airtime allows orders from R2.00 all the way to R999.00 so you can order very specific values like Vodacom R2.35 or MTN R111.76.

While data is also PINLESS (it is a direct recharge) it too can only be ordered if it appears on the list of denominations that the Networks has chosen to create.

Process Flow: PINNED Vouchers

For PINNED you will first issue a fetchProducts call to get the available product list then you will issue a placeOrder call to place the order, you will receive an order number in the repsonse which you will use in the fetchOrder call. The response (subject to funds being available in your wallet) will be the PIN and serial number of the chosen voucher.

Process Flow: PINLESS Vouchers

For PINLESS Airtime or Data you will issue a fetchProducts call to get the product list then you will issue a placeOrder call to place the order. FREEPAID will respond with an order number and you will then use this order number to query the status of the PINLESS recharge using the queryOrder call. This will return ‘Success’ or ‘Failure’.

So in short:

PINLESS:

  • Fetch Product List ( PINLESS vouchers will be p-network example p-vodacom)
  • Place PINLESS Order
  • 
                  "user" => "USERXXXX",  # USER number, NOT cell number
                  "pass" => "PASSXXXX",
                  "refno" => "TESTXXXX", # Your own refno
                  "network" => "p-vodacom",  # PINLESS vodacom
                  "sellvalue" => "2.44",
                  "count" => "1",  # ONLY 1 is accepted here for PINLESS
                  "extra" => "CELLXXXX",  # CELL number to be recharged
                  
  • Query PINLESS Order
  • 
                  "user" => "USERXXXX",  # USER number, NOT cell number
                  "pass" => "PASSXXXX",
                  "orderno" => "ORDERXXX",
                  

The steps are

  • Place the order
  • Receive back an order number
  • Use that order number to query the status of the order.

Note: Do not query the status more than once per minute and after five attempts, once per hour. Any failures that we receive from the Network will be adjusted on your account automatically.

For PINNED Airtime vouchers you will use placeOrder to place the order, but then you will use the order number (given in our response) to fetch the actual PINNED order. The response will be a PIN number and the serial number for the voucher, with cost price and remaining balance. (You can also use the order number to re-order old vouchers, for example if you need to do a reprint).

FAQ

Does the API work with cents?

Yes, you can only order PINLESS AIRTIME in values like R2.50, R3.20 etc. Please make sure to use a decimal point and NOT a comma. R4.55 is correct. R4,55 is not correct.

What is the correct API URL to use?

On the Live Server use https://ws.freepaid.co.za/airtimeplus/ note the "https".

What are the error codes for the API?


define( "airtimeOKAY", "000" );
define( "airtimePENDING", "001" );
define( "airtimeEMPTYORDER", "100" );
define( "airtimeINVALIDUSER", "101" );
define( "airtimeINVALIDLAST", "102" );
define( "airtimeINVALIDPASS", "103" );
define( "airtimeINVALIDNETWORK", "104" );
define( "airtimeINVALIDSELLVALUE", "105" );
define( "airtimeFUNDSEXCEEDED", "106" );
define( "airtimeOUTOFSTOCK", "107" );
define( "airtimeINVALIDCOUNT", "108" );
define( "airtimeINVALIDREFNO", "109" );
define( "airtimeINVALIDREQUEST", "110" );
define( "airtimeSTILLBUSY", "111" );
define( "airtimeINVALIDORDERNUMBER", "112" );
define( "airtimeINVALIDEXTRA", "113" );
define( "airtimeINTERNAL", "197" );
define( "airtimeTEMPORARY", "198" );
define( "airtimeUNKNOWN", "199" );
            

Can I order PINNED Airtime vouchers, PINLESS airtime and data bundles using the same API?

Yes, provided you use the correct calls and values you can do so.

What is my USER number and where do I find it?

The USER number is in fact the number associated with your account in our system, which is in turn associated with the mobile number used during registration.

The Live USER number is contained in the first SMS which we sent to you during registration on the Live site. If you have already deleted the SMS then login at services.freepaid.co.za, click on Reports, then SMS log, and find the first SMS in the report.

Or call 087 073 6555 during office hours for assistance.

Sample Code

Please feel free to send us sample code and snippets, currently only sample code in PHP is available, but it will be good to expand this section to include other languages.

fetch balance

  require_once( "nusoap.php" );
  $client = new nusoap_client( "https://ws.freepaid.co.za/airtimeplus/" );
  $err = $client->getError( );
  if( $err ){
    print "<p><b>Constructor error: ".$err."</b></p>";
  }
  else {
    $request = array(
      "user" => "USERXXXX",  # USER number, NOT cell number
      "pass" => "PASSXXXX",
    );
    $result = $client->call( "fetchBalance", array( "request" => $request ) );
    if( $client->fault ){
      print "<p><b>Error: <pre>";
      print_r( $result );
      print "</pre></b></p>";
    }
    else {
      $err = $client->getError( );
      if( $err ){
        print "<p><b>Error: ".$err."</b></p>";
      }
      else {
        print "<pre>";
        print_r( $result );
        print "</pre>";
      }
    }
  }

fetch product list

  require_once( "nusoap.php" );
  $client = new nusoap_client( "https://ws.freepaid.co.za/airtimeplus/" );
  $err = $client->getError( );
  if( $err ){
    print "<p><b>Constructor error: ".$err."</b></p>";
  }
  else {
    $request = array(
      "user" => "USERXXXX",  # USER number, NOT cell number
      "pass" => "PASSXXXX",
    );
    $result = $client->call( "fetchProducts", array( "request" => $request ) );
    if( $client->fault ){
      print "<p><b>Error: <pre>";
      print_r( $result );
      print "</pre></b></p>";
    }
    else {
      $err = $client->getError( );
      if( $err ){
        print "<p><b>Error: ".$err."</b></p>";
      }
      else {
        print "<pre>";
        print_r( $result );
        print "</pre>";
      }
    }
  }

place PINNED order

require_once( "nusoap.php" );
  $client = new nusoap_client( "https://ws.freepaid.co.za/airtimeplus/" );
  $err = $client->getError( );
  if( $err ){
    print "<p><b>Constructor error: ".$err."</b></p>";
  }
  else {
    $request = array(
      "user" => "USERXXXX",  # USER number, NOT cell number
      "pass" => "PASSXXXX",
      "refno" => "TESTXXXX",
      "network" => "vodacom",
      "sellvalue" => "2",
      "count" => "10",
      "extra" => "",
    );
    $result = $client->call( "placeOrder", array( "request" => $request ) );
    if( $client->fault ){
      print "<p><b>Error: <pre>";
      print_r( $result );
      print "</pre></b></p>";
    }
    else {
      $err = $client->getError( );
      if( $err ){
        print "<p><b>Error: ".$err."</b></p>";
      }
      else {
        print "<pre>";
        print_r( $result );
        print "</pre>";
      }
    }
  }

fetch PINNED order

require_once( "nusoap.php" );
  $client = new nusoap_client( "https://ws.freepaid.co.za/airtimeplus/" );
  $err = $client->getError( );
  if( $err ){
    print "<p><b>Constructor error: ".$err."</b></p>";
  }
  else {
    $request = array(
      "user" => "USERXXXX",  # USER number, NOT cell number
      "pass" => "PASSXXXX",
      "last" => "",  # only works 1st time; use the returned order number for next call
    );
    $result = $client->call( "fetchOrderLatest", array( "request" => $request ) );
    if( $client->fault ){
      print "<p><b>Error: <pre>";
      print_r( $result );
      print "</pre></b></p>";
    }
    else {
      $err = $client->getError( );
      if( $err ){
        print "<p><b>Error: ".$err."</b></p>";
      }
      else {
        print "<pre>";
        print_r( $result );
        print "</pre>";
      }
    }
  }

place PINLESS order

  require_once( "nusoap.php" );
  $client = new nusoap_client( "https://ws.freepaid.co.za/airtimeplus/" );
  $err = $client->getError( );
  if( $err ){
    print "<p><b>Constructor error: ".$err."</b></p>";
  }
  else {
    $request = array(
      "user" => "USERXXXX",  # USER number, NOT cell number
      "pass" => "PASSXXXX",
      "refno" => "TESTXXXX",
      "network" => "p-vodacom",  # PINLESS vodacom pd-network = data
      "sellvalue" => "2",
      "count" => "1",  # ONLY 1 is accepted here for PINLESS
      "extra" => "CELLXXXX",  # CELL number to be recharged
    );
    $result = $client->call( "placeOrder", array( "request" => $request ) );
    if( $client->fault ){
      print "<p><b>Error: <pre>";
      print_r( $result );
      print "</pre></b></p>";
    }
    else {
      $err = $client->getError( );
      if( $err ){
        print "<p><b>Error: ".$err."</b></p>";
      }
      else {
        print "<pre>";
        print_r( $result );
        print "</pre>";
      }
    }
  }

query PINLESS order

  require_once( "nusoap.php" );
  $client = new nusoap_client( "https://ws.freepaid.co.za/airtimeplus/" );
  $err = $client->getError( );
  if( $err ){
    print "<p><b>Constructor error: ".$err."</b></p>";
  }
  else {
    $request = array(
      "user" => "USERXXXX",  # USER number, NOT cell number
      "pass" => "PASSXXXX",
      "orderno" => "ORDERXXX",
    );
    $result = $client->call( "queryOrder", array( "request" => $request ) );
    if( $client->fault ){
      print "<p><b>Error: <pre>";
      print_r( $result );
      print "</pre></b></p>";
    }
    else {
      $err = $client->getError( );
      if( $err ){
        print "<p><b>Error: ".$err."</b></p>";
      }
      else {
        print "<pre>";
        print_r( $result );
        print "</pre>";
      }
    }
  }

Our Products

Network Description Type Group Name Face Value
1 BRANSON Virgin Mobile Pinned Voucher Airtime Voucher R10.00
2 BRANSON Virgin Mobile Pinned Voucher Airtime Voucher R30.00
3 BRANSON Virgin Mobile Pinned Voucher Airtime Voucher R50.00
4 BRANSON Virgin Mobile Pinned Voucher Airtime Voucher R100.00
5 BRANSON Virgin Mobile Pinned Voucher Airtime Voucher R250.00
6 CELLC Cell C Pinned Voucher Airtime Voucher R5.00
7 CELLC Cell C Pinned Voucher Airtime Voucher R10.00
8 CELLC Cell C Pinned Voucher Airtime Voucher R25.00
9 CELLC Cell C Pinned Voucher Airtime Voucher R50.00
10 CELLC Cell C Pinned Voucher Airtime Voucher R70.00
11 CELLC Cell C Pinned Voucher Airtime Voucher R100.00
12 CELLC Cell C Pinned Voucher Airtime Voucher R200.00
13 ESKOM Eskom Pinned Voucher Airtime Voucher R20.00
14 HEITA Telkom Pinned Voucher Airtime Voucher R5.00
15 HEITA Telkom Pinned Voucher Airtime Voucher R10.00
16 HEITA Telkom Pinned Voucher Airtime Voucher R20.00
17 HEITA Telkom Pinned Voucher Airtime Voucher R30.00
18 HEITA Telkom Pinned Voucher Airtime Voucher R50.00
19 HEITA Telkom Pinned Voucher Airtime Voucher R100.00
20 MTN MTN Pinned Voucher Airtime Voucher R2.00
21 MTN MTN Pinned Voucher Airtime Voucher R5.00
22 MTN MTN Pinned Voucher Airtime Voucher R10.00
23 MTN MTN Pinned Voucher Airtime Voucher R15.00
24 MTN MTN Pinned Voucher Airtime Voucher R30.00
25 MTN MTN Pinned Voucher Airtime Voucher R60.00
26 MTN MTN Pinned Voucher Airtime Voucher R180.00
27 VODACOM Vodacom Pinned Voucher Airtime Voucher R2.00
28 VODACOM Vodacom Pinned Voucher Airtime Voucher R5.00
29 VODACOM Vodacom Pinned Voucher Airtime Voucher R10.00
30 VODACOM Vodacom Pinned Voucher Airtime Voucher R12.00
31 VODACOM Vodacom Pinned Voucher Airtime Voucher R29.00
32 VODACOM Vodacom Pinned Voucher Airtime Voucher R49.00
33 VODACOM Vodacom Pinned Voucher Airtime Voucher R55.00
34 VODACOM Vodacom Pinned Voucher Airtime Voucher R110.00
35 VODACOM Vodacom Pinned Voucher Airtime Voucher R275.00
36 WORLDCALL WorldCall Pinned Voucher Airtime Voucher R10.00
37 WORLDCALL WorldCall Pinned Voucher Airtime Voucher R50.00
38 WORLDCALL WorldCall Pinned Voucher Airtime Voucher R100.00
39 WORLDCALL WorldCall Pinned Voucher Airtime Voucher R200.00
40 WORLDCHAT WorldChat Pinned Voucher Airtime Voucher R200.00
41 CELLC CellC Airtime Pinless Airtime Airtime R0.00
42 HEITA Telkom Mobile Airtime Pinless Airtime Airtime R0.00
43 MTN MTN Airtime Pinless Airtime Airtime R0.00
44 VODACOM Vodacom Airtime Pinless Airtime Airtime R0.00
45 CELLC 250MB-R6 Pinless Data Night Data R6.00
46 CELLC 100MB-R19 Pinless Data 30-day Data Bundle R19.00
47 CELLC 350MB-R49 Pinless Data 30-day Data Bundle R49.00
48 CELLC 1+1GB-R85 Pinless Data 30-day Data Bundle R85.00
49 CELLC 1.5+1.5GB-R99 Pinless Data 30-day Data Bundle R99.00
50 CELLC 2+2GB-R149 Pinless Data 30-day Data Bundle R149.00
51 CELLC 3+3GB-R199 Pinless Data 30-day Data Bundle R199.00
52 CELLC 4+4GB-R249 Pinless Data 30-day Data Bundle R249.00
53 CELLC 6+6GB-R299 Pinless Data 30-day Data Bundle R299.00
54 CELLC 10+10GB-R469 Pinless Data 30-day Data Bundle R469.00
55 CELLC 20GB-R799 Pinless Data 365-day Data Bundle R799.00
56 CELLC 30GB-R899 Pinless Data 365-day Data Bundle R899.00
57 CELLC 50GB-R1099 Pinless Data 365-day Data Bundle R1099.00
58 CELLC 100GB-R1599 Pinless Data 365-day Data Bundle R1599.00
59 CELLC 200GB-R1999 Pinless Data 365-day Data Bundle R1999.00
60 HEITA 35+35MB-R7-7mth Pinless Data Once Off Data Bundle R7.00
61 HEITA 100MB-R10 Pinless Data Weekend Data Bundle R10.00
62 HEITA 75+75MB-R14-7mth Pinless Data Once Off Data Bundle R14.00
63 HEITA 200MB-R19 Pinless Data Weekend Data Bundle R19.00
64 HEITA 150+150MB-R29-7mth Pinless Data Once Off Data Bundle R29.00
65 HEITA 300+300MB-R49-7mth Pinless Data Once Off Data Bundle R49.00
66 HEITA 500+500MB-R69-7mth Pinless Data Once Off Data Bundle R69.00
67 HEITA 1+1GB-R79-2mth Pinless Data Once Off Data Bundle R79.00
68 HEITA 1.5+1.5GB-R89-2mth Pinless Data Once Off Data Bundle R89.00
69 HEITA 2+2GB-R146-3mth Pinless Data Once Off Data Bundle R146.00
70 HEITA 3+3GB-R209-3mth Pinless Data Once Off Data Bundle R209.00
71 HEITA 5+5GB-R314-3mth Pinless Data Once Off Data Bundle R314.00
72 HEITA 10+10GB-R493-3mth Pinless Data Once Off Data Bundle R493.00
73 HEITA 20GB-R734-7mth Pinless Data Once Off Data Bundle R734.00
74 HEITA 50GB-R1574-7mth Pinless Data Once Off Data Bundle R1574.00
75 HEITA 100GB-R2624-7mth Pinless Data Once Off Data Bundle R2624.00
76 MTN 5MB-R4 Pinless Data Data Bundle R4.00
77 MTN 40MB-R10 Pinless Data Data Bundle R10.00
78 MTN 120MB-R17 Pinless Data Weekly Data R17.00
79 MTN 120MB-R20 Pinless Data Data Bundle R20.00
80 MTN 200MB-R29 Pinless Data Data Bundle R29.00
81 MTN 350MB-R49 Pinless Data Data Bundle R49.00
82 MTN 500MB-R65 Pinless Data Data Bundle R65.00
83 MTN 1GB-R79 Pinless Data Data Bundle R79.00
84 MTN 1.5GB-R99 Pinless Data Data Bundle R99.00
85 MTN 2+2GB-R149 Pinless Data Data Bundle R149.00
86 MTN 3+3GB-R199 Pinless Data Data Bundle R199.00
87 MTN 5+5GB-R299 Pinless Data Data Bundle R299.00
88 MTN 6+6GB-R349 Pinless Data Data Bundle R349.00
89 MTN 10+10GB-R469 Pinless Data Data Bundle R469.00
90 MTN 20+20GB-R599 Pinless Data Data Bundle R599.00
91 MTN 30+30GB-R699 Pinless Data Data Bundle R699.00
92 MTN 50+50GB-R799 Pinless Data Data Bundle R799.00
93 MTN 100+100GB-R999 Pinless Data Data Bundle R999.00
94 VODACOM 10min-R2(on net) Pinless Data Power Bundle R2.00
95 VODACOM 50MB-R4 Pinless Data Night Data R4.00
96 VODACOM 35MB-R5.50 Pinless Data Same Day Data R5.50
97 VODACOM 100MB-R7 Pinless Data Night Data R7.00
98 VODACOM 75MB-R10 Pinless Data Same Day Data R10.00
99 VODACOM 75MB-R13 Pinless Data 30-day Data Bundle R13.00
100 VODACOM 250MB-R14 Pinless Data Night Data R14.00
101 VODACOM 250MB-R17 Pinless Data Same Day Data R17.00
102 VODACOM 150MB-R18 Pinless Data Weekly Data R18.00
103 VODACOM 240MB-R32 Pinless Data 30-day Data Bundle R32.00
104 VODACOM 400MB-R53 Pinless Data 30-day Data Bundle R53.00
105 VODACOM 600MB-R74 Pinless Data 30-day Data Bundle R74.00
106 VODACOM 1.2GB-R89 Pinless Data 30-day Data Bundle R89.00
107 VODACOM 2.2GB-R105 Pinless Data Weekly Data R105.00
108 VODACOM 2.5GB-R155 Pinless Data 30-day Data Bundle R155.00
109 VODACOM 4.5GB-R259 Pinless Data 30-day Data Bundle R259.00
110 VODACOM 7GB-R365 Pinless Data 30-day Data Bundle R365.00
111 VODACOM 12GB-R499 Pinless Data 30-day Data Bundle R499.00
112 VODACOM 18GB-R549 Pinless Data 30-day Data Bundle R549.00
113 VODACOM 40GB-R712 Pinless Data 30-day Data Bundle R712.00
114 VODACOM 60GB-R799 Pinless Data 30-day Data Bundle R799.00
115 VODACOM 120GB-R999 Pinless Data 30-day Data Bundle R999.00