NYYU Logo
APIPresale

Get Presales by Status

Filter and retrieve presale rounds based on their current status

ADMIN ONLY

Get Presales by Status

Filter presale rounds by status to focus on pending, active, or completed token sales.

Admin Access Required

This query is only accessible to users with ADMIN privileges. Standard users cannot view presale round details.

Overview

The getPreSaleByStatus query enables administrators to retrieve presale rounds filtered by their current status, making it easier to manage and monitor specific stages of the presale lifecycle.


GraphQL Schema

query {
  getPreSaleByStatus(
    status: Int!
  ): [PreSale]
}

Parameters

status

Required

Int

The status of the presale rounds to retrieve. Valid values:

1Pending (Not yet started)
2Started (Currently active)
3Ended (Completed)

Return Value

Success Response

Returns an array of [PreSale] objects matching the specified status, each containing:

idUnique identifier for the presale round
startedAtStart time in UNIX timestamp format
endedAtEnd time in UNIX timestamp format
tokenAmountTotal tokens available in the presale
tokenPricePrice per token during the presale
conditionsArray of custom conditions with name/value pairs

Example Usage

Request - Get Active Presales

query GetActivePresales {
  getPreSaleByStatus(status: 2) {
    id
    startedAt
    endedAt
    tokenAmount
    tokenPrice
    conditions {
      name
      value
    }
  }
}

Response

{
  "data": {
    "getPreSaleByStatus": [
      {
        "id": 12,
        "startedAt": 1704067200.0,
        "endedAt": 1706745600.0,
        "tokenAmount": 1000000.0,
        "tokenPrice": 0.5,
        "conditions": [
          {
            "name": "Minimum Purchase",
            "value": "100 tokens"
          },
          {
            "name": "Maximum Purchase",
            "value": "10000 tokens"
          },
          {
            "name": "KYC",
            "value": "Level 2 verification required"
          }
        ]
      }
    ]
  }
}

Active Presales Retrieved

The query successfully returned all currently active presale rounds (status: 2) with their complete details.


Status-Specific Examples

Pending Presales (Status: 1)

Query upcoming presale rounds that haven't started yet:

getPreSaleByStatus(status: 1)

🟢 Active Presales (Status: 2)

Query presale rounds that are currently accepting orders:

getPreSaleByStatus(status: 2)

🔴 Completed Presales (Status: 3)

Query presale rounds that have ended:

getPreSaleByStatus(status: 3)

Use Cases

🎯

Active Sales Monitoring

Focus on currently active presales to monitor real-time sales, token allocation, and participant activity.

📅

Upcoming Events

View pending presales to prepare marketing materials, whitelist management, and launch communications.

📊

Historical Analysis

Review completed presales to analyze performance, token distribution, and participant demographics.

🔔

Status Notifications

Build automated alerts for status changes, such as when presales start or are about to end.


Best Practices

🎯 Targeted Queries

Use status filtering to reduce payload size and improve performance compared to querying all presales.

⚡ Real-Time Updates

Poll active presales (status: 2) more frequently than pending or completed ones for real-time monitoring.

📈 Performance Optimization

Implement separate caching strategies for each status level based on update frequency requirements.

🔍 Status Transitions

Monitor presales near their start/end times to detect status transitions and trigger appropriate actions.


Status Workflow

🔄 Presale Status Lifecycle

Pending
Status: 1

🟢

Started
Status: 2

🔴

Ended
Status: 3