### Get a test access token Source: https://developers.reloadly.com/developer-tools/get-started/products-quickstart This cURL command demonstrates how to obtain a test access token from Reloadly's authorization server. ```curl curl -i -X POST https://auth.reloadly.com/oauth/token -H 'Content-Type: application/json' -d '{ "client_id": "qwcLzXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "client_secret": "7kscVxQZ32-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "grant_type": "client_credentials", "audience": "https://topups-sandbox.reloadly.com" }' ``` -------------------------------- ### Making a top-up Source: https://developers.reloadly.com/developer-tools/explore-integration-options/libraries-and-sdks Examples of making a top-up using different methods (phone and email) and currencies. ```Node let api = new AirtimeApi(ApiCredentials.ClientId, ApiCredentials .ClientSecret, null, Environment.SANDBOX); let operation = await api.topups(); let req0 = operation.send(new PhoneTopupRequest( /*The amount is in your Reloadly account currency*/ 15, operatorId, new Phone(/*Sender Phone*/ "+17862541236", "US"), /*Use local amount*/ false, new Phone(/*Recipient Phone*/ "+50936377111", "HT"), /*Optional, for your internal reference*/ "")); let transaction0 = await req0.execute(); let req1 = operation.send(new PhoneTopupRequest( /*The amount is two thousand Nigerian Naira*/ 2000, operatorId, new Phone(/*Sender Phone*/ "+17862541236", "US"), /*Use local amount*/ true, new Phone(/*Recipient Phone*/ "+2349045150334", "NG"))); let transaction1 = await req1.execute(); let req2 = operation.send(new EmailTopupRequest( /*The amount is in your Reloadly account currency*/ 15m, operatorId, /*Recipient email*/ "example@nauta.com.cu", /*Sender phone*/ new Phone(/*Sender Phone*/ "+17862541236", "US" ) }; let transaction2 = await req2.execute(); ``` -------------------------------- ### Node.js Authentication Usage Source: https://developers.reloadly.com/developer-tools/explore-integration-options/libraries-and-sdks Example of how to authenticate and get an access token using the Node.js SDK. ```javascript var api = new AuthenticationApi(ApiCredentials.ClientId, ApiCredentials.ClientSecret, ServiceURLs.AIRTIME_SANDBOX); var operation = api.clientCredentials(); var request = operation.getAccessToken(); var response = await request.execute(); console.log("access token: " + response.access_token); ``` -------------------------------- ### Node.js Installation Source: https://developers.reloadly.com/developer-tools/explore-integration-options/libraries-and-sdks Install the Node.js SDK for authentication and airtime services. ```bash npm install @reloadly/reloadly.authentication npm install @reloadly/reloadly.airtime ``` -------------------------------- ### Make an airtime or data top-up Source: https://developers.reloadly.com/developer-tools/get-started/products-quickstart This code snippet shows how to make an airtime or data top-up using the Airtime API. It includes the endpoint, headers, and a JSON payload with details such as operator ID, amount, recipient information, and sender information. ```curl curl -i -X POST https://topups.reloadly.com/topups \ -H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ -d '{ \ "operatorId": 535, \ "amount": 3168.4, \ "useLocalAmount": false, \ "customIdentifier": "This is example identifier 130", \ "recipientEmail": "peter@nauta.com.cu", \ "recipientPhone": { \ "countryCode": "GB", \ "number": 447951731337 \ }, \ "senderPhone": { \ "countryCode": "CA", \ "number": 11231231231 \ }' ``` -------------------------------- ### Check Wallet Balance using API Source: https://developers.reloadly.com/wallet This cURL example demonstrates how to make a GET request to the /accounts/balance endpoint to retrieve your wallet's balance. ```cURL curl -i -X GET https://topups.reloadly.com/accounts/balance -H 'Authorization: Bearer ' ``` -------------------------------- ### Successful API Response Example Source: https://developers.reloadly.com/wallet An example of a successful response when checking the wallet balance via the API. ```JSON { "balance": 5000, "currencyCode": "USD", "currencyName": "US Dollar", "updatedAt": "2022-12-04 08:45:51" } ``` -------------------------------- ### Successful top-up response Source: https://developers.reloadly.com/developer-tools/get-started/products-quickstart This JSON object represents a successful response from Reloadly after making an airtime top-up. It includes transaction details, status, amounts, dates, and balance information. ```json { "transactionId": 33469, "status": "SUCCESSFUL", "operatorTransactionId": null, "customIdentifier": "airtime-top-up", "recipientPhone": "971503971821", "recipientEmail": null, "senderPhone": "11231231231", "countryCode": "AE", "operatorId": 1100, "operatorName": "Etisalat United Arab Emirates", "discount": 41.6, "discountCurrencyCode": "NGN", "requestedAmount": 832, "requestedAmountCurrencyCode": "NGN", "deliveredAmount": 5.6, "deliveredAmountCurrencyCode": "AED", "transactionDate": "2022-06-06 10:57:48", "pinDetail": null, "fee": 2.99891, "balanceInfo": { "oldBalance": 809811.69103, "newBalance": 809021.29103, "cost": 790.4, "currencyCode": "NGN", "currencyName": "Nigerian Naira", "updatedAt": "2022-06-06 14:57:48" } ``` -------------------------------- ### Airtime Top-Up Request in Sandbox Source: https://developers.reloadly.com/developer-tools/sandbox This cURL command shows an example of an airtime top-up request made in the sandbox environment using the obtained access token. ```cURL curl -i -X POST https://topups-sandbox.reloadly.com/topups -H 'Authorization: Bearer ' -H 'Content-Type: application/json' -d '{ "operatorId": 1100, "amount": 832, "useLocalAmount": false, "customIdentifier": "airtime-top-up", "recipientEmail": "jeanb@reloadly.com", "recipientPhone": { "countryCode": "AE", "number": 0503971821 }, "senderPhone": { "countryCode": "CA", "number": 11231231231 } }' ``` -------------------------------- ### Get a Sandbox Access Token Source: https://developers.reloadly.com/developer-tools/sandbox This cURL command demonstrates how to request a test access token from Reloadly's authorization URL. ```cURL curl -i -X POST https://auth.reloadly.com/oauth/token -H 'Content-Type: application/json' -d '{ "client_id": "rzcLzvMmxZ919IVPgQlr6MDxiJRkEyjA", "client_secret": "7qpcVxQZ44-DDe1PBoZkM4b7WGnUBY-600Tkaol88NOrPn8yoeojMgQALtFGuDC", "grant_type": "client_credentials", "audience": "https://topups-sandbox.reloadly.com" }' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.