introduction
Weta is an API that allows programmatic access to payment system of Yemeni communication company, so our API provide your apps, websites and any other platforms to billing mobile balance from any country in the world.
Authentication & Authorization
Weta APIs are HTTP-based RESTful APIs that based on JWT for authorization. All requests to resources must be accompanied by a correct token, each API request and response bodies are formatted in JSON.
JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object.
when you register an account you put a username and password, so when you post an username and password to Authorized you will get an access token request.
access tokens called bearer tokens will used for authorization when you make REST API requests, also access tokens have a finite lifetime. for example if an expiry value of 60 indicates that the access token expires in one hour from the time the response was generated. in our case token expiry value 1440 by default.
API request
To construct a REST API request, combine these components :
request parameter
| Component | Description |
|---|---|
| The HTTP method |
|
| The URL to the service | https://yemenairtime.com/api |
| Query parameters | depending on API call, it's Controls which data appears in the response. |
| HTTP request headers | Includes the Authorization header with the access token. |
| A JSON request body | Required for most GET, POST, PUT, and PATCH calls. |
API response
Weta API calls was return JSON response and HTTP status code, also Some API calls may get an HTTP error code.
Response codes
| Status code | Description |
|---|---|
| 200 | Success. |
| 201 | Created. |
| 204 | No content. |
| 304 | ConditionNotMet - Not Modified: The condition specified in the |
| 400 | Invalid parameters in the request |
| 401 | Authentication failure. |
| 403 | Don't have permissions to access resource due to the policy |
| 404 | Not Found - The specified resource does not exist. |
| 405 | Method not allowed by the resource. |
| 409 | Conflict. |
| 411 | Length Required: The Content-Length header was not specified. |
| 412 | Precondition Failed: The condition specified in the conditional header(s) |
| 413 | RequestBodyTooLarge - Request Entity Too Large: The size of the |
| 416 | InvalidRange - Requested Range Not Satisfiable: The range specified is |
| 422 | unprocessable entity. |
| 500 | Internal server error. |
| 503 | ServerBusy - Service Unavailable: The server is currently unable to |
error code
Weta API calls also may return an API error code.
API error
| Status code | Description |
|---|---|
| 1000 | your balance not enough. |
| 1001 | there is another batch proccess in this moment. |
| 1002 | Chosen amount is invalid or not allowed for the user. |
| 1003 | Chosen offer is invalid or not allowed for the user. |
| 1004 | the accounting details is not founded. |
| 1005 | Rejected |
API calls 🚀
great you are ready now to make REST API calls, all you want is create a Weta developer account and get an access token
cURL request example
in this doc we will show an examples with cURL so If you use Windows, should use a Bash shell to make cURL calls. and If you use a command-line tool other than cURL, set content-type to application/json.
Note:
You can download cURL for your environment from Here.
Also you can download Postman from Here.
register
/register register new account
cURL request
curl -X POST \
https://yemenairtime.com/api/register \
-H 'Content-Type: application/json' \
-d '{
"name":"customer first, meddle and last name",
"username":"customer username",
"email":"customer_email@mile.com",
"mobile":"967XXXXXXXXX",
"password":"customer password",
"password_confirmation":"customer password"
}'
Parameters
| Parameter | Data type | Description |
|---|---|---|
| name* | string | first, meddle and last name |
| username* | string | Identical username |
| mobile* | string | Agent mobile number |
| email* | string | email address |
| password* | string | Identical password |
| password_confirmation* | string | Identical password confirm |
Responses
| code | Description | Example Value |
|---|---|---|
| 201 | created |
|
| 422 | unprocessable entity |
|
login
/login signing and get access token
cURL request
curl -x post \ https://yemenairtime.com/api/login \
-H 'Content-Type: application/json' \
-d '{
"username":"customer_username",
"password:":"customer_password"
}'
Parameters
| Parameter | Data type | Description |
|---|---|---|
| username* | string | Identical username |
| password* | string | Password must be at least 8 character |
Responses
| code | Description | Example Value |
|---|---|---|
| 200 | success |
|
| 422 | unprocessable entity |
|
| 401 | Authentication failure |
|
query weta offer
/q/weta-offer query to get available weta offers
cURL request
curl -X POST \
https://yemenairtime.com/api/q/weta-offer \
-H 'Authorization: Bearer ehjrexaioijkv1qilcjhbgcioijiuzi1nij9.eyjpc3mioijo
dhrwolwvxc9sb2nhbghvc3q6odawmfwvyxbpxc9sb2dpbiisimlhdci6mtu
5ote3otmymcwizxhwijoxntk5mtgyoiwlcjuymyioje1otkxnjkzmjasimp
0asi6ik1vnmu2whzfzuq4s0o2nlugtlcjzdwiiojewmdawlcjwcnyioii4n2u
wewfxzwy5zfqxntgxmmzkrwm5nze1m2exnguwyja6nzu0nmfhitt.ffqtxvvj
e1mlt2jpfeiirglyxbzryup6bpebpsinwia' \
-H 'Content-Type: application/json' \
-d '{
"mobile":"967XXXXXXXXX"
}'
Parameters
| Parameter | Data type | Description |
|---|---|---|
| token* | string | Bearer authentication token |
| mobile* | string | Customer number, must be 10 or 12 digit |
Responses
| code | Description | Example Value |
|---|---|---|
| 200 | success |
|
| 401 | authentication failure |
|
| 422 | unprocessable entity |
|
billing weta offer
/bill/weta-offer billing offer from available weta offers
cURL request
curl -X POST \
https://yemenairtime.com/api/bill/weta-offer \
-H 'Authorization: Bearer ehjrexaioijkv1qilcjhbgcioijiuzi1nij9.eyjpc3mioijo
dhrwolwvxc9sb2nhbghvc3q6odawmfwvyxbpxc9sb2dpbiisimlhdci6mtu
5ote3otmymcwizxhwijoxntk5mtgyoiwlcjuymyioje1otkxnjkzmjasimp
0asi6ik1vnmu2whzfzuq4s0o2nlugtlcjzdwiiojewmdawlcjwcnyioii4n2u
wewfxzwy5zfqxntgxmmzkrwm5nze1m2exnguwyja6nzu0nmfhitt.ffqtxvvj
e1mlt2jpfeiirglyxbzryup6bpebpsinwia' \
-H 'Content-Type: application/json' \
-d '{
"mobile":"967XXXXXXXXX",
"trans_id":1,
"code":"1",
"type":"prepaid"
}'
Parameters
| Parameter | Data type | Description |
|---|---|---|
| token* | string | Bearer authentication token |
| mobile* | string | customer mobile, must be 10 or 12 digit numbers |
| trans_id* | integer | unique sequence integer number |
| code* | string | weta offer code |
| type* | string | mobile type, if you billing number with 12 digit the type must be [prepaid,postpaid], but if you billing 10 digit number the type must be [line,adsl] |
Responses
| code | Description | Example Value |
|---|---|---|
| 200 | success |
|
| 401 | authentication failure |
|
| 422 | unprocessable entity |
|
query applied backage
/q/applied-backage query to get applied backage details
cURL request
curl -X POST \
https://yemenairtime.com/api/q/applied-backage \
-H 'Authorization: Bearer ehjrexaioijkv1qilcjhbgcioijiuzi1nij9.eyjpc3mioijo
dhrwolwvxc9sb2nhbghvc3q6odawmfwvyxbpxc9sb2dpbiisimlhdci6mtu
5ote3otmymcwizxhwijoxntk5mtgyoiwlcjuymyioje1otkxnjkzmjasimp
0asi6ik1vnmu2whzfzuq4s0o2nlugtlcjzdwiiojewmdawlcjwcnyioii4n2u
wewfxzwy5zfqxntgxmmzkrwm5nze1m2exnguwyja6nzu0nmfhitt.ffqtxvvj
e1mlt2jpfeiirglyxbzryup6bpebpsinwia' \
-H 'Content-Type: application/json' \
-d '{
"mobile":"967XXXXXXXXX"
}'
Parameters
| Parameter | Data type | Description |
|---|---|---|
| token* | string | Bearer authentication token |
| mobile* | string | customer mobile, must be Yemen Mobile number and 12 digit numbers |
Responses
| code | Description | Example Value |
|---|---|---|
| 200 | success |
|
| 401 | authentication failure |
|
| 422 | unprocessable entity |
|
query balance
/q/balance query to get available amount of mobile number
cURL request
curl -X POST \
https://yemenairtime.com/api/q/balance \
-H 'Authorization: Bearer ehjrexaioijkv1qilcjhbgcioijiuzi1nij9.eyjpc3mioijo
dhrwolwvxc9sb2nhbghvc3q6odawmfwvyxbpxc9sb2dpbiisimlhdci6mtu
5ote3otmymcwizxhwijoxntk5mtgyoiwlcjuymyioje1otkxnjkzmjasimp
0asi6ik1vnmu2whzfzuq4s0o2nlugtlcjzdwiiojewmdawlcjwcnyioii4n2u
wewfxzwy5zfqxntgxmmzkrwm5nze1m2exnguwyja6nzu0nmfhitt.ffqtxvvj
e1mlt2jpfeiirglyxbzryup6bpebpsinwia' \
-H 'Content-Type: application/json' \
-d '{
"mobile":"967XXXXXXXXX",
"methode":"prepaid"
}'
Parameters
| Parameter | Data type | Description |
|---|---|---|
| token* | string | Bearer authentication token |
| mobile* | string | customer mobile, must be 12 numbers |
| type* | string | pay methode |
Responses
| code | Description | Example Value |
|---|---|---|
| 200 |
success
Note:MobileType 0 mean prepaid MobileType 1 mean postpaid |
|
| 401 | authentication failure |
|
| 422 | unprocessable entity |
|
query solfa
/q/solfa query to chick if the mobile number has solfa or not
cURL request
curl -X POST \
https://yemenairtime.com/api/q/solfa\
-H 'Authorization: Bearer ehjrexaioijkv1qilcjhbgcioijiuzi1nij9.eyjpc3mioijo
dhrwolwvxc9sb2nhbghvc3q6odawmfwvyxbpxc9sb2dpbiisimlhdci6mtu
5ote3otmymcwizxhwijoxntk5mtgyoiwlcjuymyioje1otkxnjkzmjasimp
0asi6ik1vnmu2whzfzuq4s0o2nlugtlcjzdwiiojewmdawlcjwcnyioii4n2u
wewfxzwy5zfqxntgxmmzkrwm5nze1m2exnguwyja6nzu0nmfhitt.ffqtxvvj
e1mlt2jpfeiirglyxbzryup6bpebpsinwia' \
-H 'Content-Type: application/json' \
-d '{
"mobile":"967XXXXXXXXX"
}'
Parameters
| Parameter | Data type | Description |
|---|---|---|
| token* | string | Bearer authentication token |
| mobile* | string | customer mobile, must be Yemen Mobile number and 12 digit numbers |
Responses
| code | Description | Example Value |
|---|---|---|
| 200 | success |
|
| 401 | authentication failure |
|
| 422 | unprocessable entity |
|
query agent balance
/q/agent-balance query to get agent balance
cURL request
curl -X POST \
https://yemenairtime.com/api/q/agent-balance \
-H 'Authorization: Bearer ehjrexaioijkv1qilcjhbgcioijiuzi1nij9.eyjpc3mioijo
dhrwolwvxc9sb2nhbghvc3q6odawmfwvyxbpxc9sb2dpbiisimlhdci6mtu
5ote3otmymcwizxhwijoxntk5mtgyoiwlcjuymyioje1otkxnjkzmjasimp
0asi6ik1vnmu2whzfzuq4s0o2nlugtlcjzdwiiojewmdawlcjwcnyioii4n2u
wewfxzwy5zfqxntgxmmzkrwm5nze1m2exnguwyja6nzu0nmfhitt.ffqtxvvj
e1mlt2jpfeiirglyxbzryup6bpebpsinwia' \
-H 'Content-Type: application/json' \
Parameters
| Parameter | Data type | Description |
|---|---|---|
| token* | string | Bearer authentication token |
Responses
| code | Description | Example Value |
|---|---|---|
| 200 | success |
|
| 401 | authentication failure |
|
| 422 | unprocessable entity |
|
query operator status
/q/status query to check status of specific operation
cURL request
curl -X POST \
https://yemenairtime.com/api/q/status \
-H 'Authorization: Bearer ehjrexaioijkv1qilcjhbgcioijiuzi1nij9.eyjpc3mioijo
dhrwolwvxc9sb2nhbghvc3q6odawmfwvyxbpxc9sb2dpbiisimlhdci6mtu
5ote3otmymcwizxhwijoxntk5mtgyoiwlcjuymyioje1otkxnjkzmjasimp
0asi6ik1vnmu2whzfzuq4s0o2nlugtlcjzdwiiojewmdawlcjwcnyioii4n2u
wewfxzwy5zfqxntgxmmzkrwm5nze1m2exnguwyja6nzu0nmfhitt.ffqtxvvj
e1mlt2jpfeiirglyxbzryup6bpebpsinwia' \
-H 'Content-Type: application/json' \
-d '{
"trans_id":6,
"mobile":"9677XXXXXXXX"
}'
Parameters
| Parameter | Data type | Description |
|---|---|---|
| token* | string | Bearer authentication token |
| mobile* | string | Agent mobile that account registered with, must be 10 or 12 digit number |
| trans_id* | integer | Type of request must be [adsl or line] |
Responses
| code | Description | Example Value |
|---|---|---|
| 200 |
success
Note:isDone 1 mean success isDone 0 mean in progress isBan 1 mean ban isBan 0 mean safe |
|
| 401 | authentication failure |
|
| 422 | unprocessable entity |
|
reset password
/setting/reset_pass Reset account password
cURL request
curl -X POST \
https://yemenairtime.com/api/setting/reset_pass \
-H 'Authorization: Bearer ehjrexaioijkv1qilcjhbgcioijiuzi1nij9.eyjpc3mioijo
dhrwolwvxc9sb2nhbghvc3q6odawmfwvyxbpxc9sb2dpbiisimlhdci6mtu
5ote3otmymcwizxhwijoxntk5mtgyoiwlcjuymyioje1otkxnjkzmjasimp
0asi6ik1vnmu2whzfzuq4s0o2nlugtlcjzdwiiojewmdawlcjwcnyioii4n2u
wewfxzwy5zfqxntgxmmzkrwm5nze1m2exnguwyja6nzu0nmfhitt.ffqtxvvj
e1mlt2jpfeiirglyxbzryup6bpebpsinwia' \
-H 'Content-Type: application/json' \
-d '{
"password":"New password"
}'
Parameters
| Parameter | Data type | Description |
|---|---|---|
| token* | string | Bearer authentication token |
| token* | string | password |
Responses
| code | Description | Example Value |
|---|---|---|
| 200 | success |
|
| 401 | authentication failure |
|
| 422 | unprocessable entity |
|
logout
/logout logout from the system and end the access token
cURL request
curl -X POST \
https://yemenairtime.com/api/logout \
-H 'Authorization: Bearer ehjrexaioijkv1qilcjhbgcioijiuzi1nij9.eyjpc3mioijo
dhrwolwvxc9sb2nhbghvc3q6odawmfwvyxbpxc9sb2dpbiisimlhdci6mtu
5ote3otmymcwizxhwijoxntk5mtgyoiwlcjuymyioje1otkxnjkzmjasimp
0asi6ik1vnmu2whzfzuq4s0o2nlugtlcjzdwiiojewmdawlcjwcnyioii4n2u
wewfxzwy5zfqxntgxmmzkrwm5nze1m2exnguwyja6nzu0nmfhitt.ffqtxvvj
e1mlt2jpfeiirglyxbzryup6bpebpsinwia' \
-H 'Content-Type: application/json' \
Parameters
| Parameter | Data type | Description |
|---|---|---|
| token* | string | Bearer authentication token |
Responses
| code | Description | Example Value |
|---|---|---|
| 200 | success |
|
| 401 | authentication failure |
|
commissions & discounts
Commissions & Discounts is based on operation,All Commissions are paid instantly when a Weta is processed.
One thing to note that All Operators provide two types of discounts, One is the local discount that will be applied for all Weta consumer and the other is the consumer based discount that will applied when the consumer has an offer or for VPN consumer.
fix delay
Weta is provide simple way to fix the delay between server and client, by using Operation Status query.
Wen you sending any billing call you put a sequence user_trand_id parameter, so wen you loose the status of response because of delay you can make a simple post call to /q/status. By using parameter trans_id and mobile number of operation you will get is Done, is Ban and the reason.
Note that isBan has two value [ 0, 1 ] the zero value mean that operator was done successfully, in other case the one value mean operator was in progress.isBan also has two value [ 0, 1 ] the zero value mean ban, in other case the one value mean safe.API methods discovery
This section presents the methods discovery that is available in this API.
methods table
| Method | Main end point | Description |
|---|---|---|
| Post | /login | signing to weta system |
| Post | /q/agent-balance | query to get agent balance |
| Post | /q/weta-offer | query to get available offers to bill |
| Post | /bill/weta-offer | billing offer from available weta offers |
| Post | /q/applied-backage | query to get applied backage details |
| Post | /q/adsl-line | query to get available amount of line or adsl |
| Post | /q/balance | query to get available amount of mobile number |
| Post | /q/solfa | query to chick if the mobile number has solfa or not |
| Post | /q/status | query to check status of specific operation |
transition parameters discovery
This section presents the transition parameter discovery that is used in this API methods.
transition parameter
| Parameter | Type | mandatory | Description |
|---|---|---|---|
| username | string | Yes | Identical username |
| password | string | Yes | Password must be at least 8 characte |
| token | string | Yes | Bearer authentication token (Header) |
| mobile | Number | Yes | Mobile/phone number |
| trans_id | Number | Yes | Unique sequence integer number |
| amount | Number | Sometimes | Type of request / Type of pay |
| type | String | Sometimes | pay / number type |
| code | string | Sometimes | weta offer code |