Please be aware, that the code examples below are very condensed and intentionally omit the recommended try..catch construct as well as the async framing.
Param | Type | Text |
---|---|---|
alias | string | a blog's alias |
- requires: successful login
- returns: tStoryList object
tStoryList Property | Type | Text |
---|---|---|
fromPage | number | beginning page (starts with 0) |
toPage | number | ending page |
maxPage | number | number of available pages (each page holds up to 20 stories) |
stories | tStoryListItem[] | array of tStoryListItem |
total | number | number of total available stories for this alias |
tStoryListItem Property | Type | Text |
---|---|---|
id | string | the story's id |
createDate | string | date of creation as 'tt.mm.yyyy mm:dd' |
title | string | the story's title |
fromPage defaults to 0 (most recent page = most recent 20 stories)
toPage defaults to maxPage (if omitted, all stories of the blog will be returned)
toPage must be greater or equal to fromPage
const td = new Twoday.Twoday('prod', { delay: 100 });
await td.login();
const alias = 'neonwilderness';
const storyInfos = await td.listStories(alias, 0, 1);
console.log(storyInfos);
Param | Type | Text |
---|---|---|
alias | string | the blog's alias |
id | string | the story's id |
- requires: successful login
- returns: res or null
const td = new Twoday.Twoday('prod');
await td.login();
const res = await td.getStory('foundation', '1022380953');
if (res) console.log(`The story text is: ${res.body}`);
Param | Type | Text |
---|---|---|
alias | string | the blog's alias |
id | string | the story's id |
- requires: successful login
- returns: boolean
const td = new Twoday.Twoday('prod');
await td.login();
const exists = await td.hasStory('foundation', '1022380953');
console.log(`The story does ${exists ? '' : 'not '}exist.`)
Param | Type | Text |
---|---|---|
alias | string | the blog's alias |
story | tStoryInfo | object |
tStoryInfo Property | Type | Text |
---|---|---|
title | string | the story's title |
body | string | the story's content |
niceurl? | string | a nice url string |
topic? | string | a topic string |
publish? | string | datetimestamp as publish date of the story |
action? | string | 'save' or 'publish' |
- requires: successful login
- returns: tStoryKeys object
tStoryKeys Property | Type | Text |
---|---|---|
id | string | the new story id |
niceurl | string | the nice url string |
title and body are required parameters.
If niceurl is null or undefined, the title will be converted to a nice url string.
If the publish datetimestamp is a future date, the story will be publicly viewable from that date on. If publish is omitted, it will be replaced with the actual creation date.
If action is null or undefined, action 'save' is assumed (story will be saved only but not published)
const td = new Twoday.Twoday('prod', { delay: 300 });
await td.login();
const story = {
title: 'The Falling Man',
body: '<p>Lorem ipsum dolor sit amet, consetetur...</p><p>At vero eos et accusam et...</p>',
topic: 'New York',
action: 'publish'
};
const res = await td.createStory('neonwilderness', story);
console.log(`Story "${story.niceurl}" successfully created (code=${res.statusCode}).`);
Param | Type | Text |
---|---|---|
alias | string | the blog's alias |
story | tStoryInfo | object |
tStoryInfo Property | Type | Text |
---|---|---|
title | string | the story's title |
body | string | the story's content |
id | string | the story's id |
niceurl? | string | a nice url string |
topic? | string | a topic string |
publish? | string | datetimestamp as publish date of the story |
action? | string | 'save' or 'publish' |
- requires: successful login
- returns: Response
title and body are required parameters.
If niceurl is null or undefined, the title will be converted to a nice url string.
If the publish datetimestamp is a future date, the story will be publicly viewable from that date on. If publish is omitted, it will be replaced with the actual creation date.
If action is null or undefined, action 'save' is assumed (story will be saved only but not published)
const td = new Twoday.Twoday('prod', { delay: 300 });
await td.login();
const story = {
title: 'The 9/11 Jumpers',
body: '<p>Lorem ipsum dolor sit amet, consetetur...</p><p>At vero eos et accusam et...</p>',
id: '5185134',
topic: 'New York'
};
const res = await td.updateStory('neonwilderness', story);
console.log(`Story "${story.id}" successfully updated (code=${res.statusCode}).`);
Param | Type | Text |
---|---|---|
alias | string | the blog's alias |
- returns: Array of tNameUrl
tNameUrl Property | Type | Text |
---|---|---|
name | string | topic text |
url | string | url of the topic |
const td = new Twoday.Twoday('prod', { delay: 300 });
const data = await td.getStoryTopics('neonwilderness');
console.table(data); // lists: index, name, url