loading...

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
  • GET. Requests data from a resource.
  • POST. Submits data to a resource to process.
  • PUT. Updates a resource
  • PATCH. Partially updates a resource.
  • DELETE. Deletes a resource.
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

{
    "status_code": 201,
    "description": "Created.",
    "data": {
        "user": {
            "name": "full user name",
            "username": "userName",
            "email": "email@ect.com",
            "mobile": "967XXXXXXXXX",
            "balance": 0,
            "balance_ceiling": 0,
            "balance_type": "prepaid",
            "env": "Postman Runtime 0.0-unknown",
            "created_at": 1603345214
        }
    }
}

                                                
422 unprocessable entity

    {
        "status_code": 422,
        "description": "unprocessable entity.",
        "data": [
            "The name field is required.",
            "The username field is required.",
            "The email field is required.",
            "The password field is required.",
            "The password confirmation field is required.",
            "The mobile field is required."
        ]
    }

                                                

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

{
    "status_code": 200,
    "description": "Success.",
    "token": "ehjrexaioijkv1qilcjhbgcioijiuzi1nij9.eyjpc3mioijo
    dhrwolwvxc9sb2nhbghvc3q6odawmfwvyxbpxc9sb2dpbiisimlhdci6mtu
    5ote3otmymcwizxhwixntk5mtgyoiwlcjuymyioje1otkxnjkzmjasimp
    0asi6ik1vnmu2whzfzuq4s0o2nludgtlcjzdwiiojewmdawlcjwcnyioii4n2u
    wewfxzwy5zfqxntgxmmzkrwm5nze1m2exnguwyja6nzu0nmfhitt.ffqtxvvj
    e1mlt2jpfeiirglyxbzryup6bpebpsinwia"
    "exp_date": 1603432173
}

                                
422 unprocessable entity

{
    "status_code": 422,
    "description": "unprocessable entity.",
    "data": [
        "the username field is required.",
        "the password field is required."
    ]
}

                                
401 Authentication failure

