See README
$ npm -i @hackmd/api
- Copy following into
index.js
const { default: API } = require('@hackmd/api')
const api = new API()
api.login('your account', 'your password').then(() => {
api.newNote(`# Untitle Add By API`)
})
- execute it by
node index.js
const { default: API, ExportType } = require('@hackmd/api')
const api = new API()
api.login('your account', 'your password').then(() => {
api.exportString('your note id', ExportType.MD).then((res) => {
api.newNote(res)
})
})
notice: There are not all the functions. I just write the functions which I am interested in
constructor(config?: APIOptions)
- config: optional, APIOptions
login(email: string, password: string): Promise<void>
- method to login- email: string
- password: string
logout(): Promise<void>
- method to logoutnewNote(body: string, options?: NewNoteOption): Promise<void>
- method to add a new note- body: string - the content you want to add in the new note, for example:
# api test
- options: optional, NewNoteOption
- body: string - the content you want to add in the new note, for example:
exportString(noteId: string, type: ExportType): Promise<string>
- method to export a note- noteId: string - the id in the url. If your url of the example note is
https://hackmd.io/XXXOOO
, your noteId isXXXOOO
- type: ExportType
- noteId: string - the id in the url. If your url of the example note is
- serverUrl: string - optional, the url of the server, for example:
https://hackmd.io
- cookiePath: string - optional, the path where the cookies save in
- enterprise: boolean - optional, I don't know what it is
- team: string - optional, the team id in the url
- PDF: 0 - export to pdf
- SLIDE: 1 - I don't know what it is
- MD: 2 - export to markdown
- HTML: 3 - export to html
MIT