Skip to main content

Introduction

The GenLayer Points API is a Django REST Framework (DRF) based API that provides comprehensive access to the GenLayer Testnet Program’s contribution tracking system. The API allows you to manage users, contributions, leaderboards, and more.

Base URLs

http://localhost:8000/api/v1/

API Versioning

The API is versioned through the URL path. The current version is v1. All endpoints are prefixed with /api/v1/ except authentication endpoints which use /api/auth/.

Response Format

All API responses are returned in JSON format with consistent structure:

Success Response

{
  "id": 1,
  "name": "Example User",
  "address": "0x1234567890abcdef",
  "created_at": "2024-01-15T10:30:00Z"
}

List Response (Paginated)

{
  "count": 150,
  "next": "http://localhost:8000/api/v1/users/?page=2",
  "previous": null,
  "results": [
    {
      "id": 1,
      "name": "User 1"
    },
    {
      "id": 2,
      "name": "User 2"
    }
  ]
}

Error Response

{
  "error": "Invalid signature: address mismatch"
}
or for validation errors:
{
  "points": [
    "Points must be between 10 and 100 for Node Running."
  ],
  "contribution_type": [
    "This field is required."
  ]
}

Status Codes

The API uses standard HTTP status codes:
CodeMeaning
200OK - Request succeeded
201Created - Resource created successfully
400Bad Request - Invalid request data
401Unauthorized - Authentication required
403Forbidden - Insufficient permissions
404Not Found - Resource not found
500Internal Server Error - Server error

Pagination

List endpoints support pagination with the following query parameters:
page
integer
default:"1"
Page number to retrieve
page_size
integer
default:"10"
Number of items per page (max 100)
limit
integer
Alternative to page_size for limiting results

Filtering and Ordering

Many endpoints support filtering and ordering:

Filtering

GET /api/v1/contributions/?user=5&contribution_type=3

Ordering

GET /api/v1/contributions/?ordering=-created_at
Use - prefix for descending order.

Searching

GET /api/v1/users/?search=alice

Rate Limiting

Currently, there are no strict rate limits, but excessive requests may be throttled. Best practices:
  • Cache responses when appropriate
  • Use pagination for large datasets
  • Batch requests when possible

CORS

The API supports CORS for browser-based applications. The following headers are included in responses:
  • Access-Control-Allow-Origin
  • Access-Control-Allow-Credentials
  • Access-Control-Allow-Methods
  • Access-Control-Allow-Headers

Development vs Production

Development:
  • Debug mode enabled
  • Detailed error messages
  • CORS allows localhost origins
  • Test reCAPTCHA keys accepted
Production:
  • Debug mode disabled
  • Generic error messages
  • CORS restricted to specific origins
  • Real reCAPTCHA validation required

Next Steps

Authentication

Learn about SIWE authentication flow

Users API

Manage user accounts and profiles

Contributions API

Track and submit contributions

Leaderboard API

Access rankings and statistics

Build docs developers (and LLMs) love