{
    "status_code": 401,
    "description": "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

    {
        "status_code": 200,
        "description": "Success.",
        "data": [
            {
                "code": "1",
                "telecom_company": "TeleYemen - Line",
                "category": "XYZ",
                "amount_sent": 600,
                "WETA_offer": [
                    {
                        "extra_balance": "10%"
                    }
                ],
                "processing_fees": "10%",
                "total_cost": "XYZ",
                "recevied": 660
            },
            {
                "code": "2",
                "telecom_company": "TeleYemen - Line",
                "category": "XYZ",
                "amount_sent": 1410,
                "WETA_offer": [
                    {
                        "extra_balance": "20%"
                    }
                ],
                "processing_fees": "10%",
                "total_cost": "XYZ",
                "recevied": 1692
            },
            {
                "code": "3",
                "telecom_company": "TeleYemen - Line",
                "category": "XYZ",
                "amount_sent": 2000,
                "WETA_offer": [
                    {
                        "extra_balance": "30%"
                    }
                ],
                "processing_fees": "10%",
                "total_cost": "XYZ",
                "recevied": 2600
            },
            {
                "code": "4",
                "telecom_company": "TeleYemen - Line",
                "category": "XYZ",
                "amount_sent": 2500,
                "WETA_offer": [
                    {
                        "extra_balance": "35%"
                    }
                ],
                "processing_fees": "10%",
                "total_cost": "XYZ",
                "recevied": 3375
            },
            {
                "code": "5",
                "telecom_company": "TeleYemen - Line",
                "category": "XYZ",
                "amount_sent": 5000,
                "WETA_offer": [
                    {
                        "extra_balance": "60%"
                    }
                ],
                "processing_fees": "10%",
                "total_cost": "XYZ",
                "recevied": 8000
            },
            {
                "code": "6",
                "telecom_company": "TeleYemen - Line",
                "category": "XYZ",
                "amount_sent": 10000,
                "WETA_offer": [
                    {
                        "extra_balance": "70%"
                    }
                ],
                "processing_fees": "10%",
                "total_cost": "XYZ",
                "recevied": 17000
            }
        ]
    }

                                
401 authentication failure

{
    "message ": "Token not provided",
    "status_code": 401
}

                                
422 unprocessable entity

{
    "status_code": 422,
    "description": "unprocessable entity.",
    "data": [
        "the mobile field is required.",
    ]
}

                                

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

{
    "status_code": 200,
    "description": "Success.",
    "data": [
        {
            "status_code": 200,
            "description": "Success.",
            "data": {
                "trans_id": 1,
                "sent_amount": 600,
                "recevied": 660,
                "processing_fees": "XYZ",
                "price": "XYZ",
                "remain_amount": "XYZ",
                "Operator": "XYZ",
            }
        }
    ]
}

                                
401 authentication failure

{
    "message ": "Token not provided",
    "status_code": 401
}

                                
422 unprocessable entity

    {
        "status_code": 422,
        "description": "unprocessable entity.",
        "data": [
            "The mobile field is required."
            "The trans id field is required.",
            "The code field is required.",
            "The type field is required."
        ]
    }

                                

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

{
    "status_code": 200,
    "description": "Success.",
    "data": {
        "offers": [
            {
            "offerId": "P400001",
            "offerName": "Internet",
            "offerStartDate": "20131110171807",
            "offerEndDate": "20991231235959"
            }
        ]
    }
}

                                
401 authentication failure

{
"message ": "Token not provided",
"status_code": 401
}

                                
422 unprocessable entity

{
    "status_code": 422,
    "description": "unprocessable entity.",
    "data": [
        "the mobile field is required.",
    ]
}

                                

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

{
    "status_code": 200,
    "description": "Success.",
    "data": {
        "mobile_type": "0",
        "availableCredit": "42.57",
        "balance": "42.57"
    }
}

                                                            
401 authentication failure

{
    "message ": "Token not provided",
    "status_code": 401
}

                                                            
422 unprocessable entity

{
    "status_code": 422,
    "description": "unprocessable entity.",
    "data": [
        "the mobile field is required.",
        "the type field is required."
    ]
}

                                                            

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

{
    "status_code": 200,
    "description": "Success.",
    "data": {
        "RESULTCODE": "0",
        "RESULTDESC": "UNKOWN_STATUS"
    }
}

                                                            
401 authentication failure

{
    "message ": "Token not provided",
    "status_code": 401
}

                                                            
422 unprocessable entity

{
    "status_code": 422,
    "description": "unprocessable entity.",
    "data": [
        "the mobile field is required.",
    ]
}

                                                            

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

{
    "status_code": 200,
    "description": "Success.",
    "data": {
        "balance": 5000
    }
}

                                                            
401 authentication failure

{
    "message ": "Token not provided",
    "status_code": 401
}

                                                            
422 unprocessable entity

{
    "status_code": 422,
    "description": "unprocessable entity.",
    "data": [
        "the mobile field is required.",
    ]
}

                                                            

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

    {
        "status_code": 200,
        "description": "Success.",
        "data": {
            "isDone": 0,
            "isBan": 1,
            "mobile": "967XXXXXXXXX",
            "reason": 400
        }
    }

                                
401 authentication failure

{
    "message ": "Token not provided",
    "status_code": 401
}

                                
422 unprocessable entity

{
    "status_code": 422,
    "description": "unprocessable entity.",
    "data": [
        "the mobile field is required.",
        "the trans id field is required."
    ]
}

                                

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

    {
        "status_code": 200,
        "description": "success."
    }

401 authentication failure

{
    "message ": "Token not provided",
    "status_code": 401
}

422 unprocessable entity

{
    "status_code": 422,
    "description": "password filed is required."
}

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

{
    "status_code": 200,
    "description": "User logged out successfully"
}

401 authentication failure

{
    "message ": "Token not provided",
    "status_code": 401
}

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