Authentication overview
Inferdo's API authentication system is designed to provide secure and controlled access to its computer vision services, including the Image Recognition API and Object Detection API. The core mechanism for authentication involves the use of API keys, which serve as unique identifiers for your application and authorize it to make requests. When a request is made to an Inferdo endpoint, the API key is transmitted to verify the request's origin and ensure it comes from an authorized user or service.
This approach simplifies integration while maintaining a necessary level of security for accessing sensitive machine learning models. Inferdo recommends following standard security practices for API key management to prevent unauthorized access and potential misuse of your account. The system is built to support various application architectures, from server-side applications to client-side integrations where appropriate security measures are in place.
Supported authentication methods
Inferdo primarily supports API key authentication. This method is common for web APIs due to its simplicity and effectiveness when correctly implemented. An API key is a secret token that grants access to your Inferdo account and its associated resources.
| Method | When to Use | Security Level |
|---|---|---|
| API Key (Bearer Token) | Server-side applications, internal tools, mobile app backends. | High (when securely stored and transmitted over HTTPS). |
| API Key (Query Parameter) | Not recommended for production. Limited use in testing or specific client-side scenarios with strict origin policies. | Low (prone to URL logging and exposure). |
For most integrations, the API key should be sent as a Bearer Token in the Authorization header of your HTTP requests. This method is preferred over passing the key as a query parameter because it keeps the key out of server logs and browser history, reducing exposure risk. The Inferdo API reference details how to structure these requests.
Getting your credentials
To access Inferdo's APIs, you need to obtain an API key from your Inferdo dashboard. The process generally involves these steps:
- Sign Up/Log In: Navigate to the Inferdo homepage and either sign up for a new account or log in to an existing one. Inferdo offers a free tier that includes 500 API calls per month, allowing you to generate an API key for testing and development.
- Access Dashboard: Once logged in, go to your user dashboard.
- Locate API Keys Section: Look for a section typically labeled "API Keys," "Developers," or "Settings."
- Generate New Key: If you don't have an existing key or wish to create a new one for a specific project, select the option to "Generate New API Key." You might be prompted to give your key a descriptive name to help you manage multiple keys.
- Copy Your Key: After generation, your new API key will be displayed. It's crucial to copy this key immediately and store it securely, as it often won't be shown again for security reasons. If you lose it, you'll typically need to revoke it and generate a new one.
Inferdo's documentation provides a step-by-step guide on generating and managing API keys within the platform.
Authenticated request example
Once you have your API key, you can use it to authenticate your requests to Inferdo's APIs. The key should be passed in the Authorization header as a Bearer token. Here are examples for Python and Node.js, the primary languages Inferdo supports with SDKs:
Python Example
Using the requests library for an Image Recognition API call:
import requests
import os
INFERDO_API_KEY = os.environ.get("INFERDO_API_KEY") # Load from environment variable
API_ENDPOINT = "https://api.inferdo.io/v1/image/recognize"
headers = {
"Authorization": f"Bearer {INFERDO_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"image_url": "https://example.com/path/to/your/image.jpg"
}
try:
response = requests.post(API_ENDPOINT, headers=headers, json=payload)
response.raise_for_status() # Raise an exception for HTTP errors
print("Success:", response.json())
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err}")
except Exception as err:
print(f"Other error occurred: {err}")
Node.js Example
Using the node-fetch library (or built-in fetch in newer Node.js versions) for an Object Detection API call:
import fetch from 'node-fetch'; // For Node.js versions without native fetch
const INFERDO_API_KEY = process.env.INFERDO_API_KEY; // Load from environment variable
const API_ENDPOINT = "https://api.inferdo.io/v1/object/detect";
async function detectObjects(imageUrl) {
if (!INFERDO_API_KEY) {
console.error("INFERDO_API_KEY environment variable not set.");
return;
}
try {
const response = await fetch(API_ENDPOINT, {
method: 'POST',
headers: {
'Authorization': `Bearer ${INFERDO_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
image_url: imageUrl
})
});
if (!response.ok) {
const errorBody = await response.text();
throw new Error(`HTTP error! Status: ${response.status}, Body: ${errorBody}`);
}
const data = await response.json();
console.log("Success:", data);
} catch (error) {
console.error("Error during object detection:", error);
}
}
detectObjects("https://example.com/path/to/another/image.png");
These examples demonstrate loading the API key from environment variables, which is a critical security practice, and then including it in the Authorization header.
Security best practices
Securing your Inferdo API keys is paramount to protect your account from unauthorized access and potential billing misuse. Adhere to these best practices:
- Environment Variables: Never hardcode API keys directly into your source code. Instead, load them from environment variables. This prevents keys from being committed to version control systems (like Git) and exposed in public repositories. Both Python and Node.js examples above demonstrate this approach. The Google Cloud documentation on API key best practices further elaborates on this and other recommendations.
- HTTPS/SSL: Always ensure that all communication with Inferdo's API endpoints occurs over HTTPS (HTTP Secure). This encrypts the data in transit, including your API key, protecting it from interception by malicious actors. Inferdo's API endpoints are designed to enforce HTTPS.
- Restrict IP Addresses (where possible): If Inferdo offers IP restriction features for API keys (check your dashboard settings), limit the IP addresses that can use a specific key to only those of your servers or applications. This adds an extra layer of security, making the key unusable from unauthorized locations.
- Principle of Least Privilege: If Inferdo supports granular permissions for API keys, assign only the minimum necessary permissions to each key. For instance, if a key only needs to perform image recognition, do not grant it access to model training or account management functions.
- Regular Key Rotation: Periodically rotate your API keys. This means generating a new key, updating your applications to use the new key, and then revoking the old key. This practice limits the window of exposure for a compromised key. The Inferdo API key management guide will show you how to revoke old keys.
- Monitoring and Alerting: Implement monitoring for unusual API usage patterns associated with your keys. High volumes of requests from unexpected locations or sudden spikes in usage could indicate a compromised key. Inferdo's dashboard may offer usage analytics to help with this.
-
Secure Storage: Store API keys securely in your environment. For serverless functions or containerized applications, utilize secret management services (e.g., AWS Secrets Manager, Google Secret Manager, Azure Key Vault) provided by your cloud provider. For local development, use
.envfiles and ensure they are excluded from version control. - Client-Side Caution: Avoid embedding API keys directly into client-side code (e.g., JavaScript in a web browser, mobile app binaries) unless strictly necessary and protected by strong domain restrictions or other security measures. If client-side access is required, consider using proxy servers to mediate requests and hide the API key, or use temporary, short-lived tokens if Inferdo supports them.