C-Mobiles provides you with a very simple API, which allows you to manage individual accounts.
You can access all of the calls from the following https://demoapis.com/cmobile/:id/
Please note that all API calls expect an id parameter. Please pick one number 9-11 digits long, and use it for all of your calls. This way when you top up an account and then ask for the account status, you will see the balance updated.
Also, if you happen to use a number that someone else is also using (this is not very likely unless you use the demo id), just pick a different number and you should be fine.
Here is the list of available functions:
getAccountStatus
allows you to ask for the Account balance, minutes, SMS, and data.
Signature:
/
You need to provide your selected account id.
Example:
Here is an example of how to get the account balance for id 012345678
https://demoapis.com/cmobile/012345678/
Result:
xxxxxxxxxx
{
"balance": 12,
"minutes": 100,
"SMS": 200,
"megabytes": 29,
"data": "29 MB"
}
topUp
allows you to top up your account balance, as a result, the balance will increase and you will receive an updated account status.
Signature:
xxxxxxxxxx
/topUp?val={amount}&card={4-digits}
You need to provide your selected account id.
Additionally, you need to provide two query params:
val
— with the amount you want to top upcard
— last 4 digits of the card to use, this param is not really used for anything, but it is here to simulate the scenario.Example:
Here is an example of how to top the account id 012345678 with 10 credits using the card ending with 9876 (don't worry no card payment will actually happen 😉).
https://demoapis.com/cmobile/012345678/topUp?val=10&card=9876
Result:
xxxxxxxxxx
{
"SMS": 200,
"balance": 22,
"minutes": 100,
"data": "29 MB",
"megabytes": 29
}
availableCads
allows you to look up all associated payment cards with the account.
Signature:
xxxxxxxxxx
/availableCards
You need to provide your selected account id.
Example:
Here is an example of how to check what payment cards are associated with the account id 012345678.
https://demoapis.com/cmobile/012345678/availableCards
Result:
xxxxxxxxxx
[
{
"card": "6575",
"val": 6575
},
{
"card": "3688",
"val": 3688
}
]
resetAccount
allows you to reset your account. This can come useful when you want to start from scratch.
Signature:
xxxxxxxxxx
/reset
You need to provide your selected account id.
Example:
Here is an example of how to reset the account id 012345678.
https://demoapis.com/cmobile/012345678/reset
Result:
xxxxxxxxxx
{
"balance": 12,
"minutes": 100,
"SMS": 200,
"megabytes": 29,
"data": "29 MB"
}
dataPackages
allows you to view available data packages for you to purchase.
For each package you will receive a name, formatted data size, megabytes, and a price.
Signature:
xxxxxxxxxx
/dataPackages
No parameters are required.
Example:
Here is an example of how to view available data packages.
https://demoapis.com/cmobile/012345678/dataPackages
Result:
xxxxxxxxxx
[
{
"name": "lite",
"data": "512 MB",
"megabytes": 512,
"price": 7
},
{
"name": "small",
"data": "1 GB",
"megabytes": 1024,
"price": 10
},
{
"name": "medium",
"data": "3 GB",
"megabytes": 3072,
"price": 20
},
{
"name": "big",
"data": "5 GB",
"megabytes": 5120,
"price": 25
}
]
buyData
allows you to purchase more data for your account. As a result, more data will be added to the account, and the price of the package will be deducted from the balance.
Signature:
xxxxxxxxxx
/buyData?dataPack={name}
You need to provide your selected account id.
Additionally, you need to provide a query param dataPack
with the name of the package that you want to purchase.
Example:
Here is an example of how to buy a medium data pack for the account id 012345678.
https://demoapis.com/cmobile/012345678/buyData?dataPack=tiny
Result:
xxxxxxxxxx
{
"SMS": 200,
"balance": 5,
"minutes": 100,
"data": "0.5 GB",
"megabytes": 541
}