An unofficial .NET package that wraps up the Oxford Languages API.
- First, obtain your App ID and App Key from https://developer.oxforddictionaries.com/.
Note: On the 1st of April, 2024, all plans except the Business plan were discontinued.
- Install the package:
Nuget: NuGet\Install-Package OxfordDictionaryApiDotNet
Project: <PackageReference Include="OxfordDictionaryApiDotNet"/>
.NET CLI: dotnet add package OxfordDictionaryApiDotNet
Or simply download this repository from the 'Code' dropdown menu.
It takes just 3 lines of code to retrieve a definition:
- Use the Entries client to fetch information about a word:
var entries = new EntriesClient("appId", "appKey");
var entry = await entries.FindEntryAsync("entanglement");
- There are many things a word can return, but you can always use a helper method for convenience:
var definition = entry.FindFirstDefinition();
The above simplifies the following process:
var result = entry?.Results?.FirstOrDefault();
var lexEntry = result?.LexicalEntries?.FirstOrDefault();
var innerEntry = lexEntry?.Entries?.FirstOrDefault();
var sense = innerEntry?.Senses?.FirstOrDefault();
var definition = sense?.Definitions?.FirstOrDefault();
- You can also define a main client that houses both the Entries and Lemmas clients:
var config = new OxfordDictionaryClientConfig
{
AppId = "yourAppId",
AppKey = "yourAppKey"
};
var client = new OxfordDictionaryClient(config);
var entriesClient = client.EntriesClient;
var lemmasClient = client.LemmasClient;
Please note that this is not a straightforward, one-size-fits-all dictionary. A single entry can provide lots of details, most of which you won't even need. While I have tried to provide some guidance in my XML comments, for a more in-depth understanding of how the Oxford Dictionaries API works, and their data structure, please visit their official documentation webpage: https://developer.oxforddictionaries.com/documentation.