DEV Community

Thijs Boelman
Thijs Boelman

Posted on

First RESTful API in Express: Word List Generator API

Why did I create this?

I stumbled across an article of someone who made his first RESTful API in JavaScript. I was curious on how it was built and gave it a look. I have never made an API myself, so I wanted to give it a try. Also I saw it was deployed on Heroku which I had never heard of. It seemed very interesting. (Source)

Development

After thinking of an idea for an API, I came up with a word list generator. It gives you an array of words which can be used for whatever your creative brain can think of e.g. a hangman game.

How does it work

Whenever an API call gets made, it grabs an x amount of random words from a wordlist. The wordlist is a JSON array of words. I've created 2 wordlists for 2 languages (english & dutch). You configure the data you want from the API through querystrings. Where lang is the language and amount is the amount of words you want. (max 1000.) If you want you can take a look inside the GitHub Repository.

How to use it

Languages:

  • EN - English

  • NL - Dutch

  • IT - Italian

Example API call

https://wordgenerator-api.herokuapp.com/api/v1/resources/words?lang=EN&amount=5

There are 2 querystrings:

  • lang=EN - to specify the language.

  • amount=5 - the amount of random words. (max. 1000)

These are also the default values.

Example response:

[
    "humanitarian",
    "furniture",
    "committees",
    "surprised",
    "procedure"
]
Enter fullscreen mode Exit fullscreen mode

Top comments (0)