Statistique des envois
- Home
- Statistique des envois
Statistique des envois
Cette requête est utilisée pour récupérer les statistiques des envois sur une période précise. Elle permet de récupérer le nombre de SMS envoyés et le cout associé à ces envoiS.
URL
GET. https://api.smspartner.fr/v1/statistics/cost-resume?apiKey=API_KEY&interval=custom&from=21-10-2022&to=21-10-2022
Paramètres
Une limite de 5 requêtes par minute est appliquée.
Le paramètre interval est soit : | |
last_month | Le mois précédent |
---|---|
last_twelve_months | 12 derniers mois |
custom | dans ce cas les dates de début (from) et de fin (to) sont requises |
Requête
Exemple de requête:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
const https = require('https'); let apiKey = 'YOUR_API_KEY'; let url = `https://api.smspartner.fr/v1/statistics/cost-resume?apiKey=${apiKey}&interval=last_twelve_months`; // 12 derniers mois //interval=last_month // 1 dernier mois //interval=custom&from=21-10-2022&to=21-10-2022 // intervalle personnalisé https.get(url, (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { console.log(JSON.parse(data)); }); }).on("error", (err) => { console.log("Erreur: " + err.message); }); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class StatistiqueDesEnvois { public static void main(String[] args) { try { // Prepare data for GET request String apiKey = "YOUR_API_KEY"; String interval = "last_twelve_months"; //interval=last_month // 1 dernier mois //interval=custom&from=21-10-2022&to=21-10-2022 // intervalle personnalisé // Create GET request URL String urlString = "https://api.smspartner.fr/v1/statistics/cost-resume?" + "apiKey=" + apiKey + "&interval=" + interval; // Create URL object URL url = new URL(urlString); // Create HTTP connection HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setConnectTimeout(10000); connection.setReadTimeout(10000); // Send GET request int responseCode = connection.getResponseCode(); // Get response BufferedReader reader; if (responseCode >= 200 && responseCode <= 299) { reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); } else { reader = new BufferedReader(new InputStreamReader(connection.getErrorStream())); } StringBuilder response = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { response.append(line); } reader.close(); // Process your response here System.out.println(response.toString()); } catch (Exception e) { e.printStackTrace(); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import SwiftUI struct StatistiqueDesEnvois: View { @State private var result: String = "Loading..." var body: some View { VStack { Text("Statistique Des Envois") .font(.title) .padding() Text(result) .font(.system(size: 20)) .padding() } .onAppear(perform: getStatistics) } func getStatistics() { let apiKey = "YOUR_API_KEY" let interval = "last_twelve_months" let urlString = "https://api.smspartner.fr/v1/statistics/cost-resume?apiKey=\(apiKey)&interval=\(interval)" guard let url = URL(string: urlString) else { print("Invalid URL") result = "Invalid URL" return } var request = URLRequest(url: url) request.httpMethod = "GET" let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") DispatchQueue.main.async { self.result = "Error: \(error)" } } else if let data = data { let str = String(data: data, encoding: .utf8) DispatchQueue.main.async { self.result = str ?? "Error" } } } task.resume() } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
package main import ( "io/ioutil" "log" "net/http" "time" ) func main() { // Prepare data for GET request apiKey := "YOUR_API_KEY" interval := "last_twelve_months" // last month: "last_month", custom interval: "custom&from=21-10-2022&to=21-10-2022" // Create GET request URL url := "https://api.smspartner.fr/v1/statistics/cost-resume?" + "apiKey=" + apiKey + "&interval=" + interval // Create HTTP client client := &http.Client{Timeout: 10 * time.Second} // Send GET request resp, err := client.Get(url) if err != nil { log.Fatalf("Error sending request: %v", err) } defer resp.Body.Close() // Get response body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalf("Error reading response body: %v", err) } // Process your response here log.Printf("Response: %s", body) } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
using System; using System.Net.Http; using System.Threading.Tasks; class Program { private static readonly HttpClient client = new HttpClient(); static async Task Main(string[] args) { var apiKey = "VOTRE_CLÉ_API"; var interval = "last_twelve_months"; // Changer à "last_month" pour le dernier mois, "custom" pour un intervalle personnalisé var uri = new Uri($"https://api.smspartner.fr/v1/statistics/cost-resume?apiKey={apiKey}&interval={interval}"); // Ajoutez "&from=date&to=date" pour un intervalle personnalisé // Envoyer la requête GET HttpResponseMessage response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { // Lire la réponse var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); } else { // Afficher un message en cas d'échec de la requête GET Console.WriteLine("La requête GET a échoué avec le code de statut: " + response.StatusCode); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import requests apiKey = 'YOUR_API_KEY' url = f'https://api.smspartner.fr/v1/statistics/cost-resume?apiKey={apiKey}&interval=last_twelve_months' try: response = requests.get(url) response.raise_for_status() data = response.json() print(data) except requests.exceptions.RequestException as e: print(f"Erreur: {e}") Ou avec la bibliothèque 'urllib': import json from urllib import request, error apiKey = 'YOUR_API_KEY' url = f'https://api.smspartner.fr/v1/statistics/cost-resume?apiKey={apiKey}&interval=last_twelve_months' try: with request.urlopen(url) as response: data = json.load(response) print(data) except error.URLError as e: print(f"Erreur: {e.reason}") |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?php $apiKey = 'YOUR_API_KEY'; $url = 'https://api.smspartner.fr/v1/statistics/cost-resume?apiKey=' . $apiKey . '&interval=last_twelve_months'; // Initialise cURL session $ch = curl_init($url); // Set cURL options curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute cURL session and fetch the result $response = curl_exec($ch); // Handle errors if (curl_errno($ch)) { echo 'Erreur: ' . curl_error($ch); } else { // Decode the result $data = json_decode($response, true); print_r($data); } // Close cURL session curl_close($ch); ?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?php $apiKey = 'YOUR_API_KEY'; $url = 'https://api.smspartner.fr/v1/statistics/cost-resume?apiKey=' . $apiKey . '&interval=last_twelve_months'; // Initialise cURL session $ch = curl_init($url); // Set cURL options curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute cURL session and fetch the result $response = curl_exec($ch); // Handle errors if (curl_errno($ch)) { echo 'Erreur: ' . curl_error($ch); } else { // Decode the result $data = json_decode($response, true); print_r($data); } // Close cURL session curl_close($ch); ?> |
1 |
curl -H "Content-Type: application/json" -X GET "https://api.smspartner.fr/v1/statistics/cost-resume?apiKey=YOUR_API_KEY&interval=last_twelve_months" |
Exemple de résultat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
{ "success": true, "datas": [ { "month": "october", "year": "2021", "m": "10", "date": 1633039200, "type": "month", "cost": "49.174", "nb_send": "1210" }, { "month": "november", "year": "2021", "m": "11", "date": 1635721200, "type": "month", "cost": "67.674", "nb_send": "1409" }, |
© 2014 - 2023 NDA MEDIA. Tous droits réservés. Mentions légales