python wordnik setup

23 views
Skip to first unread message

John Lukow

unread,
Mar 9, 2024, 3:53:13 PMMar 9
to Wordnik API
I ran across wordnik as a resource from another program.  I have obtained an API key, and created a simple script from the documentation page:

from wordnik import *

apiKey = 'key i obtained from the website here'
client = swagger.ApiClient(apiKey, apiUrl)

wordApi = WordApi.WordApi(client)
example = wordApi.getTopExample('irony')
print (example)

I get an error name 'swagger' not defined. The interpreter also does not like WordApi.

Suggestions?

Erin McKean

unread,
Mar 10, 2024, 12:50:16 PMMar 10
to wordn...@googlegroups.com
Hi John!

Can you let me know what version of Python you are using? I tried this with 3.7.3 and it worked. Also, your last line should be

`print (example.text)`

to get the text of the example.

I hope this helps!

Thank you for using the Wordnik API!

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/f2dff636-7e7a-49f6-9196-473eb7dc836en%40googlegroups.com.

John Lukow

unread,
Mar 10, 2024, 8:19:07 PMMar 10
to Wordnik API
Great to hear from you!  I was worried this group was no longer active.  I decided to give up manually setting up the environment in Visual Studio and just switched over to Pycharm.  Things worked better after that.  I probably had something wrong.

I have built a random word and definition function since then successfully.

I am glad you are here because there is not much on StackOverflow pertaining to wordnik.

I am working on a wrdl clone and using wordnik to determine the word and then provide definitions at the end.  I am also playing with a hangman game, that I may backward apply wordnik to, since the random word generator I used did not include definitions.

I'm struggling a little with syntax, but figuring it out.  I've only been playing with Python for about 30 days, but really like it so far!!
Reply all
Reply to author
Forward
0 new messages