404 error when fetching synonyms

24 views
Skip to first unread message

Nox

unread,
Dec 19, 2022, 6:44:03 AM12/19/22
to Wordnik API
I am writing a game, where I first fetch a random word and then fetch the synonyms for that word. About 1/3 of the time the fetch for synonyms of the random word returns a 404 that gets printed out in the devtools console (will always print out since it's a 404).

Is there any good way to get random words that most have synonyms?

Because right now my api key is printed out in the devtools everytime the fetch fails..

I highly recommend that you fix this. All words in the database should contain a object synonym. If there are no synonyms just return an empty array, easy as that. Becuase right now API-keys are printed out. Or add a retriction to get random words.

Erin McKean

unread,
Dec 27, 2022, 11:01:25 AM12/27/22
to wordn...@googlegroups.com
Hi Nox! I am so sorry to take so long to reply to this!

So it sounds like there are two problems. One is that there's no way to reliably pick random words with synonyms. That's a great idea, and I'll add it to the list.
The other is that it sounds like you're calling the Wordnik API from the client, and that's not a great idea for exactly the reason you state: it makes your key public, which is against our terms of service. We strongly require that you keep your key private. You can use a proxy server to do so -- there are a lot of good options, depending on what language and framework you use.

In the meantime, you might get better results by using something like the Moby dataset (https://en.wikipedia.org/wiki/Moby_Project#Thesaurus). It's not all that big, so it might be possible to load it in the client and then choose a random line.

Good luck with your game!

Yours,

Erin
---------------------
Erin McKean
Wordnik
@emc...@xoxo.zone/@wor...@wordnik.social
Wordnik is a 501(c)3 nonprofit organization
The Wordnik mission: every English word, available to everyone, everywhere

--
You received this message because you are subscribed to the Google Groups "Wordnik API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wordnik-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wordnik-api/79255105-8815-4d22-992a-8d04297af894n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages