SMS
Consulter le solde
Récupère le solde SMS disponible sur le compte
GET
/
balance
Consulter le solde
curl --request GET \
--url https://api.dexchange-sms.com/api/v1/balance \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.dexchange-sms.com/api/v1/balance"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.dexchange-sms.com/api/v1/balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dexchange-sms.com/api/v1/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.dexchange-sms.com/api/v1/balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.dexchange-sms.com/api/v1/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dexchange-sms.com/api/v1/balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"statusCode": 401,
"message": "Unauthorized",
"error": "Unauthorized"
}
{
"statusCode": 404,
"message": "User not found",
"error": "Not Found"
}
Description
Cet endpoint permet de consulter le nombre d’unités SMS disponibles sur votre compte.Exemple de requête
curl -X GET https://api.dexchange-sms.com/api/v1/balance \
-H "X-Api-Key: VOTRE_CLE_API"
const response = await fetch('https://api.dexchange-sms.com/api/v1/balance', {
method: 'GET',
headers: {
'X-Api-Key': 'VOTRE_CLE_API'
}
});
const data = await response.json();
console.log(`Solde: ${data.solde_sms} SMS`);
import requests
response = requests.get(
'https://api.dexchange-sms.com/api/v1/balance',
headers={
'X-Api-Key': 'VOTRE_CLE_API'
}
)
data = response.json()
print(f"Solde: {data['solde_sms']} SMS")
<?php
$ch = curl_init('https://api.dexchange-sms.com/api/v1/balance');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Api-Key: VOTRE_CLE_API'
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
echo "Solde: " . $data['solde_sms'] . " SMS";
Réponse
string
L’adresse email associée au compte
integer
Le nombre d’unités SMS disponibles
string
Type de compte :
prepay (solde prépayé) ou postpay (facturation
différée). Pour un compte postpay, solde_sms reflète la limite de crédit.Exemple de réponse réussie
{
"email": "[email protected]",
"solde_sms": 1500,
"type": "prepay"
}
Erreurs possibles
{
"statusCode": 401,
"message": "Unauthorized",
"error": "Unauthorized"
}
{
"statusCode": 404,
"message": "User not found",
"error": "Not Found"
}
Bonnes pratiques
Vérifiez votre solde avant les envois en masse : Avant d’envoyer une campagne SMS, assurez-vous d’avoir suffisamment de crédits en vérifiant votre solde.
Rechargement : Pour recharger votre solde, connectez-vous à votre tableau de bord et effectuez un paiement.
⌘I
Consulter le solde
curl --request GET \
--url https://api.dexchange-sms.com/api/v1/balance \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.dexchange-sms.com/api/v1/balance"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.dexchange-sms.com/api/v1/balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dexchange-sms.com/api/v1/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.dexchange-sms.com/api/v1/balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.dexchange-sms.com/api/v1/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dexchange-sms.com/api/v1/balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"statusCode": 401,
"message": "Unauthorized",
"error": "Unauthorized"
}
{
"statusCode": 404,
"message": "User not found",
"error": "Not Found"
}