Below are some examples demonstrating how to make requests to each of the API methods described earlier.
1. Create Order
python javascript
These examples use the requests
library, which is a popular choice for making HTTP requests in Python. If you haven't already, you will need to install the requests
library using pip:
Copy import requests
import json
url = "https://api.aryze.io/v1/orders"
headers = { "Content-Type" : "application/json" , "x-api-key" : "YOUR_API_KEY" }
data = {
"customerName" : "John Doe" ,
"chainId" : "1" ,
"amount" : "1000" ,
"mintWallet" : "0x1234567890abcdef" ,
"customerOrder" : "Order123" ,
"stableCoin" : "eUSD"
}
response = requests . post (url, headers = headers, data = json. dumps (data))
print (response.text)
To use axios
for making HTTP requests in JavaScript, you first need to ensure that axios
is installed in your project. If you haven't installed it yet, you can do so by running:
Copy const axios = require ( 'axios' );
const url = "https://api.aryze.io/v1/orders" ;
const headers = {
"Content-Type" : "application/json" ,
"x-api-key" : "YOUR_API_KEY"
};
const data = {
"customerName" : "John Doe" ,
"chainId" : "1" ,
"amount" : "1000" ,
"mintWallet" : "0x1234567890abcdef" ,
"customerOrder" : "Order123" ,
"stableCoin" : "eUSD"
};
axios .post (url , data , { headers : headers })
.then (response => {
console .log ( response .data);
})
.catch (error => {
console .error ( 'Error:' , error . response .data);
});
2. Get All Orders
python javascript
Copy import requests
url = "https://api.aryze.io/v1/orders"
headers = { "x-api-key" : "YOUR_API_KEY" }
response = requests . get (url, headers = headers)
print (response.text)
Copy const axios = require ( 'axios' );
const url = "https://api.aryze.io/v1/orders" ;
const headers = {
"x-api-key" : "YOUR_API_KEY"
};
axios .get (url , { headers : headers })
.then (response => {
console .log ( response .data);
})
.catch (error => {
console .error ( 'Error:' , error .response ? error . response .data : error .message);
});
3. Get Order By ID
python javascript
Copy import requests
order_id = "unique_order_id"
url = f "https://api.aryze.io/v1/orders/ { order_id } "
headers = { "x-api-key" : "YOUR_API_KEY" }
response = requests . get (url, headers = headers)
print (response.text)
Copy const axios = require ( 'axios' );
const order_id = "unique_order_id" ;
const url = `https://api.aryze.io/v1/orders/ ${ order_id } ` ;
const headers = {
"x-api-key" : "YOUR_API_KEY"
};
axios .get (url , { headers : headers })
.then (response => {
console .log ( response .data);
})
.catch (error => {
console .error ( 'Error:' , error .response ? error . response .data : error .message);
});
4. Update Order
python javascript
Copy import requests
import json
order_id = "unique_order_id"
url = f "https://api.aryze.io/v1/orders/ { order_id } "
headers = { "Content-Type" : "application/json" , "x-api-key" : "YOUR_API_KEY" }
data = {
"amount" : "1500" ,
"orderStatus" : "Processing"
}
response = requests . put (url, headers = headers, data = json. dumps (data))
print (response.text)
Copy const axios = require ( 'axios' );
const order_id = "unique_order_id" ;
const url = `https://api.aryze.io/v1/orders/ ${ order_id } ` ;
const headers = {
"Content-Type" : "application/json" ,
"x-api-key" : "YOUR_API_KEY"
};
const data = {
"amount" : "1500" ,
"orderStatus" : "Processing"
};
axios .put (url , data , { headers : headers })
.then (response => {
console .log ( response .data);
})
.catch (error => {
console .error ( 'Error:' , error .response ? error . response .data : error .message);
});
These examples show how to use Python and JavaScript to interact with the Aryze Orders API, including how to send GET and POST requests, include headers, and serialize data to JSON for the request body. Remember to adjust parameters as needed to match your requirements.
Last updated 3 months ago