wordnik 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 40

wordnik #

Wordnik API for Dart #

All object models and API calls have been implemented, but with minimal testing. API signatures are likely to change until fully tested.

Basic usage #

import 'package:wordnik/wordnik.dart';

void main() async {

  Wordnik wordnik = Wordnik('YOUR_API_KEY');

  WordObject randomWord = await wordnik.getRandomWord(
    includePartOfSpeech: 'verb',
    minLength: 6,
    maxLength: 10



v1.0.0 - 2018-08-08 #

  • Updated to fully support Dart 2
  • Upgraded json_seralizable and updated object models to use the new default of generated ToJson methods instead of Mixins
  • Removed an unused class and added a missing internal class
  • Added a missing API call (getScrabbleScore)
  • Updated the example and documentation

v0.4.0 - 2018-07-25 #

  • Completed documentation for API calls
  • API calls that used CSV strings were changed to use List<String>
  • Multiple other API call parameters have been modified to work in a more sensible way
  • Renamed ApiTokenStatus to ApiKeyStatus
  • Added enums for use in the API calls that require them

v0.3.3 - 2018-07-15 #

  • Added an ApiException which is now thrown when the API returns an error
  • Modified deleteWordsFromWordList() and addWordsToWordList() to take List<String> instead of List<StringValue>
  • StringValue is no longer exposed as it is now only used internally
  • Completed documentation for account, wordList, and wordLists APIs
  • Added more tests
  • Added dependency for http_status for internal use
  • Major internal refactoring and reorganization for readability/maintainability (doesn't affect public-facing API)

v0.3.2 - 2018-07-14 #

v0.3.1 - 2018-07-11 #

  • Fixed return type for getEtymologies()
  • Fixed some parameter encoding issues
  • Completed examples for all API calls
  • Documentation work continues

v0.3.0 - 2018-07-10 #

  • Implemented the remaining word API calls
  • Added example package (incomplete)
  • Minor internal API adjustments

v0.2.0 - 2018-07-10 #

  • Implemented all wordList API calls
  • Implemented getDefinitions from word API
  • Tweaked JSON serialization options for less cluttered output
  • Removed default values, for now
  • Cleaned up internal API structure

v0.1.0 - 2018-07-06 #

  • Initial Pub release
  • Implemented all account, wordLists, and words API calls
  • Converted all models to use json_serializable

v0.0.1 - 2018-07-03 #

  • Initial commit.


// These aren't necessary for standard operation of the API;
// they are only required for the API key import and some of the example code
import 'dart:math';
import 'package:credentials_helper/credentials_helper.dart';

// Required imports
import 'package:wordnik/wordnik.dart';

void main() async {
  Random random = Random();

  // This isn't required, but you'll need to provide the API key in some way
  Credentials credentials = Credentials.fromFile('credentials.json');

  Wordnik wordnik = Wordnik(credentials.apiKey);

  AuthenticationToken authToken = await wordnik.authenticate(credentials.username, credentials.password);
  print('Authenticated and received token "${authToken.token}".\n');

  User user = await wordnik.getLoggedInUser(authToken.token);
  print('Welcome, ${user.displayName}!\n');

  ApiKeyStatus keyStatus = await wordnik.getApiKeyStatus();
  print('You have made ${keyStatus.totalRequests} requests and have ${keyStatus.remainingCalls} remaining.');
  print('Counter will reset in ${keyStatus.resetsIn.inMinutes} minutes.\n');

  WordObject exampleWord = await wordnik.getWord('example');
  int score = await wordnik.getScrabbleScore(exampleWord.word);
  print('Got word "${exampleWord.word}".');
  print('It has a Scrabble score of $score.\n');

  List<AudioFile> audioFiles = await wordnik.getAudio(exampleWord.word);
  print('${audioFiles.length} audio results found.');
  print('The first one is: "${audioFiles.first.fileUrl}"\n');

  List<Definition> definitions = await wordnik.getDefinitions(exampleWord.word);
  print('${definitions.length} definitions found.');
  print('The first one is: "${definitions.first.text}"\n');

  List<String> etymologies = await wordnik.getEtymologies(exampleWord.word);
  print('${etymologies.length} etymologies found.');
  print('The first one is: "${etymologies.first}"\n');

  ExampleSearchResults examples = await wordnik.getExamples(exampleWord.word);
  print('${examples.examples.length} examples found.');
  print('The first one is: "${examples.examples.first.text}"\n');

  FrequencySummary frequencySummary = await wordnik.getWordFrequency(exampleWord.word);
  Frequency frequency = frequencySummary.frequency[random.nextInt(frequencySummary.frequency.length)];
  print('${frequency.count} occurances from the year ${frequency.year}\n');

  List<Syllable> syllables = await wordnik.getHyphenation(exampleWord.word);
  print('This word has ${syllables.length} syllables: ${syllables.map((s) => s.text).join('-')}\n');

  List<Bigram> bigrams = await wordnik.getPhrases(
    limit: 10
  Bigram bigram = bigrams[random.nextInt(bigrams.length)];
  print('You might say "${bigram.gram1} ${bigram.gram2}".\n');

  List<TextPron> textProns = await wordnik.getTextPronunciations(exampleWord.word);
  TextPron textPron = textProns.first;
  print('It is pronounced "${textPron.raw}".\n');

  List<Related> relatedWords = await wordnik.getRelatedWords(
    relationshipTypes: ['synonym', 'rhyme']
  Related synonyms = relatedWords.firstWhere((word) => word.relationshipType == 'synonym');
  Related rhymes = relatedWords.firstWhere((word) => word.relationshipType == 'rhyme');
  print('${synonyms.words.length} synonyms found, including "${synonyms.words[random.nextInt(synonyms.words.length)]}".\n');
  print('${rhymes.words.length} rhymes found, including "${rhymes.words[random.nextInt(rhymes.words.length)]}".\n');

  Example example = await wordnik.getTopExample(exampleWord.word);
  print('The top example is: "${example.text}" from ${example.title}.\n');

  WordOfTheDay wordOfTheDay = await wordnik.getWordOfTheDay();
  WordOfTheDay previousWordOfTheDay = await wordnik.getWordOfTheDay(date: DateTime.now().subtract(Duration(days: 1)));
  print('The word of the day is "${wordOfTheDay.word}".\n');
  print('Yesterday\'s word of the day was "${previousWordOfTheDay.word}".\n');

  DefinitionSearchResults reverseDictionaryResults = await wordnik.reverseDictionary('eating utensil with prongs');
  Definition reverseDictionary = reverseDictionaryResults.results.first;
  print('A word that means "eating utensil with prongs" might be "${reverseDictionary.word}".\n');

  WordSearchResults searchResults = await wordnik.searchWords(
    isRegex: true,
    skip: 1,
    limit: 1
  WordSearchResult searchResult = searchResults.searchResults.first;
  print('${searchResults.totalResults} words found that contain the sequence "rong", including "${searchResult.word}".\n');

  WordObject randomNoun = await wordnik.getRandomWord(
    partsOfSpeech: PartOfSpeechOptions(noun: true, nounPlural: false, nounPosessive: false, properNoun: false, properNounPlural: false, properNounPosessive: false, givenName: false, familyName: false),
    minLength: 5,
    maxLength: 7
  print('Got random noun "${randomNoun.word}".\n');

  List<WordObject> randomAdjectives = await wordnik.getRandomWords(
    partsOfSpeech: PartOfSpeechOptions(adjective: true),
    minLength: 5,
    maxLength: 7,
    limit: 3
  print('Got random adjectives: ${randomAdjectives.map((adjective) => adjective.word).join(', ')}\n');

  WordList newWordList = WordList(
    'Temporary Example List',
    description: 'Created by the Wordnik API for Dart.'
  WordList createdWordList = await wordnik.createWordList(
  print('New word list "${createdWordList.name}" created with permalink "${createdWordList.permalink}".\n');

  List<String> wordsToAdd = List<String>()
    ..addAll(randomAdjectives.map((word) => word.word));
  await wordnik.addWordsToWordList(
  print('Added ${wordsToAdd.length} words to "${createdWordList.name}".\n');

  List<String> wordsToDelete = List<String>()
  await wordnik.deleteWordsFromWordList(
  print('Deleted ${wordsToDelete.length} words from "${createdWordList.name}".\n');

  WordList modifiedWordList = createdWordList
    ..description = 'I feel like a ${randomAdjectives[random.nextInt(randomAdjectives.length)].word} ${randomNoun.word} ${exampleWord.word}.';
  await wordnik.updateWordList(
  print('Updated description for "${modifiedWordList.name}".\n');

  List<WordList> userWordLists = await wordnik.getWordListsForLoggedInUser(authToken.token);
  print('Found ${userWordLists.length} word lists. The first one is titled "${userWordLists.first.name}".\n');

  WordList ourWordList = await wordnik.getWordListByPermalink(
  print('"${ourWordList.name}" now contains ${ourWordList.numberWordsInList} words and the description is "${ourWordList.description}".\n');

  List<WordListWord> wordListWords = await wordnik.getWordListWords(
  print('The words on the list are: ${wordListWords.map((word) => word.word).join(', ')}.\n');

  await wordnik.deleteWordList(
  print('Deleted "${ourWordList.name}".\n');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  wordnik: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:wordnik/wordnik.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 1, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/src/models/definition.g.dart. (-3.45 points)

Analysis of lib/src/models/definition.g.dart reported 7 hints, including:

line 10 col 10: Unnecessary new keyword.

line 16 col 21: Unnecessary new keyword.

line 22 col 21: Unnecessary new keyword.

line 26 col 71: Unnecessary new keyword.

line 28 col 69: Unnecessary new keyword.

Fix lib/src/models/example.g.dart. (-1.99 points)

Analysis of lib/src/models/example.g.dart reported 4 hints:

line 10 col 10: Unnecessary new keyword.

line 16 col 13: Unnecessary new keyword.

line 21 col 13: Unnecessary new keyword.

line 24 col 13: Unnecessary new keyword.

Fix lib/src/models/word_of_the_day.g.dart. (-1.99 points)

Analysis of lib/src/models/word_of_the_day.g.dart reported 4 hints:

line 11 col 10: Unnecessary new keyword.

line 15 col 13: Unnecessary new keyword.

line 24 col 21: Unnecessary new keyword.

line 30 col 21: Unnecessary new keyword.

Fix additional 79 files with analysis or formatting issues. (-21.98 points)

Additional issues in the following files:

  • lib/src/models/example_search_results.g.dart (3 hints)
  • lib/src/models/part_of_speech.g.dart (3 hints)
  • lib/src/models/definition_search_results.g.dart (2 hints)
  • lib/src/models/facet.g.dart (2 hints)
  • lib/src/models/frequency_summary.g.dart (2 hints)
  • lib/src/models/root.g.dart (2 hints)
  • lib/src/models/sentence.g.dart (2 hints)
  • lib/src/models/word_search_results.g.dart (2 hints)
  • lib/src/models/api_exception.g.dart (1 hint)
  • lib/src/models/api_key_status.g.dart (1 hint)
  • lib/src/models/audio_file.g.dart (1 hint)
  • lib/src/models/authentication_token.g.dart (1 hint)
  • lib/src/models/bigram.g.dart (1 hint)
  • lib/src/models/category.g.dart (1 hint)
  • lib/src/models/citation.g.dart (1 hint)
  • lib/src/models/content_provider.g.dart (1 hint)
  • lib/src/models/example_usage.g.dart (1 hint)
  • lib/src/models/facet_value.g.dart (1 hint)
  • lib/src/models/frequency.g.dart (1 hint)
  • lib/src/models/label.g.dart (1 hint)
  • lib/src/models/long.g.dart (1 hint)
  • lib/src/models/note.g.dart (1 hint)
  • lib/src/models/related.g.dart (1 hint)
  • lib/src/models/scored_word.g.dart (1 hint)
  • lib/src/models/simple_definition.g.dart (1 hint)
  • lib/src/models/simple_example.g.dart (1 hint)
  • lib/src/models/string_value.g.dart (1 hint)
  • lib/src/models/syllable.g.dart (1 hint)
  • lib/src/models/text_pron.g.dart (1 hint)
  • lib/src/models/user.g.dart (1 hint)
  • lib/src/models/word_list.g.dart (1 hint)
  • lib/src/models/word_list_word.g.dart (1 hint)
  • lib/src/models/word_object.g.dart (1 hint)
  • lib/src/models/word_search_result.g.dart (1 hint)
  • lib/src/api_client.dart (Run dartfmt to format lib/src/api_client.dart.)
  • lib/src/apis/account_apis.dart (Run dartfmt to format lib/src/apis/account_apis.dart.)
  • lib/src/apis/word_apis.dart (Run dartfmt to format lib/src/apis/word_apis.dart.)
  • lib/src/apis/word_list_apis.dart (Run dartfmt to format lib/src/apis/word_list_apis.dart.)
  • lib/src/apis/word_lists_apis.dart (Run dartfmt to format lib/src/apis/word_lists_apis.dart.)
  • lib/src/apis/words_apis.dart (Run dartfmt to format lib/src/apis/words_apis.dart.)
  • lib/src/enums.dart (Run dartfmt to format lib/src/enums.dart.)
  • lib/src/models/api_exception.dart (Run dartfmt to format lib/src/models/api_exception.dart.)
  • lib/src/models/api_key_status.dart (Run dartfmt to format lib/src/models/api_key_status.dart.)
  • lib/src/models/audio_file.dart (Run dartfmt to format lib/src/models/audio_file.dart.)
  • lib/src/models/authentication_token.dart (Run dartfmt to format lib/src/models/authentication_token.dart.)
  • lib/src/models/bigram.dart (Run dartfmt to format lib/src/models/bigram.dart.)
  • lib/src/models/category.dart (Run dartfmt to format lib/src/models/category.dart.)
  • lib/src/models/citation.dart (Run dartfmt to format lib/src/models/citation.dart.)
  • lib/src/models/content_provider.dart (Run dartfmt to format lib/src/models/content_provider.dart.)
  • lib/src/models/definition.dart (Run dartfmt to format lib/src/models/definition.dart.)
  • lib/src/models/definition_search_results.dart (Run dartfmt to format lib/src/models/definition_search_results.dart.)
  • lib/src/models/example.dart (Run dartfmt to format lib/src/models/example.dart.)
  • lib/src/models/example_search_results.dart (Run dartfmt to format lib/src/models/example_search_results.dart.)
  • lib/src/models/example_usage.dart (Run dartfmt to format lib/src/models/example_usage.dart.)
  • lib/src/models/facet.dart (Run dartfmt to format lib/src/models/facet.dart.)
  • lib/src/models/facet_value.dart (Run dartfmt to format lib/src/models/facet_value.dart.)
  • lib/src/models/frequency.dart (Run dartfmt to format lib/src/models/frequency.dart.)
  • lib/src/models/frequency_summary.dart (Run dartfmt to format lib/src/models/frequency_summary.dart.)
  • lib/src/models/label.dart (Run dartfmt to format lib/src/models/label.dart.)
  • lib/src/models/long.dart (Run dartfmt to format lib/src/models/long.dart.)
  • lib/src/models/note.dart (Run dartfmt to format lib/src/models/note.dart.)
  • lib/src/models/part_of_speech.dart (Run dartfmt to format lib/src/models/part_of_speech.dart.)
  • lib/src/models/part_of_speech_options.dart (Run dartfmt to format lib/src/models/part_of_speech_options.dart.)
  • lib/src/models/related.dart (Run dartfmt to format lib/src/models/related.dart.)
  • lib/src/models/root.dart (Run dartfmt to format lib/src/models/root.dart.)
  • lib/src/models/scored_word.dart (Run dartfmt to format lib/src/models/scored_word.dart.)
  • lib/src/models/sentence.dart (Run dartfmt to format lib/src/models/sentence.dart.)
  • lib/src/models/simple_definition.dart (Run dartfmt to format lib/src/models/simple_definition.dart.)
  • lib/src/models/simple_example.dart (Run dartfmt to format lib/src/models/simple_example.dart.)
  • lib/src/models/string_value.dart (Run dartfmt to format lib/src/models/string_value.dart.)
  • lib/src/models/syllable.dart (Run dartfmt to format lib/src/models/syllable.dart.)
  • lib/src/models/text_pron.dart (Run dartfmt to format lib/src/models/text_pron.dart.)
  • lib/src/models/user.dart (Run dartfmt to format lib/src/models/user.dart.)
  • lib/src/models/word_list.dart (Run dartfmt to format lib/src/models/word_list.dart.)
  • lib/src/models/word_list_word.dart (Run dartfmt to format lib/src/models/word_list_word.dart.)
  • lib/src/models/word_object.dart (Run dartfmt to format lib/src/models/word_object.dart.)
  • lib/src/models/word_of_the_day.dart (Run dartfmt to format lib/src/models/word_of_the_day.dart.)
  • lib/src/models/word_search_result.dart (Run dartfmt to format lib/src/models/word_search_result.dart.)
  • lib/src/models/word_search_results.dart (Run dartfmt to format lib/src/models/word_search_results.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-30 points)

The version constraint in pubspec.yaml does not support the latest published versions for 3 dependencies (http, intl, json_annotation).

Package is getting outdated. (-64.38 points)

The package was last published 85 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
http ^0.11.3 0.11.3+17 0.12.0+4
intl ^0.15.7 0.15.8 0.16.1
json_annotation ^1.0.0 1.2.0 3.0.1
Transitive dependencies
async 2.4.1
charcode 1.1.3
collection 1.14.12
http_parser 3.1.4
meta 1.1.8
path 1.6.4
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
build_runner ^0.9.2
credentials_helper ^1.0.3
json_serializable ^1.0.0
test ^1.3.0