• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    JavaScript
  • Created about 10 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A RESTful JSON-speaking API allowing you to write things to NodeBB

Deprecation

As of NodeBB v1.15.0, this plugin is deprecated and has entered maintenance mode. You can of course still use this plugin with versions of v1.15.x and beyond, and I will continue to ensure it is compatible; however new features will not be added.

Please see this blog post for more information

New users are recommended to use the built-in Write API that comes with NodeBB v1.15.0 and up.

Write API

This plugin exposes a write enabled API interface for NodeBB. It is useful if you would like to supplment the built-in read-only API, in order to push items/actions/events to NodeBB.

For example, without this plugin, one can easily retrieve the contents of a post by prefixing api/ to the corresponding route. (e.g. https://community.nodebb.org/api/topic/687/help-translate-nodebb/2).

With this plugin, however, you can create content on NodeBB externally (new topics, new posts, etc), which comes in handy when third-party applications want deeper integration with NodeBB.

Installation

Install this plugin via the plugins page in the ACP.

Alternatively:

$ cd /path/to/nodebb/node_modules
$ git clone [email protected]:NodeBB/nodebb-plugin-write-api.git
$ cd nodebb-plugin-write-api
$ npm i

In both methods, you will need to ./nodebb build before (re-)starting your NodeBB forum.

API Resources

Quick Start

  1. Install and activate the plugin, reload NodeBB
  2. Generate your uid an API token in the ACP page
  3. curl -H "Authorization: Bearer {YOUR_TOKEN}" --data "title={TITLE}&content={CONTENT}&cid={CID}" http://localhost:4567/api/v1/topics

Authentication

Authentication is handled either via HTTP Bearer Token or JSON Web Token, as generated/specified in the Write API.

Bearer Tokens

There are two types of tokens:

  • A user token is associated with a specific uid, and all calls made are made in the name of that user
  • A master token is not associated with any specific uid, though a _uid parameter is required in the request, and then all calls are made in the name of that user. This is the only difference between the two tokens. A master token with _uid set to a non-administrator will not allow you to make administrative calls.

Note: The first token can be generated via the administration page (admin/plugins/write-api), or via the token generation route (POST /api/v1/users/{UID}/tokens) by sending in a password, but additional user tokens can be generated using an existing user/master token.

JSON Web Tokens

JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.

To make requests with a JSON Web Token instead of a user/master token, sign the entire request payload with the same secret as defined in the plugin, and either send it in the POST body, or as a query string parameter. In both cases, the key token is used.

For example,

$ curl http://localhost:4567/api/v1/users/1/tokens?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfdWlkIjoxfQ.pbm5wbAZ4__yFh5y8oeCsJyT0dm8ROcd5SEBr4yGlNw  # secret is 'secret'

Error Handling

When the API encounters an error, it will do it's best to report what went wrong. Errors will follow the format specified in this example:

{
    "code": "not-authorised",
    "message": "You are not authorised to make this call",
    "params": {}
}

Changelog

v5.0

  • Introduced v2 router with breaking changes to some routes (see api/v2 Endpoints for more information)
  • Additional validation for post routes in v2 router only

v4.6

  • Bug fixes
  • Allowing users to generate token via password input (only in token generation route)

v4.5

  • Bug fixes
  • Updated integration with NodeBB so that privileged assets in NodeBB (e.g. /unread) can be retrieved for a user via user/master tokens

v4.2

  • Fix bug with topic deletion
  • Introduced support for category enable/disable, and category purge (deletion)

v4.1

  • Allow addition of tags when creating topics
  • Handling post deletion via API

v3.x to v4.x

  • Made compatible with NodeBB v1.0.0

v3.1

  • Introduced support for JSON Web Tokens

v2.x to v3.x

  • users/ routes now take a uid instead of a userslug. This affects the following routes:
    • PUT /api/v1/users/:userslug -> PUT /api/v1/users/:uid
    • POST /api/v1/users/:userslug/follow -> POST /api/v1/users/:uid/follow
    • DELETE /api/v1/users/:userslug/follow -> DELETE /api/v1/users/:uid/follow

More Repositories

1

NodeBB

Node.js based forum software built for the modern web
JavaScript
14,126
star
2

nodebb-theme-persona

Persona - A modern and responsive NodeBB theme
Smarty
91
star
3

nodebb-plugin-quickstart

A starter kit for quickly creating NodeBB plugins.
JavaScript
59
star
4

nodebb-plugin-poll

Poll plugin for NodeBB.
JavaScript
46
star
5

nodebb-plugin-question-and-answer

Question and Answer Plugin for NodeBB
JavaScript
40
star
6

nodebb-theme-lavender

A simple theme for NodeBB. Check out the theming guide that accompanies this work
Smarty
34
star
7

nodebb-theme-vanilla

Vanilla theme for NodeBB based on Bootstrap. Perfect for starting your own NodeBB themes!
Less
31
star
8

nodebb-plugin-custom-homepage

Allows you to define a custom homepage for NodeBB
JavaScript
28
star
9

nodebb-plugin-markdown

A Markdown parser for NodeBB
JavaScript
27
star
10

nodebb-theme-quickstart

Quickstart Theming Shell
JavaScript
25
star
11

docs

NodeBB Documentation via MkDocs
JavaScript
18
star
12

nodebb-widget-essentials

Several basic widgets bundled together in one package including 'HTML', 'Markdown', 'Recent Replies', 'Active Users', and 'Moderators'
Smarty
17
star
13

nodebb-theme-harmony

Harmony theme for NodeBB v3.0+
Smarty
16
star
14

nodebb-english

English documentation for NodeBB
HTML
15
star
15

nodebb-plugin-composer-quill

WYSIWYG composer for NodeBB based off of Quill (https://quilljs.com/)
JavaScript
15
star
16

nodebb-plugin-featured-threads

Featured Threads & Widget for NodeBB
JavaScript
14
star
17

nodebb-plugin-composer-default

Default Composer for NodeBB
JavaScript
13
star
18

nodebb-plugin-category-sections

This plugin allows you to organize the categories on your homepage into individual sections.
JavaScript
13
star
19

nodebb-rewards-essentials

Essential Rewards Starter Pack for NodeBB
JavaScript
12
star
20

nodebb-chinese-simplified

Simplified Chinese translation of NodeBB documentation
HTML
12
star
21

nodebb-plugin-2factor

Two-Factor Authentication for NodeBB
JavaScript
12
star
22

nodebb-theme-rocket

A theme with a card-based design for NodeBB forums. Mobile enabled.
CSS
11
star
23

nodebb-plugin-emoji

NodeBB Plugin enabling emoji as seen on http://www.emoji-cheat-sheet.com
TypeScript
11
star
24

nodebb.org

The landing page for NodeBB's hosting platform
Vue
9
star
25

nodebb-plugin-category-notifications

JavaScript
8
star
26

nodebb-plugin-leaderboard

Adds a daily/weekly/monthly leaderboard based on reputation
JavaScript
8
star
27

nodebb-plugin-imagemagick

ImageMagick parsing of avatars and other uploaded image assets
JavaScript
8
star
28

nodebb-plugin-sso-oauth2-multiple

NodeBB Plugin for configuring multiple OAuth2 endpoints for login
JavaScript
8
star
29

nodebb-plugin-gdpr

GDPR Compliance Tools and Administrative Overview Pages
JavaScript
7
star
30

nodebb-plugin-friends

Friendship plugin ala facebook
JavaScript
7
star
31

nodebb-plugin-topic-ratings

This plugin allows users to rate topics in your NodeBB forum.
JavaScript
7
star
32

nodebb-plugin-superusers

Allows you to set a certain group to have banning privileges
JavaScript
7
star
33

pulling

Flexible slideout menu for mobile webapps
TypeScript
7
star
34

nodebb-plugin-asset-manager

NodeBB Asset Manager
JavaScript
6
star
35

nodebb-plugin-glossary

A glossary plugin
JavaScript
5
star
36

nodebb-plugin-link-preview

Link Preview (and embedding) plugin for NodeBB
JavaScript
5
star
37

nodebb-french

French translation of NodeBB documentation
Python
4
star
38

nodebb-plugin-global-chat

Global chat room for NodeBB
JavaScript
4
star
39

nodebb-package-manager

Package manager for NodeBB
JavaScript
4
star
40

nodebb-plugin-best-posts

Show bests post of the forum
JavaScript
4
star
41

nodebb-plugin-customize

Customize translations in your forum
TypeScript
4
star
42

nodebb.org-original

The landing page for NodeBB.
HTML
4
star
43

nodebb-plugin-link-mentions

Allows users to post external links using keywords (like mentions/hashtags)
JavaScript
4
star
44

nodebb-plugin-group-gallery

Exposes photo uploading capability for groups, and introduces a custom widget for placement into group pages
JavaScript
3
star
45

nodebb-plugin-category-optin

JavaScript
3
star
46

nodebb-plugin-webhooks

Ping custom endpoints with hook data
JavaScript
3
star
47

nodebb-plugin-ntfy

Push Notifications for NodeBB (via ntfy)
JavaScript
3
star
48

nodebb-plugin-feed

A NodeBB Plugin that creates a social media like feed of topics
JavaScript
3
star
49

nodebb-german

German documentation for NodeBB
Python
3
star
50

nodebb-theme-cerulean

The default NodeBB theme based on the vanilla bootstrap theme
CSS
3
star
51

nodebb-plugin-category-carousel

A carousel to show categories as a widget
JavaScript
3
star
52

nodebb-plugin-latency

JavaScript
3
star
53

nodebb-plugin-openai

NodeBB OpenAI plugin
JavaScript
2
star
54

nodebb-plugin-cdn

JavaScript
2
star
55

nodebb-plugin-squash

Mark users as trolls to squash their posts
JavaScript
2
star
56

nodebb-plugin-import-network54

Custom importer built for Network54 Forums
JavaScript
2
star
57

nodebb-plugin-dev-tracker

Dev tracker plugin to show posts & topics from specific groups
JavaScript
2
star
58

nodebb-russian

Russian documentation for NodeBB
HTML
2
star
59

nodebb-plugin-kitchen-sink

This repo will serve as a sample for all action/filter hooks available in NodeBB.
JavaScript
2
star
60

nodebb-theme-palette

Palette Theme for NodeBB
Smarty
2
star
61

nodebb-plugin-openapi-spec

openapi spec generator
JavaScript
1
star
62

nodebb-plugin-debug-hook

A plugin to see parameters passed to hooks in real time
JavaScript
1
star
63

nodebb-plugin-hashtags

Enable hashtags in topics and posts
JavaScript
1
star
64

docgen

Hooks documentation generator for NodeBB
JavaScript
1
star
65

nodebb-plugin-topic-redirect

Topic Redirect plugin for NodeBB
Smarty
1
star
66

nodebb-vietnamese

Vietnamese documentation for NodeBB
Python
1
star
67

nodebb-plugin-topic-move-notification

Sends a notification to a users followers when they move a topic from a hidden category to a visible category.
JavaScript
1
star
68

assets

NodeBB Logos
1
star
69

nodebb-theme-community

The Persona-variant theme for the forum at https://community.nodebb.org
JavaScript
1
star
70

nodebb-plugin-image-mentions

JavaScript
1
star
71

nodebb-plugin-undelete-users

A NodeBB plugin to re-associate deleted users with their content that are not removed.
JavaScript
1
star
72

nodebb-plugin-featured-categories

Add featured category cards to Persona's category homepage
JavaScript
1
star