### Make DRIP API Calls (Bash, Node.js, Python)
Source: https://docs.drip.re/developer/quickstart
Demonstrates how to make initial DRIP API calls to retrieve realm information and member counts using cURL, Node.js, and Python. Requires an API key and Realm ID. These examples show a quick way to get started with basic API interactions.
```bash
# 1. Get your API key from Admin > Developer > Project API
# 2. Replace YOUR_API_KEY and YOUR_REALM_ID below
# 3. Run this command
curl -X GET "https://api.drip.re/api/v1/realms/YOUR_REALM_ID" \
-H "Authorization: Bearer YOUR_API_KEY"
```
```javascript
// npm install node-fetch
const response = await fetch('https://api.drip.re/api/v1/realms/YOUR_REALM_ID', {
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});
console.log(await response.json());
```
```python
# pip install requests
import requests
r = requests.get('https://api.drip.re/api/v1/realms/YOUR_REALM_ID',
headers={'Authorization': 'Bearer YOUR_API_KEY'})
print(r.json())
```
--------------------------------
### Getting Started with DRIP API
Source: https://docs.drip.re/api-reference/introduction
Steps to get started with the DRIP API, including reading the developer guide, choosing an API, and obtaining an API key.
```APIDOC
## Getting Started
### 1. Read the Developer Guide
Before diving into the API reference, we recommend reading our comprehensive [Developer Guide](/developer/quickstart) which covers Quick Start, Authentication, Core Concepts, API Clients, and Best Practices.
### 2. Choose Your API
* **New Projects**: Use the [Current API](#current-api-recommended) for all new integrations.
* **Existing Projects**: Plan your [migration from Legacy API](#migration-guide) to Current API.
### 3. Get Your API Key
1. Visit the [DRIP Dashboard](https://app.drip.re).
2. Navigate to your realm settings.
3. Generate an API client in the [API Clients](/developer/api-clients) section.
4. Copy your API key and keep it secure.
```
--------------------------------
### GET /api/v1/realms/{realm_id}
Source: https://docs.drip.re/developer/quickstart
Retrieves information about a specific realm (project) using its ID.
```APIDOC
## GET /api/v1/realms/{realm_id}
### Description
Retrieves information about a specific realm (project) using its ID. This is often the first step in authenticating and identifying your project within the DRIP API.
### Method
GET
### Endpoint
`/api/v1/realms/{realm_id}`
### Parameters
#### Path Parameters
- **realm_id** (string) - Required - The unique identifier for the realm.
#### Query Parameters
None
#### Request Body
None
### Request Example
```bash
curl -X GET "https://api.drip.re/api/v1/realms/YOUR_REALM_ID" \
-H "Authorization: Bearer YOUR_API_KEY"
```
### Response
#### Success Response (200)
- **id** (string) - The unique identifier for the realm.
- **name** (string) - The name of the realm.
- **scopes** (array) - A list of scopes associated with the realm's API client.
#### Response Example
```json
{
"id": "YOUR_REALM_ID",
"name": "My Project Name",
"scopes": ["realm:read", "members:read"]
}
```
```
--------------------------------
### Example Encrypted Data and Installation URL (JavaScript)
Source: https://docs.drip.re/developer/multi-realm-apps
This snippet shows an example of encrypted data and a generated installation URL. The encrypted data is a string that would be used to create a secure installation link for an application. Ensure the appId and the encrypted data are correctly formatted when constructing the URL.
```javascript
// Encrypted Data Example:
"U2FsdGVkX1+L+8EzH4IbNHRgXLSOh9OUCzPZ8tjVdNA1M5..."
// Generated Installation URL:
"https://app.drip.re/admin/apps/authorize?appId=your-app-id&epfo=U2FsdGVkX1%2BL%2B8EzH4IbNHRgXLSOh9OUCzPZ8tjVdNA1M5..."
```
--------------------------------
### App Store Listing Description Example (Markdown)
Source: https://docs.drip.re/developer/app-store
Provides an example of a compelling app store description using Markdown, highlighting key features and target audience. This is crucial for App Store Optimization (ASO).
```markdown
# Good Example
**Community Analytics Pro** gives realm administrators deep insights into member engagement, activity patterns, and growth trends.
Key Features:
- Real-time engagement dashboards
- Member activity heatmaps
- Custom report generation
- Automated insights and recommendations
Perfect for community managers who want to understand and grow their communities with data-driven decisions.
```
--------------------------------
### GET /websites/drip_re/app_installs
Source: https://docs.drip.re/api-reference/apps/get-app-installs
Retrieves a paginated list of realms where the app has been installed. This endpoint is useful for understanding the distribution of your application.
```APIDOC
## GET /websites/drip_re/app_installs
### Description
Get paginated list of realms that have installed this app.
### Method
GET
### Endpoint
/websites/drip_re/app_installs
### Parameters
#### Query Parameters
- **page** (integer) - Optional - The page number to retrieve.
- **pageSize** (integer) - Optional - The number of items to return per page.
### Request Example
```json
{
"example": "GET /websites/drip_re/app_installs?page=1&pageSize=20"
}
```
### Response
#### Success Response (200)
- **realms** (array) - A list of realms that have installed the app.
- **realmId** (string) - The ID of the realm.
- **realmName** (string) - The name of the realm.
- **installDate** (string) - The date the app was installed.
- **pagination** (object) - Information about the pagination.
- **currentPage** (integer) - The current page number.
- **totalPages** (integer) - The total number of pages available.
- **totalItems** (integer) - The total number of items across all pages.
#### Response Example
```json
{
"example": {
"realms": [
{
"realmId": "realm-123",
"realmName": "Example Realm",
"installDate": "2023-10-27T10:00:00Z"
}
],
"pagination": {
"currentPage": 1,
"totalPages": 5,
"totalItems": 100
}
}
}
```
```
--------------------------------
### Basic DRIP API Client Setup and Authentication
Source: https://docs.drip.re/developer/examples
Demonstrates how to initialize a DRIP API client with your API key and realm ID. This setup includes methods for making authenticated requests to the API, handling responses, and basic error management. It's designed for easy integration into your applications.
```javascript
class DripClient {
constructor(apiKey, realmId) {
this.apiKey = apiKey;
this.realmId = realmId;
this.baseUrl = 'https://api.drip.re/api/v1';
}
async request(method, endpoint, data = null) {
const url = `${this.baseUrl}${endpoint}`;
const options = {
method,
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
}
};
if (data) {
options.body = JSON.stringify(data);
}
try {
const response = await fetch(url, options);
if (!response.ok) {
const error = await response.json();
throw new Error(`API Error: ${response.status} - ${error.message || 'Unknown error'}`);
}
return response.json();
} catch (error) {
console.error('DRIP API Error:', error);
throw error;
}
}
}
// Usage
const client = new DripClient('your_api_key', 'your_realm_id');
```
```python
import requests
import json
class DripClient:
def __init__(self, api_key, realm_id):
self.api_key = api_key
self.realm_id = realm_id
self.base_url = 'https://api.drip.re/api/v1'
self.session = requests.Session()
self.session.headers.update({
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
})
def request(self, method, endpoint, data=None):
url = f"{self.base_url}{endpoint}"
try:
response = self.session.request(method, url, json=data)
response.raise_for_status()
return response.json()
except requests.exceptions.HTTPError as e:
print(f'DRIP API Error: {e}')
raise
except Exception as e:
print(f'Request failed: {e}')
raise
# Usage
client = DripClient('your_api_key', 'your_realm_id')
```
```bash
# Set your variables
DRIP_API_KEY="your_api_key_here"
REALM_ID="your_realm_id_here"
BASE_URL="https://api.drip.re/api/v1"
# Function to make API calls
drip_api() {
local method=$1
local endpoint=$2
local data=$3
if [ -n "$data" ]; then
curl -s -X "$method" "$BASE_URL$endpoint" \
-H "Authorization: Bearer $DRIP_API_KEY" \
-H "Content-Type: application/json" \
-d "$data"
else
curl -s -X "$method" "$BASE_URL$endpoint" \
-H "Authorization: Bearer $DRIP_API_KEY"
fi
}
# Usage
# drip_api GET "/realms/$REALM_ID"
```
--------------------------------
### Fetch DRIP Realm and Members Data (Python)
Source: https://docs.drip.re/developer/quickstart
Fetches realm information and member data from the DRIP API using the Python requests library. This example requires a DRIP API key (client secret) and a Realm ID. It demonstrates authenticated requests and handling potential errors.
```python
import requests
DRIP_API_KEY = 'your_client_secret_here'
REALM_ID = 'your_realm_id_here'
headers = {'Authorization': f'Bearer {DRIP_API_KEY}'}
try:
# Get your realm info
realm = requests.get(f'https://api.drip.re/api/v1/realms/{REALM_ID}', headers=headers).json()
print(f'🎉 Your realm: {realm["name"]}')
# Get some members
members = requests.get(f'https://api.drip.re/api/v1/realm/{REALM_ID}/members/search?type=drip-id&values=all', headers=headers).json()
print(f'👥 Member count: {len(members.get("data", []))}')
except Exception as error:
print(f'❌ Error: {error}')
```
--------------------------------
### GET /api/v1/realm/{realm_id}/members/search
Source: https://docs.drip.re/developer/quickstart
Searches for members within a specified realm based on provided criteria.
```APIDOC
## GET /api/v1/realm/{realm_id}/members/search
### Description
Searches for members within a specified realm based on provided criteria. This endpoint allows you to retrieve a list of members, often used for counting or filtering.
### Method
GET
### Endpoint
`/api/v1/realm/{realm_id}/members/search`
### Parameters
#### Path Parameters
- **realm_id** (string) - Required - The unique identifier for the realm.
#### Query Parameters
- **type** (string) - Required - The type of search query (e.g., `drip-id`).
- **values** (string) - Required - The values to search for (e.g., `all` to retrieve all members).
#### Request Body
None
### Request Example
```bash
curl -X GET "https://api.drip.re/api/v1/realm/YOUR_REALM_ID/members/search?type=drip-id&values=all" \
-H "Authorization: Bearer YOUR_API_KEY"
```
### Response
#### Success Response (200)
- **data** (array) - An array of member objects matching the search criteria.
- **total** (integer) - The total number of members found.
#### Response Example
```json
{
"data": [
{
"drip_id": "member1_drip_id",
"email": "member1@example.com"
},
{
"drip_id": "member2_drip_id",
"email": "member2@example.com"
}
],
"total": 2
}
```
```
--------------------------------
### Error Handling
Source: https://docs.drip.re/developer/quickstart
Common error codes and their explanations, including 401 Unauthorized, 403 Forbidden, 404 Not Found, and 429 Too Many Requests.
```APIDOC
## Error Handling
### 401 Unauthorized
**Problem**: Your API key is wrong or missing.
**Fix**: Double-check you're using the **Client Secret** (not Client ID) from the developer portal.
### 403 Forbidden
**Problem**: Your API client doesn't have the right scopes.
**Fix**: Go back to **Admin > Developer > Project API** and add more scopes to your client. Common scopes include `realm:read`, `members:read`, `members:write`, `points:write`.
### 404 Not Found
**Problem**: Wrong Realm ID or member doesn't exist.
**Fix**: Check your realm ID in the dashboard URL. For members, try searching first before updating.
### 429 Too Many Requests
**Problem**: You're making requests too fast.
**Fix**: Add a small delay between requests or use batch endpoints.
```
--------------------------------
### Generate Leaderboard (JavaScript)
Source: https://docs.drip.re/developer/guides/managing-members
Create a leaderboard by fetching member data and sorting them by their point balances. This example uses pseudo-code for fetching members and demonstrates sorting and slicing to get the top members. It requires the realm ID and an optional limit for the number of leaderboard entries.
```javascript
async function generateLeaderboard(realmId, limit = 10) {
// This would typically involve fetching multiple members
// and sorting by their point balances
const members = await searchMembers(realmId, 'drip-id', 'all'); // Pseudo-code, assuming searchMembers is defined elsewhere
return members
.sort((a, b) => b.pointBalances[0].balance - a.pointBalances[0].balance)
.slice(0, limit)
.map((member, index) => ({
rank: index + 1,
username: member.username,
points: member.pointBalances[0].balance
}));
}
```
--------------------------------
### GET /api/v1/realms/{realmId}/apps/{appId}/installs
Source: https://docs.drip.re/api-reference/apps/get-app-installs
Retrieves a paginated list of realms that have installed a specific app. Supports filtering, sorting, and searching.
```APIDOC
## GET /api/v1/realms/{realmId}/apps/{appId}/installs
### Description
Get paginated list of realms that have installed this app. Supports filtering, sorting, and searching by realm name or description.
### Method
GET
### Endpoint
/api/v1/realms/{realmId}/apps/{appId}/installs
### Parameters
#### Path Parameters
- **realmId** (string) - Required - Realm ID (24-character hexadecimal string).
- **appId** (string) - Required - App ID (24-character hexadecimal string).
#### Query Parameters
- **page** (integer) - Optional - Page number. Minimum: 1. Default: 1.
- **limit** (integer) - Optional - Number of items per page. Minimum: 1, Maximum: 100. Default: 10.
- **search** (string) - Optional - Search term for realm name or description.
- **sortBy** (string) - Optional - Field to sort by. Enum: `createdAt`, `updatedAt`, `realmName`, `memberCount`. Default: `createdAt`.
- **sortOrder** (string) - Optional - Sort order. Enum: `asc`, `desc`. Default: `desc`.
### Request Example
```json
{
"example": "Not applicable for GET request body"
}
```
### Response
#### Success Response (200)
- **data** (array) - Array of app installation objects.
- **id** (string) - Installation ID.
- **realmId** (string) - ID of the realm.
- **appId** (string) - ID of the app.
- **approvedScopes** (array) - List of approved scopes.
- **platformType** (string, nullable) - Type of the platform.
- **platformId** (string, nullable) - ID of the platform.
- **createdAt** (string) - Timestamp of creation (ISO 8601 format).
- **updatedAt** (string) - Timestamp of last update (ISO 8601 format).
- **realm** (object) - Details of the realm.
- **id** (string) - Realm ID.
- **name** (string) - Realm name.
- **description** (string, nullable) - Realm description.
- **imageUrl** (string, nullable) - URL of the realm image.
- **ownerId** (string) - ID of the realm owner.
- **owner** (object) - Details of the realm owner.
- **id** (string) - Owner ID.
- **displayName** (string, nullable) - Owner's display name.
- **username** (string, nullable) - Owner's username.
- **imageUrl** (string, nullable) - URL of the owner's image.
- **createdAt** (string) - Timestamp of realm creation (ISO 8601 format).
- **memberCount** (integer) - Number of members in the realm.
- **meta** (object) - Metadata for pagination.
- **total** (integer) - Total number of items.
- **page** (integer) - Current page number.
#### Response Example
```json
{
"data": [
{
"id": "60f5c1b0a1b2c3d4e5f6a7b8",
"realmId": "60f5c1b0a1b2c3d4e5f6a7b8",
"appId": "60f5c1b0a1b2c3d4e5f6a7b8",
"approvedScopes": ["read:profile"],
"platformType": "web",
"platformId": "web-123",
"createdAt": "2023-10-27T10:00:00Z",
"updatedAt": "2023-10-27T10:00:00Z",
"realm": {
"id": "60f5c1b0a1b2c3d4e5f6a7b8",
"name": "Example Realm",
"description": "A sample realm",
"imageUrl": "https://example.com/image.png",
"ownerId": "60f5c1b0a1b2c3d4e5f6a7b8",
"owner": {
"id": "60f5c1b0a1b2c3d4e5f6a7b8",
"displayName": "John Doe",
"username": "johndoe",
"imageUrl": "https://example.com/avatar.png"
},
"createdAt": "2023-10-27T09:00:00Z",
"memberCount": 100
}
}
],
"meta": {
"total": 50,
"page": 1
}
}
```
```
--------------------------------
### Fetch DRIP Realm and Members Data (cURL)
Source: https://docs.drip.re/developer/quickstart
Fetches realm information and member data from the DRIP API using cURL commands. This example requires a DRIP API key (client secret) and a Realm ID. It uses `jq` to parse the JSON output for realm name and member count.
```bash
# Set your variables
DRIP_API_KEY="your_client_secret_here"
REALM_ID="your_realm_id_here"
# Get realm info
echo "🎉 Your realm:"
curl -s "https://api.drip.re/api/v1/realms/$REALM_ID" \
-H "Authorization: Bearer $DRIP_API_KEY" | jq '.name'
# Get member count
echo "👥 Member count:"
curl -s "https://api.drip.re/api/v1/realm/$REALM_ID/members/search?type=drip-id&values=all" \
-H "Authorization: Bearer $DRIP_API_KEY" | jq '.data | length'
```
--------------------------------
### DRIP API Example Requests (cURL, JavaScript, Python)
Source: https://docs.drip.re/api-reference/authentication
These examples show how to make authenticated GET requests to the DRIP API using cURL, JavaScript (with fetch), and Python (with requests). All examples include the necessary `Authorization` header and `Content-Type` header.
```bash
curl -X GET "https://api.drip.re/api/v1/realms/YOUR_REALM_ID" \
-H "Authorization: Bearer YOUR_API_KEY_HERE" \
-H "Content-Type: application/json"
```
```javascript
const response = await fetch('https://api.drip.re/api/v1/realms/YOUR_REALM_ID', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY_HERE',
'Content-Type': 'application/json'
}
});
```
```python
import requests
headers = {
'Authorization': 'Bearer YOUR_API_KEY_HERE',
'Content-Type': 'application/json'
}
response = requests.get('https://api.drip.re/api/v1/realms/YOUR_REALM_ID', headers=headers)
```
--------------------------------
### Fetch DRIP Realm and Members Data (JavaScript)
Source: https://docs.drip.re/developer/quickstart
Fetches realm information and member data from the DRIP API using JavaScript's fetch API. This example requires a DRIP API key (client secret) and a Realm ID. It demonstrates authenticated requests and parsing JSON responses.
```javascript
const DRIP_API_KEY = 'your_client_secret_here';
const REALM_ID = 'your_realm_id_here';
async function getDripData() {
try {
// Get your realm info
const realm = await fetch(`https://api.drip.re/api/v1/realms/${REALM_ID}`, {
headers: { 'Authorization': `Bearer ${DRIP_API_KEY}` }
}).then(r => r.json());
console.log('🎉 Your realm:', realm.name);
// Get some members
const members = await fetch(`https://api.drip.re/api/v1/realm/${REALM_ID}/members/search?type=drip-id&values=all`, {
headers: { 'Authorization': `Bearer ${DRIP_API_KEY}` }
}).then(r => r.json());
console.log('👥 Member count:', members.data?.length || 0);
} catch (error) {
console.error('❌ Error:', error.message);
}
}
getDripData();
```
--------------------------------
### Search Members
Source: https://docs.drip.re/developer/quickstart
This endpoint allows you to search for members within your realm using various criteria such as username, Discord ID, or wallet address.
```APIDOC
## GET /api/v1/realm/{REALM_ID}/members/search
### Description
Searches for members within a realm based on specified criteria.
### Method
GET
### Endpoint
`/api/v1/realm/{REALM_ID}/members/search`
### Parameters
#### Path Parameters
- **REALM_ID** (string) - Required - The ID of the realm.
#### Query Parameters
- **type** (string) - Required - The type of search (e.g., `username`, `discord-id`, `wallet`).
- **values** (string) - Required - The value(s) to search for.
### Response
#### Success Response (200)
- **data** (array) - A list of members matching the search criteria.
- Each member object contains fields like `id`, `displayName`, `pointBalances`, etc.
#### Response Example
```json
{
"data": [
{
"id": "member_abc123",
"displayName": "Cool Member",
"pointBalances": [
{
"tokenName": "points",
"balance": 100
}
]
}
]
}
```
```
--------------------------------
### Scope Justification for DRIP App Store Submission (Good Example)
Source: https://docs.drip.re/developer/app-store
This JSON object demonstrates a good example of scope justification for a DRIP App Store submission. It lists requested scopes and provides clear, concise reasons for each, along with a summary of data usage.
```json
{
"requestedScopes": ["realm:read", "members:read", "points:write"],
"scopeJustification": {
"realm:read": "Display realm name and branding in analytics dashboard",
"members:read": "Generate engagement analytics and member insights",
"points:write": "Award points for completing external challenges and tasks"
},
"dataUsage": "Member data is used only for analytics generation and is not stored permanently or shared with third parties"
}
```
--------------------------------
### Onboard New Member with Welcome Bonus (JavaScript)
Source: https://docs.drip.re/developer/guides/managing-members
Set up new members by granting them a welcome bonus in points. This function updates the member's balance with a predefined amount. It requires the realm ID and the new member's ID.
```javascript
async function onboardNewMember(realmId, memberId) {
const welcomeBonus = 100;
const result = await updateMemberBalance(realmId, memberId, welcomeBonus); // Assuming updateMemberBalance is defined elsewhere
console.log(`Welcomed new member with ${welcomeBonus} points!`);
return result;
}
```
--------------------------------
### Award Points to a Member
Source: https://docs.drip.re/developer/quickstart
This endpoint allows you to award points to a specific member within your realm. You first need to search for the member to get their ID, then use the PATCH method to update their point balance.
```APIDOC
## PATCH /api/v1/realm/{REALM_ID}/members/{memberId}/point-balance
### Description
Awards a specified number of points (tokens) to a member.
### Method
PATCH
### Endpoint
`/api/v1/realm/{REALM_ID}/members/{memberId}/point-balance`
### Parameters
#### Path Parameters
- **REALM_ID** (string) - Required - The ID of the realm.
- **memberId** (string) - Required - The ID of the member to award points to.
#### Request Body
- **tokens** (integer) - Required - The number of points to award.
### Request Example
```json
{
"tokens": 100
}
```
### Response
#### Success Response (200)
- **message** (string) - Confirmation message.
- **data** (object) - Details of the updated point balance.
- **memberId** (string) - The ID of the member.
- **balance** (integer) - The new point balance.
#### Response Example
```json
{
"message": "Points awarded successfully.",
"data": {
"memberId": "member_abc123",
"balance": 150
}
}
```
```
--------------------------------
### Admin Setup - /authorize
Source: https://docs.drip.re/burn-ghosts-activity/admin-setup
Connects your Discord server to the DRIP Rewards system for token reward distribution. This is a required first step before hosting tournaments with token rewards.
```APIDOC
## POST /discord/authorize
### Description
Connects your Discord server to the DRIP Rewards system for token reward distribution. This command generates a DRIP authorization link, provides a DRIP bot install button if needed, links the server to a DRIP realm for automatic reward distribution, and enables token balance viewing and transactions.
### Method
POST
### Endpoint
/discord/authorize
### Parameters
#### Query Parameters
- **guild_id** (string) - Required - The ID of the Discord server to authorize.
### Request Example
```json
{
"guild_id": "123456789012345678"
}
```
### Response
#### Success Response (200)
- **authorization_url** (string) - The URL to complete the DRIP authorization process.
- **bot_install_url** (string) - The URL to install the DRIP bot if it's not already on the server.
#### Response Example
```json
{
"authorization_url": "https://drip.com/authorize?token=abcdef12345",
"bot_install_url": "https://discord.com/api/oauth2/authorize?client_id=987654321098765432&scope=bot&permissions=8"
}
```
```
--------------------------------
### Common Drip.re API Calls in JavaScript
Source: https://docs.drip.re/developer/examples
Provides a quick reference for essential Drip.re API operations in JavaScript. This includes examples for client authentication, retrieving realm information, searching members, awarding points, fetching leaderboards, and performing batch updates. These snippets are useful for getting started with common tasks.
```javascript
// Authentication & Setup
const client = new DripClient('api_key', 'realm_id');
// Get realm info
const realm = await client.request('GET', `/realms/${client.realmId}`);
// Search members
const members = await searchMembers(client, 'discord-id', 'user_id');
// Award points
await awardPoints(client, 'member_id', 100);
// Get leaderboard
const top10 = await getLeaderboard(client, 10);
// Batch update
await batchUpdatePoints(client, [
{ memberId: 'id1', tokens: 50 },
{ memberId: 'id2', tokens: 75 }
]);
```
--------------------------------
### Environment Configuration Example (.env.example)
Source: https://docs.drip.re/developer/best-practices
An example .env file demonstrating required environment variables for the DRIP API project. It includes API keys, realm IDs, and configuration for logging, caching, and rate limiting.
```dotenv
# .env.example
DRIP_API_KEY=your_api_key_here
DRIP_REALM_ID=your_realm_id_here
NODE_ENV=production
LOG_LEVEL=info
CACHE_TTL=300000
RATE_LIMIT_MAX_CONCURRENT=10
```
--------------------------------
### Test Drip.re API Authentication (JavaScript, Python, cURL)
Source: https://docs.drip.re/developer/authentication
Verifies API authentication by making a GET request to the Drip.re API realms endpoint. Provides examples for JavaScript, Python, and cURL, checking the response status and logging results.
```javascript
async function testAuth() {
try {
const response = await fetch(`https://api.drip.re/api/v1/realms/${DRIP_REALM_ID}`, {
headers: {
'Authorization': `Bearer ${DRIP_API_KEY}`
}
});
if (response.ok) {
const realm = await response.json();
console.log('✅ Authentication successful!');
console.log(`Connected to realm: ${realm.name}`);
} else {
console.log('❌ Authentication failed');
}
} catch (error) {
console.error('Error testing authentication:', error);
}
}
```
```python
def test_auth():
try:
response = requests.get(
f'https://api.drip.re/api/v1/realms/{DRIP_REALM_ID}',
headers={'Authorization': f'Bearer {DRIP_API_KEY}'}
)
if response.ok:
realm = response.json()
print("✅ Authentication successful!")
print(f"Connected to realm: {realm['name']}")
else:
print("❌ Authentication failed")
except Exception as e:
print(f"Error testing authentication: {e}")
```
```bash
# Test authentication
curl -X GET "https://api.drip.re/api/v1/realms/YOUR_REALM_ID" \
-H "Authorization: Bearer YOUR_API_KEY" \
-w "\nStatus: %{http_code}\n"
```
--------------------------------
### Migration Guide from Legacy API
Source: https://docs.drip.re/api-reference/introduction
Steps to migrate from the legacy DRIP API to the current API, including updating the base URL and authentication method.
```APIDOC
## Migration Guide
If you're currently using the legacy API, here's how to migrate:
### Step 1: Review Changes
* Compare legacy endpoints with current API equivalents.
* Update authentication method to use Bearer tokens.
* Review response format changes.
### Step 2: Update Base URL
```diff
- https://legacy-api.drip.re/v1
+ https://api.drip.re/api/v1
```
### Step 3: Update Authentication
```diff
- X-API-Key: your-api-key
+ Authorization: Bearer your-api-key
```
### Step 4: Test & Deploy
* Test all endpoints in our interactive playground.
* Update error handling for new response formats.
* Deploy and monitor your integration.