Getting started overview
Getting started with Onyx Bazaar involves a series of steps designed to provide access to its public and commercial datasets via a RESTful API. The process begins with account registration, followed by the generation of API credentials. Once credentials are obtained, developers can make authenticated requests to the Onyx Bazaar API to retrieve data from the Onyx Data Lake, utilize the Onyx Query Engine, or explore the Onyx Data Catalog. Onyx Bazaar provides SDKs for Python, JavaScript, and Go to streamline common interactions.
This guide focuses on the foundational steps required to make a successful first API call, including:
- Creating an Onyx Bazaar account.
- Generating and securing API keys.
- Making an authenticated request using cURL, Python, and JavaScript.
- Identifying common next steps and troubleshooting tips.
A quick reference for the getting started process is available below:
| Step | What to do | Where |
|---|---|---|
| 1. Sign Up | Register for an Onyx Bazaar account. The Developer Plan offers a free tier. | Onyx Bazaar homepage |
| 2. Get API Keys | Generate your unique API key from the developer dashboard. | Onyx Bazaar Developer Dashboard |
| 3. Make Request | Execute a sample API call using cURL, Python, or JavaScript. | Your preferred development environment |
| 4. Explore Docs | Review the API reference for available endpoints and data models. | Onyx Bazaar API reference |
Create an account and get keys
To begin using the Onyx Bazaar API, you must first create an account. Onyx Bazaar offers a Developer Plan that includes 5,000 requests per month, which is suitable for initial exploration and prototyping.
Account Creation
- Navigate to the Onyx Bazaar homepage.
- Click on the "Sign Up" or "Get Started Free" button.
- Follow the prompts to register your account, providing necessary details such as email and a password.
- Verify your email address if prompted, to activate your account.
Generating API Keys
After successfully creating and logging into your account, you will need to generate an API key. This key authenticates your requests to the Onyx Bazaar API.
- Log in to your Onyx Bazaar Developer Dashboard.
- Locate the "API Keys" or "Credentials" section, typically found under a "Settings" or "Developer" menu.
- Click the "Generate New Key" button.
- Your API key will be displayed. It is crucial to copy this key immediately and store it securely. Onyx Bazaar typically only displays the full key once upon generation for security reasons.
API keys are a form of secret credential, similar to passwords. Best practices for API key management include avoiding hardcoding keys directly into source code, using environment variables, or secret management services. For web applications, consider proxying API requests through a backend server to prevent exposing keys to client-side code, as detailed in the Google Maps API key best practices documentation.
Your first request
Once you have your API key, you can make your first authenticated request to the Onyx Bazaar API. This example demonstrates fetching a list of available datasets from the Onyx Data Catalog endpoint. Replace YOUR_API_KEY with the key you generated.
Using cURL
cURL is a command-line tool for making HTTP requests and is useful for quick testing.
curl -X GET \
"https://api.onyxbazaar.com/v1/datasets" \
-H "X-Onyx-API-Key: YOUR_API_KEY" \
-H "Accept: application/json"
Using Python (with requests library)
Onyx Bazaar provides a Python SDK, but a direct requests example demonstrates the underlying HTTP interaction.
import requests
import os
api_key = os.environ.get("ONYX_API_KEY")
if not api_key:
print("Error: ONYX_API_KEY environment variable not set.")
exit()
headers = {
"X-Onyx-API-Key": api_key,
"Accept": "application/json"
}
url = "https://api.onyxbazaar.com/v1/datasets"
try:
response = requests.get(url, headers=headers)
response.raise_for_status() # Raise an exception for HTTP errors (4xx or 5xx)
data = response.json()
print(data)
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err}") # Python 3.6+
except requests.exceptions.ConnectionError as conn_err:
print(f"Connection error occurred: {conn_err}")
except requests.exceptions.Timeout as timeout_err:
print(f"Timeout error occurred: {timeout_err}")
except requests.exceptions.RequestException as req_err:
print(f"An unexpected error occurred: {req_err}")
Before running the Python example, ensure you have the requests library installed (pip install requests) and set your API key as an environment variable (e.g., export ONYX_API_KEY='YOUR_API_KEY' in Linux/macOS or $env:ONYX_API_KEY='YOUR_API_KEY' in PowerShell).
Using JavaScript (Node.js with node-fetch)
For Node.js environments, node-fetch provides a familiar Fetch API interface. Ensure you install it first: npm install node-fetch. Onyx Bazaar also offers a JavaScript SDK.
const fetch = require('node-fetch');
const apiKey = process.env.ONYX_API_KEY;
if (!apiKey) {
console.error('Error: ONYX_API_KEY environment variable not set.');
process.exit(1);
}
const headers = {
'X-Onyx-API-Key': apiKey,
'Accept': 'application/json'
};
const url = 'https://api.onyxbazaar.com/v1/datasets';
async function getDatasets() {
try {
const response = await fetch(url, {
method: 'GET',
headers: headers
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);
}
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Failed to fetch datasets:', error);
}
}
getDatasets();
Set your API key as an environment variable before running (e.g., export ONYX_API_KEY='YOUR_API_KEY').
Common next steps
After successfully making your first request, consider these common next steps to further integrate with Onyx Bazaar:
- Explore the API Reference: Dive into the Onyx Bazaar API reference documentation to discover all available endpoints, request parameters, and response structures. This details how to interact with the Onyx Query Engine and specific datasets within the Onyx Data Lake.
- Utilize SDKs: For Python, JavaScript, or Go projects, consider using the official Onyx Bazaar SDKs. SDKs often simplify API interactions, handling authentication, pagination, and error handling, which can accelerate development.
- Data Discovery: Use the Onyx Bazaar data explorer UI to visually discover and understand the structure of the available datasets before programmatic access. This can inform your API queries.
- Implement Advanced Queries: Experiment with filtering, sorting, and aggregation parameters described in the API reference to retrieve specific subsets of data.
- Monitor Usage: Keep an eye on your API usage through your Onyx Bazaar Developer Dashboard to stay within your plan limits (e.g., the 5,000 requests/month for the Developer Plan).
- Error Handling: Implement robust error handling in your applications to gracefully manage API rate limits, invalid requests, and other potential issues. The MDN Web Docs on HTTP status codes provide a general reference for common API response codes.
- Upgrade Plan: If your project requires more requests or storage, review the Onyx Bazaar pricing page to upgrade to a Standard Plan or contact sales for enterprise options.
Troubleshooting the first call
Encountering issues during your first API call is common. Here are some troubleshooting steps:
- Check API Key: Ensure your
X-Onyx-API-Keyheader contains the exact API key generated from your Onyx Bazaar Developer Dashboard. Typos or leading/trailing spaces are common errors. - Environment Variable: If using environment variables, verify that
ONYX_API_KEYis correctly set in your shell before running your script. - HTTP Status Codes:
401 Unauthorized: Indicates an invalid or missing API key. Double-check your key.403 Forbidden: Your API key might be valid, but lacks permissions for the requested resource, or your account may be suspended. Check your dashboard.404 Not Found: The endpoint URL might be incorrect. Verify the URL against the Onyx Bazaar API reference.429 Too Many Requests: You have exceeded your rate limit. Wait before retrying or consider upgrading your plan.5xx Server Error: An issue on Onyx Bazaar's side. Check the Onyx Bazaar status page (if available) or contact support.
- Network Connectivity: Confirm your development environment has internet access and no firewall is blocking outbound HTTPS requests to
api.onyxbazaar.com. - JSON Parsing: If you receive a successful response but your code fails to parse it, ensure the response content type is indeed
application/jsonand the body is valid JSON. - Consult Documentation: The Onyx Bazaar documentation provides detailed error codes and common solutions specific to their API.