{"library":"meshblu-http","title":"Meshblu HTTP API Client","description":"meshblu-http is a Node.js client library for interacting with the Meshblu HTTP API, primarily associated with the Octoblu IoT platform. It provides a programmatic interface for common operations such as device registration, authentication, sending and receiving messages, and managing subscriptions and webhooks. The library is currently at version 10.2.0, with a history of minor and patch releases addressing features like `bearerToken` support and improved subscription management. While the broader Meshblu ecosystem has evolved significantly since 2017 into a microservices architecture (e.g., `meshblu-core-*` components), this client library largely targets the HTTP API of the original Meshblu 1.0 or compatible services. Its API predominantly uses a callback-based pattern, reflecting its origins as a CoffeeScript-driven project. It serves as a high-level abstraction for interacting with IoT devices and services connected to the Meshblu platform via HTTP.","language":"javascript","status":"maintenance","last_verified":"Thu Apr 23","install":{"commands":["npm install meshblu-http"],"cli":null},"imports":["const MeshbluHttp = require('meshblu-http');","const meshbluHttp = new MeshbluHttp({ uuid: 'your-uuid', token: 'your-token' });"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const MeshbluHttp = require('meshblu-http');\n\n// Configure Meshblu connection details from environment variables for security\n// It's common to have a dedicated Meshblu service running, or use a cloud instance.\nconst MESHBLU_HOSTNAME = process.env.MESHBLU_HOSTNAME ?? 'localhost';\nconst MESHBLU_PORT = parseInt(process.env.MESHBLU_PORT ?? '3000', 10);\nconst MESHBLU_PROTOCOL = process.env.MESHBLU_PROTOCOL ?? 'http';\n\nconst meshbluHttp = new MeshbluHttp({\n  hostname: MESHBLU_HOSTNAME,\n  port: MESHBLU_PORT,\n  protocol: MESHBLU_PROTOCOL\n});\n\n// Register a new device with Meshblu\nconsole.log(`Attempting to register a new device with Meshblu at ${MESHBLU_PROTOCOL}://${MESHBLU_HOSTNAME}:${MESHBLU_PORT}...`);\nmeshbluHttp.register({}, function(error, device) {\n  if (error) {\n    console.error('Failed to register device:', error.message);\n    // Handle specific error codes or retry logic\n    return;\n  }\n  console.log('Device registered successfully!');\n  console.log('UUID:', device.uuid);\n  console.log('Token:', device.token);\n\n  // Example: Authenticate the newly registered device\n  const authenticatedMeshblu = new MeshbluHttp({\n    uuid: device.uuid,\n    token: device.token,\n    hostname: MESHBLU_HOSTNAME,\n    port: MESHBLU_PORT,\n    protocol: MESHBLU_PROTOCOL\n  });\n\n  authenticatedMeshblu.authenticate(function(authError, authResponse) {\n    if (authError) {\n      console.error('Failed to authenticate device:', authError.message);\n      return;\n    }\n    console.log('Device authenticated successfully:', authResponse.online ? 'Online' : 'Offline');\n    // Now you can use authenticatedMeshblu to send messages, create subscriptions, etc.\n  });\n});","lang":"javascript","description":"This quickstart registers a new device with Meshblu and then authenticates using the newly generated credentials. It demonstrates basic client initialization and a common device lifecycle operation, using environment variables for host configuration.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}