# Crédits

## URL

<mark style="color:red;">`GET`</mark> `https://api.smspartner.fr/v1/me`

#### **Paramètres obligatoires**

<table><thead><tr><th width="142">Nom</th><th>Valeur</th></tr></thead><tbody><tr><td><code>apiKey</code></td><td><a href="https://my.smspartner.fr/dashboard/api">Votre clé API</a></td></tr></tbody></table>

#### Paramètres optionnels

<table><thead><tr><th width="142">Nom</th><th>Valeur</th></tr></thead><tbody><tr><td><code>_format</code></td><td><code>json</code>  ou  <code>xml</code></td></tr></tbody></table>

#### Requêtes

{% tabs %}
{% tab title="PHP" %}

```php
<?php
 
        // Prepare data for GET request
        $data = 'apiKey=YOUR_API_KEY';
 
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL,'https://api.smspartner.fr/v1/me?'.$data);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_TIMEOUT, 10);
 
 
        $result = curl_exec($curl);
        curl_close($curl);
 
        // Process your response here
        echo $result;
?>
```

{% endtab %}

{% tab title="VB.net" %}

```vbnet
Imports System.IO
Imports System.Net
 
Module Module1
 
  Sub Main()
 
    Dim base_url As String = "http://api.smspartner.fr/v1/"
    Dim apiKey As String = "VOTRE_APIKEY"
 
    #check credits
    Dim url As String
    url = base_url & "me" & "?apiKey=" & apiKey
 
    Dim credits As String
    credits = apiRequest("GET", url, Nothing)
 
  End Sub
 
  Function apiRequest(method As String, url As String, parameters As String) As String
 
    Dim request As HttpWebRequest
    request = WebRequest.Create(url)
    request.Method = method
    request.Timeout = 10000   # timeout in ms
    request.ContentType = "application/json; charset=utf-8"
    request.ContentLength = 0
 
    #set POST data
    If Not String.IsNullOrEmpty(parameters) Then
      request.ContentLength = parameters.Length
      Using reqStream As StreamWriter = New StreamWriter(request.GetRequestStream())
        reqStream.Write(parameters)
      End Using
    End If
 
    #get response
    Dim returnValue As String = Nothing
    Using response As HttpWebResponse = request.GetResponse()
      If response.StatusCode = HttpStatusCode.OK Then
        Using resStream = response.GetResponseStream()
          If resStream IsNot Nothing Then
            Using reader As New StreamReader(resStream)
              returnValue = reader.ReadToEnd()
            End Using
          End If
        End Using
      End If
    End Using
    apiRequest = returnValue
 
  End Function
 
End Module
```

{% endtab %}

{% tab title="Python" %}

```python
# std
import logging
import json
from collections import OrderedDict
 
# 3p
import requests
 
API_KEY = "MY API KEY"
URL = "https://api.smspartner.fr/v1"
 
class SMSPartner():
    def get_balance(self):
		url = URL + "/me?apiKey=" + API_KEY
		r = requests.get(url)
		r_json = r.json()
		if r_json.get("success") == True:
			print(r_json)
			status = True
		else:
			print(r_json)
			status = False
		return status
```

{% endtab %}

{% tab title="cURL" %}

```
curl -H "Content-Type: application/json" -X GET  https://api.smspartner.fr/v1/me?apiKey=xxx
```

{% endtab %}

{% tab title="Nodejs" %}

```javascript
const https = require('https');

// Préparer les données pour la requête GET
let data = 'apiKey=YOUR API KEY';
let url = 'https://api.smspartner.fr/v1/me?' + data;

https.get(url, (res) => {
  let data = '';

  // Un morceau de données a été reçu.
  res.on('data', (chunk) => {
    data += chunk;
  });

  // La totalité de la réponse a été reçue. Imprimer le résultat.
  res.on('end', () => {
    console.log(JSON.parse(data));
  });

}).on("error", (err) => {
  // Un message d'erreur sera imprimé en cas d'erreur.
  console.log("Erreur: " + err.message);
});
```

{% endtab %}

