API Integration

Integrating the ApesPlay API

Integrating the ApesPlay API into your game allows you to send real-time data to our platform, enhancing your game's visibility and providing valuable insights. This guide explains how to integrate our API to send information such as active users, peak daily users, and other relevant metrics.

Overview of the ApesPlay API

The ApesPlay API enables you to:

  • Send Real-Time Data: Report active users, peak daily users, and other metrics.

  • Retrieve Data: Access data related to your game’s performance and player engagement.

  • Ensure Integration: Maintain smooth communication between your game and the ApesPlay platform.

API Endpoints

1. User Metrics Endpoint

URL: https://api.apesplay.com/v1/game/user-metrics

Method: POST

Description: This endpoint allows you to send real-time user metrics to ApesPlay.

Request Payload:

{
  "gameId": "your-game-id",
  "timestamp": "ISO8601-timestamp",
  "activeUsers": 123,
  "peakDailyUsers": 456
}

Parameters:

  • gameId (string): Unique identifier for your game.

  • timestamp (string): The current timestamp in ISO8601 format.

  • activeUsers (integer): Number of active users at the time of the report.

  • peakDailyUsers (integer): Maximum number of users observed in a day.

Response:

{
  "status": "success",
  "message": "User metrics updated successfully."
}

Errors:

  • 400 Bad Request: If the payload is missing required fields or contains invalid data.

  • 401 Unauthorized: If the API key is invalid or missing.

  • 500 Internal Server Error: For any server-side issues.

2. Game Information Endpoint

URL: https://api.apesplay.com/v1/game/info

Method: POST

Description: Update game information including status and statistics.

Request Payload:

{
  "gameId": "your-game-id",
  "status": "online",
  "currentPlayers": 50,
  "totalPlayers": 2000
}

Parameters:

  • gameId (string): Unique identifier for your game.

  • status (string): Current status of the game (e.g., "online", "offline").

  • currentPlayers (integer): Number of players currently in-game.

  • totalPlayers (integer): Total number of players who have played the game.

Response:

{
  "status": "success",
  "message": "Game information updated successfully."
}

Errors:

  • 400 Bad Request: If the payload is missing required fields or contains invalid data.

  • 401 Unauthorized: If the API key is invalid or missing.

  • 500 Internal Server Error: For any server-side issues.

Integration Steps

1. Obtain API Key

To interact with the ApesPlay API, you need an API key. Obtain your API key by:

  • Registering on the ApesPlay Developer Portal.

  • Navigating to the API section and generating a new key.

2. Implement API Calls

  • Set Up API Client: Use your preferred programming language to set up an HTTP client capable of making POST requests.

  • Send Data: Implement logic in your game to gather and send data to the relevant API endpoints at regular intervals or triggered events.

Example (Python using requests library):

import requests
import json

api_key = 'your-api-key'
url = 'https://api.apesplay.com/v1/game/user-metrics'

data = {
  "gameId": "your-game-id",
  "timestamp": "2024-07-30T14:30:00Z",
  "activeUsers": 123,
  "peakDailyUsers": 456
}

headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Bearer {api_key}'
}

response = requests.post(url, headers=headers, data=json.dumps(data))

if response.status_code == 200:
    print("Data sent successfully.")
else:
    print(f"Failed to send data: {response.text}")

3. Handle Responses and Errors

  • Check Responses: Verify the response from the API to ensure data was processed successfully.

  • Error Handling: Implement error handling to manage cases such as invalid data, unauthorized access, or server issues.

4. Testing

  • Sandbox Environment: Test your integration in a sandbox or staging environment before deploying it to production.

  • Verify Data Accuracy: Ensure that data sent to the API matches the actual metrics from your game.

Security Considerations

  • API Key Management: Keep your API key secure and avoid hardcoding it in your application code. Use environment variables or secure storage mechanisms.

  • Data Validation: Validate data before sending it to the API to prevent incorrect or malicious data from being submitted.

Support and Resources

  • API Documentation: Access detailed API documentation and examples on the ApesPlay Developer Portal.

  • Technical Support: Contact the ApesPlay support team for assistance with API integration or troubleshooting issues.

Last updated