Authentication
Introduction
Moyasar's Platform API uses API Keys to authenticate requests.
Your platform key will be generated by Moyasar's staff and shared through a secure medium during onboarding.
Basic Auth
Authentication to the API is performed via HTTP Basic Auth.
You should send the Basic authentication scheme with the following fields:
- Username: <your_api_key>
- Password: <EMPTY>
Important
The password must be kept empty
HTTPS
All API calls must be made over HTTPS; any API call made over HTTP will be rejected.
Example
Here is an example of the List Merchants endpoint in different programming languages
- PHP
- Ruby
- Java
- Python
- Node.js
- Curl
- C#
require 'vendor/autoload.php'; // Make sure Guzzle is installed via Composer
use GuzzleHttp\Client;
$client = new Client();
$response = $client->get('https://apimig.moyasar.com/v1/merchants', [
'auth' => ['platform_123', ''],
]);
echo $response->getBody()->getContents();
# frozen_string_literal: true
require 'http'
HTTP.basic_auth(user: 'platform_123', pass: '')
.get('https://apimig.moyasar.com/v1/merchants')
String url = "https://apimig.moyasar.com/v1/merchants";
String username = "platform_123";
String password = "";
String credentials = username + ":" + password;
String encodedCredentials = java.util.Base64.getEncoder().encodeToString(credentials.getBytes());
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Basic " + encodedCredentials)
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
import requests
url = 'https://apimig.moyasar.com/v1/merchants'
response = requests.get(url, auth=('platform_123', ''))
print(response.text)
const axios = require('axios');
let config = {
method: 'get',
url: 'https://apimig.moyasar.com/v1/merchants',
auth: {
username: "platform_123",
password: ""
}
};
axios.request(config)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error);
});
curl https://apimig.moyasar.com/v1/merchants -u platform_123:
using (var client = new HttpClient())
{
string url = "https://apimig.moyasar.com/v1/merchants";
string username = "platform_123";
string password = "";
var byteArray = Encoding.ASCII.GetBytes($"{username}:{password}");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
var response = await client.GetStringAsync(url);
Console.WriteLine(response);
}
tip
You must replace platform_123 with your API key.