Making a Request:
To run the Neuron, make a POST request to the API endpoint, attaching the files you want to process. This can be done in many different ways tailored to your needs. The most basic way to call the API Axon is done through CURL.
curl -X POST [Your_Pipeline_API_Endpoint] \\
-H "api-key: [Your_API_Key]" \\
-F 'files=@/path/to/your/file1' \\
-F 'files=@/path/to/your/file2'
There are also libraries available for all major programming languages to directly invoke POST endpoints. The following examples show an implementation for Python and Javascript.
import requests
# Your API Key
API_KEY = 'your_api_key'
# Prepare the headers with your API Key
headers = {
'api-key': API_KEY,
}
# The files to be processed
files = {
'files': open('/path/to/your/file1', 'rb'),
'files': open('/path/to/your/file2', 'rb'),
}
# Your Pipeline API Endpoint
api_endpoint = '[Your_Pipeline_API_Endpoint]'
# Make the POST request
response = requests.post(api_endpoint, headers=headers, files=files)
# Handle the response
if response.status_code == 200:
print("Pipeline run successfully initiated.")
else:
print(f"Error: {response.text}")
const FormData = require('form-data');
const axios = require('axios');
const fs = require('fs');
const API_KEY = 'your_api_key';
const api_endpoint = '[Your_Pipeline_API_Endpoint]';
const form = new FormData();
form.append('files', fs.createReadStream('/path/to/your/file1'));
form.append('files', fs.createReadStream('/path/to/your/file2'));
axios.post(api_endpoint, form, {
headers: {
...form.getHeaders(),
'api-key': API_KEY,
},
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error(error.response.data);
});
Using Raw Data
In addition to using files as input to the Neuron it is also possible to directly digest raw data through the API Axon. To be correctly ingested all raw data should be sent under the data
form key to the endpoint. For CURL the following example demonstrates a raw data invocation:
curl -X POST [Your_Pipeline_API_Endpoint] \\
-H "api-key: [Your_API_Key]" \\
-F 'data="<your raw data text>"'
Troubleshooting
For problems with the pipeline invocation the response status codes can give you insights into the issue. The most common problems are explained below.