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 nameid
: Unique user identifieris_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
- Invalid Session Key: Ensure the session key is valid and not expired
- Missing Required Fields: Check that all required parameters are included
- Database Errors: Check server logs for database connection issues
Testing Tips
- Start Simple: Test
get-user
first to verify your session key works - Error Scenarios: Test with invalid session keys and malformed requests
For more detailed integration information, see the Platform Integration Guide or Client API Reference.