A simple Javascript client for Dreamwidth's XML-RPC API.
- Uses native Promises (transpiled for ES5)
- Additional helper functions to be added
Install on npm:
npm install dreamwidth-api-js
Include the module:
var Dreamwidth = require('dreamwidth-api-js');
Login to your Dreamwidth account (note: you are required to login to access the API)
var myDreamwidth = Dreamwidth.login('username', 'password');
Use the general .method(value, options)
function to access API methods. See wiki documentation for a list of available methods and their options, in conjunction with the original Livejournal docs (note that both are a bit outdated)
Example: use 'getevents' method to get the latest posts from your journal.
// Set relevant options for the method
var options = {
selecttype: 'lastn',
howmany: 10
}
myDreamwidth.method('getevents', options)
.then( function(data) {
// ... Do the things
}).catch( function(data) {
// ... Handle errors
});
Response:
{ events:
[ { eventtime: '2017-02-13 16:53:00',
event: 'The post body content',
anum: 456,
itemid: 1,
logtime: '2017-03-13 05:53:13',
props: [Object],
subject: 'The post subject',
url: 'https://your_name.dreamwidth.org/123.html' },
// More entries...
]
}
Helper functions for common methods, documentation.