DEV Community

Thijs Boelman
Thijs Boelman

Posted on

4 2

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

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay