Skip to content

Using the Apical API

Implementing the Apical API in Your AI Applications

Welcome, developers! This guide will walk you through the process of integrating the Apical API into your AI applications. By following these steps, you’ll be able to leverage our vast marketplace of AI APIs to enhance your projects.

Getting Started

Before you begin, make sure you have:

  1. An Apical account
  2. Your API key (available in your account dashboard)

API Basics

The Apical API consists of two main endpoints:

  1. Search: For discovering APIs
  2. Execute: For calling specific API actions

Base URL

All API requests should be made to:

https://api.apical.com/v1

Authentication

Include your API key in the headers of all requests:

Authorization: Bearer YOUR_API_KEY

Searching for APIs

To search for APIs, make a POST request to the /main endpoint:

const response = await fetch('https://api.apical.com/v1/main', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
search: 'image recognition',
detailed: true // Optional, set to true for more detailed results
})
});
const data = await response.json();

Response Structure

The search response will include:

  • resource: Name of the API
  • description: Brief description of the API
  • availableActions: List of actions (endpoints) available for the API

Executing API Calls

To execute an API call, use the same /main endpoint with the action ID:

const response = await fetch('https://api.apical.com/v1/main', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
id: 'action_id_here',
params: {
// Parameters specific to the API action
}
})
});
const result = await response.json();

Error Handling

The API uses standard HTTP status codes. In case of an error, the response will include an error field with a description of the problem.

Rate Limiting

Be aware of rate limits for both searching and executing APIs. These limits are specified in your account dashboard.

Best Practices

  1. Cache search results when possible to reduce API calls.
  2. Use the detailed parameter in searches judiciously to balance between information completeness and response time.
  3. Implement proper error handling to manage API call failures gracefully.

Example: Image Recognition Integration

Here’s a simple example of how to integrate an image recognition API:

async function recognizeImage(imageUrl) {
// First, search for an image recognition API
const searchResponse = await fetch('https://api.apical.com/v1/main', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
search: 'image recognition'
})
});
const searchData = await searchResponse.json();
const imageRecognitionAction = searchData.availableActions[0]; // Assuming the first action is what we want
// Now, execute the image recognition API
const executeResponse = await fetch('https://api.apical.com/v1/main', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
id: imageRecognitionAction.id,
params: {
image_url: imageUrl
}
})
});
return await executeResponse.json();
}
// Usage
const result = await recognizeImage('https://example.com/image.jpg');
console.log(result);

This example demonstrates how to search for an image recognition API and then use it to analyze an image.

Remember, the Apical API is designed to be flexible and powerful. Don’t hesitate to explore and experiment with different APIs to find the perfect fit for your application!

If you have any questions or need further assistance, please don’t hesitate to reach out to our support team. Happy coding!