Run your API flows
The back-end you build using Koxy AI works with any front-end environment, language, or framework.
Below We give few examples on how to run your API flows and cloud functions.
Javascript
Using Koxy JS
import { koxyAPI } from 'koxy-js';
// Initialize (replace CLOUDSPACE_TOKEN with your Cloudspace token)
const api = new koxyAPI("CLOUDSPACE_TOKEN");
// Set request parameters
const parameters = {
"param1": "value1"
};
// Set request headers
const headers = {
"customHeader": "customValue"
};
// Run API flow (replace "main" with the flow name you want to run)
const data = await api.run("main", parameters, headers);
// Run cloud function
const functionData = await api.runFunction("function_name");
Using fetch
const url = "https://koxy-cloud.deno.dev";
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": CLOUDSPACE_TOKEN
},
body: JSON.stringify({
flow: "main",
parameters: {"param1": "value1"} // send your own parameters
})
};
fetch(url, options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
HTTP requests
curl -i -X POST https://koxy-cloud.deno.dev \
-H 'Authorization: CLOUDSPACE_TOKEN' \
-H 'Content-Type: application/json' \
--data '{"flow": "main", "parameters": '{"param1": "value1"}'}'
Python
import requests
url = "https://koxy-cloud.deno.dev"
headers = {
"Content-Type": "application/json",
"Authorization": CLOUDSPACE_TOKEN
}
data = {
"flow": "main",
"parameters": {"param1": "value1"} # send your own parameters
}
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
print(response.json())
else:
print(response.status_code)