An API built using json-server based on the template json-server-heroku that allows you to look up Chinese and Han Viet cognates based on the data from chinese-hanviet-cognates.
I created it for personal usage in my Anki deck, where I can display the list of Hanviet words for every Chinese character that I learn.
- https://chinese-hanviet-api.herokuapp.com/words?word_like=可
- https://chinese-hanviet-api.herokuapp.com/words?hanviet=trạng%20thái
1 . Install dependencies
yarn install
2 . Sync the data from the source
yarn run sync
This script will download a tsv file from the source repo, and convert it to JSON format and write into db.json
. If there is no change in the source file, you won't see any change in db.json
. But if you intend to deploy this API to Heroku, make sure to commit any changes to db.json
to git.
3 . Run the API
yarn start
This will start the API locally on port 3000.
4 . Access the API
You can query the API in many ways, for example:
For more flexible ways to query, refer to the complete documentation of json-server.
Heroku is a free hosting service for hosting small projects. Easy setup and deploy from the command line via git.
1 . Create an account on
https://heroku.com
2 . Install the Heroku CLI on your computer:
https://devcenter.heroku.com/articles/heroku-cli
3 . Connect the Heroku CLI to your account by writing the following command in your terminal and follow the instructions on the command line:
heroku login
4 . Then create a remote heroku project, kinda like creating a git repository on GitHub. This will create a project on Heroku with a random name. If you want to name your app you have to supply your own name like heroku create project-name
:
heroku create my-cool-chinese-hanviet-api
6 . Push your app to Heroku (you will see a wall of code)
git push heroku master
7 . Visit your newly create app by opening it via heroku:
heroku open
8 . For debugging if something went wrong:
heroku logs --tail
For different ways to deploy the project, refer to the original template