If you work mostly from the command line, you can interact with HackMD via hackmd-cli. It's really handy to, for example, create a copy of local files on HackMD.
Access token should be set before using hackmd-cli
. It can be created by landing hackmd.io -> Setting -> API -> Create API token. Copy the token and set it as config variable. For more details, please follow the tutorial: How to issue an API token.
Set the access token by login
command. By doing so, the access token will be saved in ~/.hackmd/config.json
.
Or you don't want to keep the credentials in one file, you can set it through environment variable:
Or you can write the configuration file manually. Edit ~/.hackmd/config.json
with the following content:
hackmd-cli
operates on the official HackMD API endpoint (https://api.hackmd.io/v1
) by default. If you want to use hackmd-cli
with a custom HackMD EE instance, you will need to configure the API endpoint by either environment variable or JSON configuration manually.
Set environment variable in your shell profile:
Or in JSON file (~/.hackmd/config.json
):
All available configurations are listed in the table below.
Config key | Environment Variable | Data Type | Example Value | Description |
---|---|---|---|---|
hackmdAPIEndpointURL |
HMD_API_ENDPOINT_URL |
string |
https://api.hackmd.io/v1 |
HackMD EE API endpoint URL |
accessToken |
HMD_API_ACCESS_TOKEN |
string |
UFHR12H7FSEF3ADFY3N9YNRN2E49VGR212NBF |
Token to access HackMD APIs |
hackmd-cli export
hackmd-cli help [COMMAND]
hackmd-cli history
hackmd-cli login
hackmd-cli logout
hackmd-cli notes
hackmd-cli notes:create
hackmd-cli notes:delete
hackmd-cli notes:update
hackmd-cli team-notes
hackmd-cli team-notes:create
hackmd-cli team-notes:delete
hackmd-cli team-notes:update
hackmd-cli teams
hackmd-cli version
hackmd-cli whoami
hackmd-cli export
Export note content
See code: src/commands/export.ts
hackmd-cli help [COMMAND]
display help for hackmd-cli
See code: @oclif/plugin-help
hackmd-cli history
List user browse history
See code: src/commands/history.ts
hackmd-cli login
Login to HackMD server from CLI
See code: src/commands/login.ts
hackmd-cli logout
Login to HackMD server from CLI
See code: src/commands/logout.ts
hackmd-cli notes
HackMD notes commands
See code: src/commands/notes/index.ts
hackmd-cli notes:create
Create a note
See code: src/commands/notes/create.ts
hackmd-cli notes:delete
Delete a note
See code: src/commands/notes/delete.ts
hackmd-cli notes:update
Update note content
See code: src/commands/notes/update.ts
hackmd-cli team-notes
HackMD team-notes commands
See code: src/commands/team-notes/index.ts
hackmd-cli team-notes:create
Create a team note
See code: src/commands/team-notes/create.ts
hackmd-cli team-notes:delete
Delete a team note
See code: src/commands/team-notes/delete.ts
hackmd-cli team-notes:update
Update team note content
See code: src/commands/team-notes/update.ts
hackmd-cli teams
List teams
See code: src/commands/teams.ts
hackmd-cli version
See code: @oclif/plugin-version
hackmd-cli whoami
Show current user information
See code: src/commands/whoami.ts
MIT