Introduction to Clore API
Overview
The Clore API provides developers with powerful tools to manage GPU resources, automate workflows, monitor server status, and handle financial transactions on the Clore platform. This API allows you to interact programmatically with the Clore Marketplace, enabling advanced control over rentals, pricing, server configurations, and more.
In this introductory article, we will cover:
Setting up access to the Clore API
Authentication process
Basic API requests and response formats
Example use cases with code snippets
1. Getting Started: Setting Up Your API Access
To begin working with the Clore API, you need an API key, which acts as an authentication token to securely interact with the API. Follow these steps:
Obtain Your API Key
Visit Clore Wallet and create an account if you haven’t already.
Navigate to the API section in your account settings.
Generate a new API key, ensuring to save it securely as it will grant access to your resources.
Setting Up the Authorization Header The Clore API requires each request to include an authentication header. Here’s how to structure it:
headers = { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" }
2. Making Your First API Call
Let’s start with a simple request to check your wallet balance using the /wallets endpoint. This endpoint returns a list of wallets associated with your account, including balances and other details.
Example Code: Fetching Wallet Balance
Expected Response:
3. Exploring Core Endpoints
a) Listing Servers Available for Rent
The /marketplace endpoint provides details on all available servers in the Clore Marketplace, including specifications, rental prices, and availability status.
Example Code: Retrieving Marketplace Data
4. Working with Server Configurations
Use the /server_config endpoint to retrieve configuration details of a specific server you own.
Example Code: Fetching Server Configuration
5. Error Handling and Response Codes
The Clore API returns different status codes to indicate success or failure:
0- Normal1- Database Error2- Invalid Input Data3- Invalid API Token4- Invalid Endpoint5- Exceeded request limit (1 request/second)
In your code, it's essential to handle these response codes for robust error management. Here's a basic example:
6. Use Case: Automated Wallet Balance Monitoring
Suppose you want to automate the process of monitoring wallet balances and receive alerts if the balance drops below a specific threshold.
Example Code: Wallet Balance Alert
7. Conclusion
This introductory guide has provided a foundational understanding of Clore API, covering basic requests, authentication, and essential endpoints. In the following articles, we will delve deeper into more complex use cases, including automated pricing adjustments, server configuration management, and dynamic resource allocation using Clore’s robust API capabilities.
Last updated