How to set up authentication and headers to use the ExPay API.
Last updated 6 months ago
The Excoinz API typically uses a secret key for Restful API authentication. The secret key can be found in .
Check my secret key value in
Add your secret key to the header
const axios = require('axios'); const REQUEST_PATH = 'ANY_PATH'; const headers = { 'EXCOINZ_SECRET': `Bearer ${process.env.SECRET_KEY}`, 'Content-Type': 'application/json' }; const data = { //ANY_DATA }; axios.post(`https://api.excoinz.com/${REQUEST_PATH}`, data, { headers: headers }) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error:', error.response.data); });
import okhttp3.*; import java.io.IOException; public static void main(String[] args) { String url = "https://api.excoinz.com/${ANY_PATH}"; String SECRET_KEY = "YOUR_SECRET_KEY"; OkHttpClient client = new OkHttpClient(); RequestBody body = RequestBody.create( MediaType.parse("application/json"), "{ //ANY_DATA }" ); Request request = new Request.Builder() .url(url) .post(body) .addHeader("EXCOINZ_SECRET", "Bearer " + SECRET_KEY) .addHeader("Content-Type", "application/json") .build(); try { Response response = client.newCall(request).execute(); System.out.println(response.body().string()); } catch (IOException e) { e.printStackTrace(); } }
<?php $SECRET_KEY = 'YOUR_SECRET_KEY'; $url = "https://api.excoinz.com/${ANY_PATH}"; $data = json_encode(array( //ANY_DATA )); $headers = array( "EXCOINZ_SECRET: Bearer $SECRET_KEY", "Content-Type: application/json" ); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { echo $response; } curl_close($ch); ?>