InstaForeks Foreks-brokeri bilan ishlashdaga bir qator afzalliklardan tashqari endi kompaniyaning har bir mijozi yangi xizmatdan - Mijoz kabinetining APIsidan foydalanishi mumkin.
API — bu InstaForeks brokerining har bir mijozi foydalana oladigan kuchli funksiyalar kutubxonasidir. Mijozlar kabineti API funksiyasidan foydalanish har bir mijozga kabinetning asosiy funksionalini istagan veb-resursda joylashtirishga imkon beradi.
Mijozlar kabineti API servisidan foydalanish tufayli InstaForeks brokerining har bir mijozi ochiq va yopiq savdo bitimlari bo'yicha hisob-varag'i balansi bo'yicha, ma'lum vaqt oralig'ida yopiq lotlar, olingan bonuslar bo'yicha statistika, avtorizatsiyalar tarixi bo'yicha so'rovlar, shuningdek hisob-varag'i bo'yicha qo'shimcha axborot kabi opsiyalar to'plamidan foydalanish imkoniga bo'ladi.
Kirish darajalari
API- funksiyalariga kirish ikki xil daraja bo'yicha amalga oshiriladi, ular xavfsizlik darajalariga ko'ra farq qiladi.
Birinchi daraja - ochiq,ya'ni qo'shimcha parametrlarni kiritishga zarurat yo'q.
Ikkinchi daraja - yopiq. Kirish yopiq darajada bo'lganda, Siz taqdim etgan parametrlarga bog'liq holda APIga kirish faqat parol bo'yicha yoki IP parol yoki IP maska bo'yicha mumkin.
Shunday qilib, Mijoz kabineti APIsi servisidan foydalanuvchi har bir mijoz o'z savdo hisob-varag'ini InstaForeks brokeri saytida Mijoz kabinetiga tashrib buyurmasdan holatini nazorat qilish imkoniyatiga ega bo'ladi.
PHP misoli
$Login = 0; #Must be Changed
$apiPassword = "password"; #Must be Changed
$data = array("Login" => $Login, "Password" => $apiPassword);
$data_string = json_encode($data);
$apiAuthenticationMethod = ''; #Must be Changed
$ch = curl_init('https://client-api.instaforex.org/'.$apiAuthenticationMethod);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
$token = curl_exec($ch);
curl_close($ch);
$apiMethodUrl = ''; #Must be Changed
$ch = curl_init('https://client-api.instaforex.org/'.$apiMethodUrl.$Login); #possibly Must be Changed part with [$Login]. Depends on the method param
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('passkey: '.$token));
$result = curl_exec($ch);
echo $result;
C# misoli
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Text;
namespace ClientPartnerApiDemoProject{
class PartnerApiSample{
public void TestMethod(){
const int login = 000000;
const string pass = "your pass";
var token = GetToken(login, pass);
var result = GetCommissionRecords(login, token);
foreach (var trade in result){
Console.WriteLine("{0} {1}",trade.Partner, trade.BalanceRecords.Count);
}
}
public string GetToken(int login, string password){
var client = new HttpClient();
HttpContent tokenContent = new ObjectContent(typeof(AccessTokenRequest), new AccessTokenRequest { Login = login, Password = password }, new JsonMediaTypeFormatter());
var token = client.PostAsync("https://client-api.instaforex.org/api/Authentication/RequestPartnerApiToken", tokenContent).Result.Content.ReadAsStringAsync().Result;
return token;
}
public List
GetCommissionRecords(int login, string token){
var client = new HttpClient();
client.DefaultRequestHeaders.Add("passkey", token);
var result = client.GetAsync(string.Format("https://client-api.instaforex.org/partner/GetCommissionRecords/{0}", login)).Result.Content.ReadAsAsync>().Result;
return result;
}
public class AccessTokenRequest{
public int Login { get; set; }
public string Password { get; set; }
}
}
}