Praya Labs Logo

API Documentation

Welcome to the comprehensive guide for the Praya Labs All-in-One API Platform. Follow these clean steps to integrate your hardware, web apps, or backend services.

1 Authentication

Every project you create generates a unique, secure API_KEY. You must authenticate every request to your endpoint using this key.

Authentication can be done securely via:

  • Query Parameter: Append ?api_key=YOUR_API_KEY to your URL.
  • HTTP Header: Send an Authorization: YOUR_API_KEY header.

2 Reading Data (GET)

To retrieve the current state of all the fields configured in your project, perform a standard GET request.

This is highly useful for checking feature flags, reading saved configurations, or fetching the latest IoT sensor states.

GET /api/generate.php?api_key=YOUR_API_KEY

Response Example:

{
  "temperature": 24.5,
  "system_active": true,
  "device_name": "Sensor Alpha"
}

3 Writing Data (POST JSON)

You can update your field values by passing their names as keys in a JSON request payload. Ensure you set the Content-Type: application/json header.

POST /api/generate.php?api_key=YOUR_API_KEY
Content-Type: application/json

{
    "temperature": 26.1,
    "system_active": false
}

4 Writing Data (GET Query)

For low-power microcontrollers (like ESP8266 or Arduino) that struggle with JSON parsing, you can simply update values by appending them as GET parameters.

GET /api/generate.php?api_key=YOUR_API_KEY&temperature=26.1&system_active=false

5 Data Types & Validation

The backend automatically validates and casts your data based on how you configured the fields in your dashboard. For example, if you send "true" (string) to a Boolean field, the API will smartly convert it to a boolean true. Unsupported fields sent in requests will be safely ignored.