{% tab title="JAVA" %}

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class CreditsSms {
    public static void main(String[] args) {
        try {
            String apiKey = "your_api_key";
            String url = "https://api.smspartner.fr/v1/me?apiKey=" + apiKey;

            URL obj = new URL(url);
            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
            con.setRequestMethod("GET");

            int responseCode = con.getResponseCode();

            if (responseCode == HttpURLConnection.HTTP_OK) {
                BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
                String inputLine;
                StringBuilder response = new StringBuilder();

                while ((inputLine = in.readLine()) != null) {
                    response.append(inputLine);
                }
                in.close();

                System.out.println(response.toString());
            } else {
                System.out.println("GET request failed. Response Code: " + responseCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```

{% endtab %}

{% tab title="Swift" %}

```swift
import SwiftUI

struct Credits: View {
    @State private var credit: String = "Loading..."

    var body: some View {
        VStack {
            Text("Mon crédit")
                .font(.title)
                .padding()

            Text(credit)
                .font(.system(size: 20))
                .padding()
        }
        .onAppear(perform: getCredit)
    }

    func getCredit() {
        let apiKey = "Your-api-key"
        let urlString = "https://api.smspartner.fr/v1/me?apiKey=\(apiKey)"

        guard let url = URL(string: urlString) else {
            print("URL inválida")
            return
        }

        let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
            if let error = error {
                print("Error: \(error)")
            } else if let data = data {
                let result = String(data: data, encoding: .utf8)
                DispatchQueue.main.async {
                    credit = result ?? "Error"
                }
            }
        }

        task.resume()
    }
}

struct CreditView_Previews: PreviewProvider {
    static var previews: some View {
        Credits()
    }
}
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	apiKey := "your_api_key"
	url := "https://api.smspartner.fr/v1/me?apiKey=" + apiKey

	response, err := http.Get(url)
	if err != nil {
		fmt.Println("GET request failed:", err)
		return
	}
	defer response.Body.Close()

	if response.StatusCode == http.StatusOK {
		bodyBytes, err := ioutil.ReadAll(response.Body)
		if err != nil {
			fmt.Println("Failed to read response body:", err)
			return
		}
		fmt.Println(string(bodyBytes))
	} else {
		fmt.Println("GET request failed. Response Code:", response.StatusCode)
	}
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
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 = "YOUR_API_KEY";
        var uri = new Uri($"https://api.smspartner.fr/v1/me?apiKey={apiKey}");

        HttpResponseMessage response = await client.GetAsync(uri);

        if (response.IsSuccessStatusCode)
        {
            var result = await response.Content.ReadAsStringAsync();
            Console.WriteLine(result);
        }
        else
        {
            Console.WriteLine("GET request failed with status code: " + response.StatusCode);
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### **Réponse**

{% tabs %}
{% tab title="json" %}
{% code fullWidth="true" %}

```json
{
    "success": true,
    "code": 200,
    "user": {
        "username": "exemple@email.com",
        "firstname": "John",
        "lastname": "Doe"
    },
    "credits": {
        "creditSms": 269082,
        "creditSmsECO": 444570,
        "creditHlr": 2045023,
        "toSend": 0,
        "solde": "10225.119",
        "currency": "EUR",
        "balance": "10225.119"
    }
}
```

{% endcode %}
{% endtab %}

{% tab title="xml" %}

```xml
<?xml version='1.0' encoding='UTF-8'?>
<result>
    <entry>true</entry>
    <entry>200</entry>
    <entry>
        <username>exemple@email.com</username>
        <firstname>John</firstname>
        <lastname>Doe</lastname>
    </entry>
    <entry>
        <entry>269070</entry>
        <entry>444551</entry>
        <entry>2044937</entry>
        <entry>0</entry>
        <entry>
            <![CDATA[10224.688]]>
        </entry>
        <entry>
            <![CDATA[EUR]]>
        </entry>
        <entry>
            <![CDATA[10224.688]]>
        </entry>
    </entry>
</result>
```

{% endtab %}
{% endtabs %}

#### **Code erreurs**

| Code de réponse | Réponse                 |
| --------------- | ----------------------- |
| 10              | Clé API incorrecte      |
| 200             | Tout s’est bien passé ! |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.docpartner.dev/api/sms-partner/credits.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
