wordnik 0.3.3

  • README.md
  • Example
  • Installing
  • Versions
  • new57


Wordnik API for Dart

Work in progress. Currently, all object models and API calls have been implemented, but with minimal testing. API signatures are likely to change as development continues.

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



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');

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

  WordObject exampleWord = await wordnik.getWord('example');
  print('Got word "${exampleWord.word}".\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(
    allowRegex: 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(
    includePartOfSpeech: 'noun',
    minLength: 5,
    maxLength: 7
  print('Got random noun "${randomNoun.word}".\n');

  List<WordObject> randomAdjectives = await wordnik.getRandomWords(
    includePartOfSpeech: 'adjective',
    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: "^0.3.3"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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';
Version Uploaded Documentation Archive
0.3.3 Jul 15, 2018 Go to the documentation of wordnik 0.3.3 Download wordnik 0.3.3 archive
0.3.2 Jul 14, 2018 Go to the documentation of wordnik 0.3.2 Download wordnik 0.3.2 archive
0.3.1 Jul 12, 2018 Go to the documentation of wordnik 0.3.1 Download wordnik 0.3.1 archive
0.3.0 Jul 11, 2018 Go to the documentation of wordnik 0.3.0 Download wordnik 0.3.0 archive
0.2.0 Jul 10, 2018 Go to the documentation of wordnik 0.2.0 Download wordnik 0.2.0 archive
0.1.0 Jul 7, 2018 Go to the documentation of wordnik 0.1.0 Download wordnik 0.1.0 archive


We analyzed this package on Jul 16, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
16 / 100
Code health derived from static analysis. [more]
98 / 100
Reflects how tidy and up-to-date the package is. [more]
99 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:wordnik/wordnik.dart.


  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 44 hints.

    Run dartfmt to format lib/src/api_client.dart.

    Run dartfmt to format lib/src/apis/account_apis.dart.

    Similar analysis of the following files failed:

    • lib/src/apis/word_apis.dart (hint)
    • lib/src/apis/word_list_apis.dart (hint)
    • lib/src/apis/word_lists_apis.dart (hint)
    • lib/src/apis/words_apis.dart (hint)
    • lib/src/enums.dart (hint)
    • lib/src/models/api_exception.dart (hint)
    • lib/src/models/api_token_status.dart (hint)
    • lib/src/models/audio_file.dart (hint)
    • lib/src/models/audio_type.dart (hint)
    • lib/src/models/authentication_token.dart (hint)
    • lib/src/models/bigram.dart (hint)
    • lib/src/models/category.dart (hint)
    • lib/src/models/citation.dart (hint)
    • lib/src/models/content_provider.dart (hint)
    • lib/src/models/definition.dart (hint)
    • lib/src/models/definition_search_results.dart (hint)
    • lib/src/models/example.dart (hint)
    • lib/src/models/example_search_results.dart (hint)
    • lib/src/models/example_usage.dart (hint)
    • lib/src/models/facet.dart (hint)
    • lib/src/models/facet_value.dart (hint)
    • lib/src/models/frequency.dart (hint)
    • lib/src/models/frequency_summary.dart (hint)
    • lib/src/models/label.dart (hint)
    • lib/src/models/note.dart (hint)
    • lib/src/models/part_of_speech.dart (hint)
    • lib/src/models/related.dart (hint)
    • lib/src/models/root.dart (hint)
    • lib/src/models/scored_word.dart (hint)
    • lib/src/models/sentence.dart (hint)
    • lib/src/models/simple_definition.dart (hint)
    • lib/src/models/simple_example.dart (hint)
    • lib/src/models/string_value.dart (hint)
    • lib/src/models/syllable.dart (hint)
    • lib/src/models/text_pron.dart (hint)
    • lib/src/models/user.dart (hint)
    • lib/src/models/word_list.dart (hint)
    • lib/src/models/word_list_word.dart (hint)
    • lib/src/models/word_object.dart (hint)
    • lib/src/models/word_of_the_day.dart (hint)
    • lib/src/models/word_search_result.dart (hint)
    • lib/src/models/word_search_results.dart (hint)
  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.58.0 <2.0.0
http ^0.11.3 0.11.3+17
http_status ^1.0.1 1.0.1+1
intl ^0.15.6 0.15.6
json_annotation ^0.2.9 0.2.9
Transitive dependencies
async 2.0.7
charcode 1.1.2
collection 1.14.10
http_parser 3.1.2
path 1.6.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
build_runner ^0.9.1
credentials_helper ^1.0.1
json_serializable ^0.5.8
test ^1.2.0