Fetch lists of banks
Countries we support : There are limitations to countries we supports, However here are the list of countries our Fetch bank api supports.
Nigeria (NGN)
Ghana (GHS)
South Africa (ZAR)
United State (USA)
Kenya (KES)
Uganda (UGX)
Tanzania (TZ)
Note : The list of our supported nations does, however, occasionally vary, thus it is appropriate to always request our supported-country-list to confirm which countries we support before making any more requests. https://api.quaapay/v1/supported-countries/
Make your "Request"
https://github.com/quaapay/fetch-our-supported-banks
curl --request POST \
--url "https://apis.quaapay/v1/banks" \
--header "Content-Type: application/json" \
--header "Authorization: your_auth_key" \
--data '{
"country": "us"
}'
Certainly! The curl request you provided is used to make an HTTP POST request to the URL "https://apis.quaapay/v1/banks" with a JSON payload. Here's a breakdown of the components in the request:
curl: This is the command-line tool used for making HTTP requests.--request POST: This specifies that the request method is POST.--url "https://apis.quaapay/v1/banks": This specifies the URL to which the request will be sent.--header "Content-Type: application/json": This sets the "Content-Type" header to indicate that the request payload is in JSON format.--data '{ "country": "us" }': This is the data you're sending in the request body. In this case, it's a JSON object with a key-value pair"country": "us".
Putting it all together, the curl request sends a POST request to the specified URL with a JSON payload containing the "country" field set to "us". The server at the specified URL will process the request and respond accordingly.
<?php
// API endpoint
$apiEndpoint = "https://apis.quaapay/v1/banks";
// Data to send
$data = array(
"country" => "us"
);
// Initialize cURL session
$curl = curl_init();
// Set cURL options
curl_setopt($curl, CURLOPT_URL, $apiEndpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: YourProductKeyHere' // Add your Product Key here
));
// Execute cURL session and get response
$response = curl_exec($curl);
// Close cURL session
curl_close($curl);
// Output the response
echo $response;
?>
Certainly! The PHP code I provided is using the cURL library to make a POST request to an API endpoint. Let's break down each part of the code step by step:
API Endpoint: This is the URL of the API you want to send a request to. In your example, it's
"https://apis.quaapay/v1/banks".Data to Send: You want to send the parameter
"country"with the value"us"as part of the POST request. This data is stored in the$dataarray.Initializing cURL Session:
curl_init(): This function initializes a new cURL session.
Setting cURL Options:
CURLOPT_URL: Specifies the URL of the API endpoint.CURLOPT_RETURNTRANSFER: Tells cURL to return the response as a string instead of directly outputting it.CURLOPT_POST: Indicates that this is a POST request.CURLOPT_POSTFIELDS: Sets the data to be sent in the request. Here, we're usingjson_encode()to convert the$dataarray to a JSON-encoded string.CURLOPT_HTTPHEADER: Specifies an array of headers to include in the request. In this case, we set theContent-Typeheader to indicate that we're sending JSON data.
Executing cURL Session:
curl_exec($curl): Executes the cURL session and sends the request to the API endpoint. It returns the response from the server.
Closing cURL Session:
curl_close($curl): Closes the cURL session to free up resources.
Outputting the Response:
echo $response;: Outputs the response received from the API endpoint. This will be the JSON response containing information from the API.
By following these steps, the PHP code sends a POST request to the specified API endpoint with the "country" parameter set to "us". It then receives the response from the API and outputs it to the browser.
Please note that error handling, validation, and security measures (such as sanitizing input) should also be considered in a production environment.
Now, let's break down the code step by step:
Including jQuery Library:
We include the jQuery library using a
<script>tag in the<head>of the HTML document.
Data to Send:
We create an object called
requestDatathat contains the data we want to send in the POST request. In this case, we set the"country"property to"us".
AJAX POST Request (
$.ajax()):url: Specifies the URL of the API endpoint.type: Specifies the request method, which is"POST"in this case.data: Sets the data to be sent in the request. We useJSON.stringify()to convert therequestDataobject to a JSON string.contentType: Specifies the content type of the data being sent, which is"application/json".success: A callback function that is executed if the request is successful. It receives the response from the server, which we log usingconsole.log(response).error: A callback function that is executed if there is an error in the request. It receives the error object, which we log usingconsole.error("Error:", error).
By following these steps, the jQuery code sends a POST request to the specified API endpoint with the "country" parameter set to "us". It then logs the response to the browser console when the request is successful and logs any errors to the console if they occur.
Now, let's break down the code step by step:
Importing the
requestsLibrary:We import the
requestslibrary, which is a popular library for making HTTP requests in Python. If you haven't installed it yet, you can do so usingpip install requests.
Data to Send:
We create a dictionary called
request_datathat contains the data we want to send in the POST request. In this case, we set the"country"key to"us".
API Endpoint URL:
We define the URL of the API endpoint that we want to send the POST request to.
Sending the POST Request (
requests.post()):We use the
requests.post()function to send the POST request.The first argument is the URL of the API endpoint.
The
jsonparameter is used to send JSON-encoded data in the request. We pass therequest_datadictionary, and therequestslibrary takes care of converting it to JSON.
Checking the Response:
We check the status code of the response using
response.status_code. If the status code is 200 (OK), it means the request was successful.If the request was successful, we print the JSON response using
response.json().If there was an error, we print the error response using
response.text.
By following these steps, the Python code sends a POST request to the specified API endpoint with the "country" parameter set to "us". It then checks the response status code and prints either the response data or an error message based on the result.
Please note that in a real-world scenario, error handling, security considerations, and best practices are important aspects to consider.
Now, let's break down the code step by step:
Importing Dependencies:
Import the required libraries:
dart:convertfor JSON encoding and decoding, andhttpfor making HTTP requests.
Defining the Flutter App:
Create a Flutter app with an
AppBarand a centeredElevatedButton.
Making the POST Request (
http.post()):In the
_MyHomePageStateclass, define thefetchDatamethod that makes the POST request.Create a
Uriinstance with the API endpoint URL.Use
http.post()to send the POST request.Provide the
Content-Typeheader as"application/json"and the request body as a JSON-encoded map with the"country"key set to"us".
Checking the Response:
Check the status code of the response using
response.statusCode. If it's 200 (OK), print the response body usingresponse.body.If there was an error, print the response body as an error message.
Building the UI:
Build the UI with a button that triggers the
fetchDatamethod when pressed.
By following these steps, the Flutter code sends a POST request to the specified API endpoint with the "country" parameter set to "us". It then checks the response status code and prints either the response data or an error message based on the result.
Remember to add the http package to your pubspec.yaml file and run flutter pub get before using this code.
Pub.dev for add http to your pubspec.yaml
https://pub.dev/packages/http
Last updated