Skip to content

Commit

Permalink
UPDATE index.md FIX grmticl errors
Browse files Browse the repository at this point in the history
  • Loading branch information
eeshaansawant committed Dec 23, 2024
1 parent 8fbbbef commit f45fe6e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
---
order:
order:
---

## Description

Generate definitions for your words in your document using API Ninjas' Dictionary API. Requires an API key.
Generates word definitions in your document using the [Dictionary API](https://api-ninjas.com/api/dictionary) offered by [API Ninjas](https://api-ninjas.com).

To use this macro, you need to obtain your own API key from API Ninjas.

<!-- This code snippet is shown in the screenshot. -->

<!-- eslint-skip -->

```ts
(function()
{
const oDocument = Api.GetDocument();
const oRange = oDocument.GetRangeBySelect();
const word = oRange.GetText();
$.ajax({
method: 'GET',
url: 'https://api.api-ninjas.com/v1/dictionary?word=' + word,
headers: { 'X-Api-Key': 'your-api-key'},
contentType: 'application/json',
success: function(result) {
console.log(result);
const text = result.definition;
const oParagraph = Api.CreateParagraph();
oParagraph.AddText(text);
oDocument.InsertContent([oParagraph], { "KeepTextOnly": true });
(function () {
const oDocument = Api.GetDocument();
const oRange = oDocument.GetRangeBySelect();
const word = oRange.GetText();
$.ajax({
method: "GET",
url: "https://api.api-ninjas.com/v1/dictionary?word=" + word,
headers: { "X-Api-Key": "your-api-key" },
contentType: "application/json",
success: function (result) {
console.log(result);
const text = result.definition;
const oParagraph = Api.CreateParagraph();
oParagraph.AddText(text);
oDocument.InsertContent([oParagraph], { KeepTextOnly: true });
},
error: function ajaxError(jqXHR) {
console.error('Error: ', jqXHR.responseText);
}
});
console.error("Error: ", jqXHR.responseText);
},
});
})();
```

Expand All @@ -42,6 +43,7 @@ Methods used: GetDocument, GetRangeBySelect, GetText, CreateParagraph, AddText,
<!-- code generated with AI -->

```vb

```

## Result
Expand Down
4 changes: 2 additions & 2 deletions site/pages/Docs/Plugin and Macros/Macros/Samples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ In this example we are summing the answer of all highlighted cells in a spreadsh

## Generate word definitions

In this example we are generating word definitions in our documents using API Ninjas' Dictionary API.
In this example we are generating word definitions in our documents using the Dictionary API offered by API Ninjas.

[More](Generate%20word%20definitions/index.md);
[More](Generate%20word%20definitions/index.md)

## Support

Expand Down

0 comments on commit f45fe6e

Please sign in to comment.