🔑

1. Generate API Key

Example Flow

  1. 1
    Visit https://ostapi.onwords.in and click on "Get API Key" from the menu.
  2. 2
    You'll be redirected to the login page. Enter your email and password, then click Submit.
  3. 3
    After logging in, you'll see a list of your devices. Select the devices you want to generate the API key for.
  4. 4
    Click the "Generate API Key" button. Your new API key will be displayed. Copy and save it securely.

API Key Generated

Secure key ready for API calls

Description

This endpoint is used to generate a secure API Key via the Onwords Smart Things app. Upon key generation, the API securely stores and associates the API key with the selected product(s), enabling authorized access for future device control operations.

⚠️ Security Note
Ensure to store the API key securely, as it is required for all future authenticated device control actions. Never expose your API key in client-side code or public repositories.
📱

2. Get Device List

Before controlling any devices, you need to retrieve the list of devices associated with your API key. This endpoint returns all devices you have access to, along with their unique identifiers and types.

Endpoint:

GET https://ostapi.onwords.in/get_device_list

Description:

This endpoint authenticates your API key and returns a list of all devices you have permission to control. Each device includes essential information such as the product ID, device name, gate type, and current status.

📋 Request Headers

Name Description
Authorization *
string
(header)
Bearer token containing your API key. Format: Bearer your-api-key

📊 Response Format

200 Success Response
Response Body
{
  "product_ids": ["device_001"],
  "status": "success",
  "api-key": "abcd123"
}

Error Responses:

401 Unauthorized: Invalid or missing Bearer token

403 Forbidden: API key doesn't have permission to list devices

500 Internal Server Error: Server error occurred

💻 Example Implementation

Python Example
import requests

# Your API configuration
API_KEY = "your_api_key_here"
BASE_URL = "https://ostapi.onwords.in/"

def get_device_list():
    headers = {
        "Authorization": f"Bearer {API_KEY}"
    }
    
    response = requests.post(
        f"{BASE_URL}get_device_list",
        headers=headers
    )
    
    return response.json()

# Get device list
devices = get_device_list()
print(devices)
JavaScript Example
const API_KEY = "your_api_key_here";
const BASE_URL = "https://ostapi.onwords.in/";

async function getDeviceList() {
    const response = await fetch(`${BASE_URL}get_device_list`, {
        method: 'POST',
        headers: {
            'Authorization': `Bearer ${API_KEY}`
        }
    });
    
    return await response.json();
}

// Get device list
getDeviceList()
    .then(result => console.log(result))
    .catch(error => console.error('Error:', error));
🎮

3. Control Device

Endpoint:

POST https://ostapi.onwords.in/control-device/

Description:

Authenticates the user, validates the API key and product access, and sends control commands to the selected device. This endpoint supports various gate types and provides real-time device control capabilities.

📋 Request Headers

Name Description
Authorization *
string
(header)
Bearer token containing your API key. Format: Bearer your-api-key
Content-Type
string
(header)
Should be set to application/json

🎯 Supported Device Types & Actions

Device Type Allowed Actions
Sliding Gate open, close, pause, partial_open
Arm Gate open_single_gate, close_single_gate, pause_single_gate
open_double_gate, close_double_gate, pause_double_gate

📝 Request Body Format

JSON Request Format
{
  "product_id": "your-product-id",
  "action": "open"
}

Request Parameters:

  • product_id (string, required): The unique identifier of the device you want to control (obtained from Get Device List)
  • action (string, required): The command to execute (see supported actions above)

📊 Response Format

200 Success Response
Response Body
{
  "status": "success",
  "product_id": "your-product-id",
  "gate_type": "your-gate-type"
}

Error Responses:

401 Unauthorized: Invalid or missing Bearer token

403 Forbidden: API key doesn't have access to this product

400 Bad Request: Invalid action or missing parameters

404 Not Found: Product ID not found

💻 Example Implementation

Python Example
import requests

# Your API configuration
API_KEY = "your_api_key_here"
BASE_URL = "https://ostapi.onwords.in/"

def device_action(product_id, action):
    headers = {
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json"
    }
    
    data = {
        "product_id": product_id,
        "action": action
    }
    
    response = requests.post(
        f"{BASE_URL}control-device/",
        json=data,
        headers=headers
    )
    
    return response.json()

# Control device
status = device_action("device_123", "open")
print(status)
JavaScript Example
const API_KEY = "your_api_key_here";
const BASE_URL = "https://ostapi.onwords.in/";

async function deviceAction(productId, action) {
    const response = await fetch(`${BASE_URL}control-device/`, {
        method: 'POST',
        headers: {
            'Authorization': `Bearer ${API_KEY}`,
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            product_id: productId,
            action: action
        })
    });
    
    return await response.json();
}

// Control device
deviceAction("device_123", "open")
    .then(result => console.log(result))
    .catch(error => console.error('Error:', error));
cURL Example
# Get Device List
curl -X POST https://ostapi.onwords.in/get_device_list \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json"

# Control Device
curl -X POST https://ostapi.onwords.in/control-device/ \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": "device_123",
    "action": "open"
  }'

Support & Integration Assistance

For any queries, support, or integration assistance, feel free to reach out to our technical team. We're here to help you integrate seamlessly with the Onwords Gate Control API.

📧 [email protected]
Where Luxury Meets Innovation