LogoNightPixel

Server API

Developer guide for using NightPixel's backend functions - get-user

Overview

NightPixel provides essential backend functions for game integration:

  • get-user: Retrieve authenticated user information

All functions require a valid game auth key, which is stored in the np_game_auth_token query parameter

Authentication Flow

1. Get User Information

Retrieve details about the authenticated user using their game session key.

Endpoint

GET /functions/v1/get-user

Authentication

Uses the NP-API-KEY header with the game session key.

Request Example

curl -i --location --request GET 'https://api.nightpixel.com/functions/v1/get-user' \
  --header 'NP-API-KEY: your-session-key'

Response

{
  "data": {
    "username": "player123",
    "id": "user-unique-id",
    "is_guest": false
  }
}

Response Fields

  • username: The user's display name
  • id: Unique user identifier
  • is_guest: Boolean indicating if user is playing as guest

Complete Workflow Example

Here's a typical workflow for getting user information:

Step-by-Step Implementation

# 1. Get user information
curl -X GET 'https://api.nightpixel.com/functions/v1/get-user' \
  --header 'NP-API-KEY: session-key-123'

Error Handling

All functions return appropriate HTTP status codes:

  • 200: Success
  • 400: Bad request (missing or invalid parameters)
  • 401: Unauthorized (invalid session key)
  • 500: Server error

Common Error Scenarios

  1. Invalid Session Key: Ensure the session key is valid and not expired
  2. Missing Required Fields: Check that all required parameters are included
  3. Database Errors: Check server logs for database connection issues

Testing Tips

  1. Start Simple: Test get-user first to verify your session key works
  2. Error Scenarios: Test with invalid session keys and malformed requests

For more detailed integration information, see the Platform Integration Guide or Client API Reference.