Skip to content

A REST API built with Next.js and TypeScript to use as a backend for Wordle clones.

License

Notifications You must be signed in to change notification settings

petergeorgas/Wordle-API

Repository files navigation

Worlde API

A simple API designed to run as a serverless function that you can use for your Wordle clone. The whole point of this API is to allow you to create a Wordle clone that keeps the answer OFF of the user's computer. This enables you, the developer, to completely prevent users from cheating by looking for the locally-stored answer to the day's word puzzle.

Usage

A live version of this application is currently hosted on Vercel. The answer to the the day's Wordle is located here. To consume the API, Send a POST request to https://wordle-api.vercel.app/api/wordle with the request body:

{
    "guess":"words"
}

, where "words" is whatever word you'd like to guess. A correct guess yields an API response that looks like this:

{
	"guess": "cross",
	"was_correct": true
}

while an incorrect guess yields an API response that looks like this:

{
	"guess": "beans",
	"was_correct": false,
	"character_info": [
		{
			"char": "b",
			"scoring": {
				"in_word": false,
				"correct_idx": false
			}
		},
		{
			"char": "e",
			"scoring": {
				"in_word": false,
				"correct_idx": false
			}
		},
		{
			"char": "a",
			"scoring": {
				"in_word": false,
				"correct_idx": false
			}
		},
		{
			"char": "n",
			"scoring": {
				"in_word": false,
				"correct_idx": false
			}
		},
		{
			"char": "s",
			"scoring": {
				"in_word": true,
				"correct_idx": true
			}
		}
	]
}

Pseudorandomness

The word of the day is pseudorandomly-selected by generating an index seeded by the number of days the current day is from 01/01/2000.

Limitations

  • Currently, the word bank only consits of 5-letter words. Eventually, shorter (4-letter) and longer (6-, 7-, 8- letter) words will be added
  • The API does not currently check to see if a guess is in the word bank, which is a feature of many Wordle clones, as well as Wordle itself.

About

A REST API built with Next.js and TypeScript to use as a backend for Wordle clones.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published