{"_id":"@adenion/blog2social-api-node-js-sdk","_rev":"2-c9f1362adaeae7dd427832f1be7b6186","name":"@adenion/blog2social-api-node-js-sdk","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@adenion/blog2social-api-node-js-sdk","version":"1.0.0","keywords":["adenion","blog2social","api","sdk","social-media","node"],"license":"MIT","_id":"@adenion/blog2social-api-node-js-sdk@1.0.0","maintainers":[{"name":"adedev","email":"developer@adenion.de"}],"homepage":"https://www.blog2social.com/","bugs":{"url":"https://github.com/Adenion/blog2social-api-node-js-sdk/issues"},"dist":{"shasum":"baaa9540fc1e6b6c96f39a31019cf7caaa94e7d5","tarball":"https://registry.npmjs.org/@adenion/blog2social-api-node-js-sdk/-/blog2social-api-node-js-sdk-1.0.0.tgz","fileCount":77,"integrity":"sha512-qa8cRstEU7hDnKtQJMQGrIgWJNvE8d5zbncNvU+X8Qt+r1dLpr0U4FWgXTFYnNL+xNcUPdMPEJ1+VfoA8nG9ZA==","signatures":[{"sig":"MEQCIByPkxIYo6QN4tKBNzU7UdVY8jEiNx+apyZW/JhiFVGIAiAy/o3546WdgnW1KnqAEIKfVD7KAEkTWWgBqeGjty/eFg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":60415},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"649eeab652ad9cbcb829198053e965690af92936","scripts":{"test":"node --test","build":"tsc -p tsconfig.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"adedev","email":"developer@adenion.de"},"repository":{"url":"git+https://github.com/Adenion/blog2social-api-node-js-sdk.git","type":"git"},"_npmVersion":"10.9.2","description":"Official Node.js SDK for the Blog2Social API.","directories":{},"_nodeVersion":"23.11.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/blog2social-api-node-js-sdk_1.0.0_1784041747260_0.4865133481681787","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@adenion/blog2social-api-node-js-sdk","version":"1.0.1","description":"Official Node.js SDK for the Blog2Social API.","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"engines":{"node":">=18"},"scripts":{"build":"tsc -p tsconfig.json","test":"node --test","prepublishOnly":"npm run build"},"keywords":["adenion","blog2social","api","sdk","social-media","node"],"homepage":"https://www.blog2social.com/","repository":{"type":"git","url":"git+https://github.com/Adenion/blog2social-api-node-js-sdk.git"},"license":"MIT","devDependencies":{"@types/node":"^22.20.1","typescript":"^5.7.0"},"_id":"@adenion/blog2social-api-node-js-sdk@1.0.1","gitHead":"8fd9ab86254bac8f87ef78991538ef4a1589d19c","bugs":{"url":"https://github.com/Adenion/blog2social-api-node-js-sdk/issues"},"_nodeVersion":"23.11.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-BWs4NH7LxHCBCjXd0pY9IbWXmu7OD9YImnlORAiOnMQh26jrjSzES6EhdNsRTgOHoEHXW9Y4bm2MVNdZVBy5eQ==","shasum":"61f7fc954907b69e638a074ea5c63858450aa2b1","tarball":"https://registry.npmjs.org/@adenion/blog2social-api-node-js-sdk/-/blog2social-api-node-js-sdk-1.0.1.tgz","fileCount":77,"unpackedSize":61348,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCBWewEeMnl/hBWYK+umxS7Jf6889yjF843Ow84fIYyxAIhAIv9ET/+hxHkeS67O9UlBxNtzmDCHRhhi+uT0NwPFh9a"}]},"_npmUser":{"name":"adedev","email":"developer@adenion.de"},"directories":{},"maintainers":[{"name":"adedev","email":"developer@adenion.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/blog2social-api-node-js-sdk_1.0.1_1787214677995_0.03420788302905797"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-14T15:09:07.075Z","modified":"2026-08-20T08:31:18.407Z","1.0.0":"2026-07-14T15:09:07.499Z","1.0.1":"2026-08-20T08:31:18.158Z"},"bugs":{"url":"https://github.com/Adenion/blog2social-api-node-js-sdk/issues"},"license":"MIT","homepage":"https://www.blog2social.com/","keywords":["adenion","blog2social","api","sdk","social-media","node"],"repository":{"type":"git","url":"git+https://github.com/Adenion/blog2social-api-node-js-sdk.git"},"description":"Official Node.js SDK for the Blog2Social API.","maintainers":[{"name":"adedev","email":"developer@adenion.de"}],"readme":"# Blog2Social API Node.js SDK\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)\n[![Node.js](https://img.shields.io/badge/Node.js-18%2B-green.svg)](https://nodejs.org/)\n[![npm](https://img.shields.io/badge/npm-ready-red.svg)](https://www.npmjs.com/)\n\nOfficial Node.js SDK for the Blog2Social API v1.0.\n\nThe SDK provides a typed, Promise-based interface for authentication, network connections, publishing, user apps, network properties, and video uploads.\n\n## Installation\n\n```bash\nnpm install @adenion/blog2social-api-node-js-sdk\n```\n\n## Requirements\n\n- Node.js 18 or higher\n- npm\n- A Blog2Social `service_token`\n- An `access_token` for user-specific endpoints\n\n## Architecture\n\n```text\n┌──────────────────────────────┐\n│    Your Node.js Application  │\n└──────────────┬───────────────┘\n               │\n               ▼\n┌──────────────────────────────┐\n│    Blog2Social Node.js SDK   │\n└──────────────┬───────────────┘\n               │\n               ▼\n┌──────────────────────────────┐\n│       Blog2Social API        │\n└──────────────┬───────────────┘\n               │\n   ┌───────────┼───────────┐\n   ▼           ▼           ▼\nFacebook   LinkedIn   Instagram\n     ▼           ▼           ▼\n  Threads   Pinterest   TikTok\n\n... additional supported networks ...\n```\n\n## Initialization\n\n```js\nimport { Blog2SocialClient } from '@adenion/blog2social-api-node-js-sdk';\n\nconst client = new Blog2SocialClient({\n  serviceToken: process.env.BLOG2SOCIAL_SERVICE_TOKEN,\n  accessToken: process.env.BLOG2SOCIAL_ACCESS_TOKEN,\n});\n```\n\nDo not commit API tokens. Use environment variables or a secrets manager in production.\n\n## Authenticate a User\n\n```js\nconst response = await client.authentication.authenticateUser();\n\nconsole.log(response.access_token);\n```\n\n`authenticateUser()` automatically stores the returned access token on the client instance.\n\n## List Users\n\nThis service-level endpoint requires only the `service_token`.\n\n```js\nconst users = await client.user.listUsers();\n\nconsole.log(users);\n```\n\n## List Available Networks\n\n```js\nconst networks = await client.network.listNetwork();\n\nconsole.log(networks);\n```\n\n## List Network Properties\n\nNetwork properties describe supported content, limits, media formats, instant sharing, and video requirements.\n\n```js\nconst properties = await client.network.listProperties();\n\nconsole.log(properties);\n```\n\nFor video publishing, inspect `video_support` and `video_upload_type` for the matching `network_id` and `network_type`.\n\nA video token is generated only when `video_upload_type` is `1`:\n\n- `0`: publish with a public video URL\n- `1`: request a video token and upload the local file in chunks\n- `2`: publish with a public video URL; no video token is generated\n\n## Connect a Social Media Account\n\n```js\nconst response = await client.connection.addNetwork(\n  1,\n  1,\n  'en',\n);\n\nconsole.log(decodeURIComponent(response.auth_link));\n```\n\nNetwork type values:\n\n```text\n0 = Profile\n1 = Page\n2 = Group\n```\n\nSome networks may require a user app. Register the app credentials first with `client.userApps.add()` and follow the API documentation for the selected network.\n\n## List Connected Accounts\n\n```js\nconst connections = await client.user.listUserAuthentications();\n\nconsole.log(connections);\n```\n\nThe returned `client_user_network_id` identifies the connected destination used for publishing.\n\n## Publish a Link Post\n\n```js\nconst clientUserNetworkId = 123456;\n\nconst response = await client.share.createPost(clientUserNetworkId, [\n  {\n    client_user_network_id: clientUserNetworkId,\n    title: 'My first API post',\n    message: 'Hello from the Blog2Social Node.js SDK.',\n    postFormat: 0,\n    customUrl: 'https://example.com',\n  },\n]);\n\nconsole.log(response);\n```\n\nPost formats:\n\n```text\n0 = Link\n1 = Image\n2 = Video\n```\n\n## Publish an Image Post\n\n```js\nconst response = await client.share.createPost(clientUserNetworkId, [\n  {\n    client_user_network_id: clientUserNetworkId,\n    title: 'Image Post',\n    message: 'This is an image post.',\n    postFormat: 1,\n    mediaObjects: [\n      {\n        type: 'IMAGE',\n        url: 'https://example.com/image.jpg',\n      },\n    ],\n  },\n]);\n```\n\n## Publish a Video by URL\n\nUse this workflow when the matching network property has `video_upload_type` equal to `0` or `2`.\n\n```js\nconst response = await client.share.createPost(clientUserNetworkId, [\n  {\n    client_user_network_id: clientUserNetworkId,\n    title: 'Video Post',\n    message: 'This is a video post.',\n    postFormat: 2,\n    mediaObjects: [\n      {\n        type: 'VIDEO',\n        url: 'https://example.com/video.mp4',\n      },\n    ],\n  },\n]);\n```\n\n## Upload a Local Video\n\nUse this workflow only when the matching network property has `video_upload_type = 1`.\n\n1. Request a video token with `client.video.createVideoPost()`.\n2. Upload the file in chunks with `client.videoUpload.uploadChunk()`.\n3. Check the result with `client.videoStatus.check()`.\n\nA complete implementation is available in `examples/uploadVideoAndPost.mjs`.\n\n## User Apps\n\n```js\nconst userApp = await client.userApps.add(\n  6,\n  'YOUR_APP_KEY',\n  'YOUR_APP_SECRET',\n  'My Pinterest App',\n);\n\nconsole.log(userApp);\n```\n\nAvailable methods:\n\n```js\nclient.userApps.add();\nclient.userApps.list();\nclient.userApps.modify();\nclient.userApps.delete();\n```\n\n## Available Services\n\n```js\nclient.authentication;\nclient.network;\nclient.connection;\nclient.categories;\nclient.user;\nclient.share;\nclient.video;\nclient.videoUpload;\nclient.videoStatus;\nclient.app;\nclient.userApps;\n```\n\n## Error Handling\n\nAPI errors are thrown as `Blog2SocialApiError` and include the HTTP status and parsed response body.\n\n```js\nimport {\n  Blog2SocialApiError,\n} from '@adenion/blog2social-api-node-js-sdk';\n\ntry {\n  await client.network.listNetwork();\n} catch (error) {\n  if (error instanceof Blog2SocialApiError) {\n    console.error(error.status);\n    console.error(error.responseBody);\n  }\n\n  throw error;\n}\n```\n\n## Examples\n\nReady-to-use examples are available in the `examples/` directory.\n\nCopy the example configuration before running them:\n\n```bash\ncp examples/config.example.mjs examples/config.mjs\n```\n\nThen add your test tokens and IDs to `examples/config.mjs`.\n\nRun an example:\n\n```bash\nnode examples/listNetwork.mjs\n```\n\n## Development\n\nInstall dependencies:\n\n```bash\nnpm install\n```\n\nBuild the SDK:\n\n```bash\nnpm run build\n```\n\nInspect the npm package contents:\n\n```bash\nnpm pack --dry-run\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}