These examples are also available on the main readme.
## API searching/scraping
These are usage examples of the api library, providing results directly.
### Word/phrase search (provided by official Jisho API)
This returns the same results as the official [Jisho.org](https://jisho.org/) API. See the discussion of that [here](https://jisho.org/forum/54fefc1f6e73340b1f160000-is-there-any-kind-of-search-api).
```dart
import 'package:unofficial_jisho_api/api.dart' as jisho;
void main() async {
jisho.searchForPhrase('日').then((result) {
...
...
...
});
}
```
### Kanji search
```dart
import 'dart:convert' show jsonEncode;
import 'package:unofficial_jisho_api/api.dart' as jisho;
void main() async {
await jisho.searchForKanji('語').then((result) {
print('Found: ${result.found}');
print('Taught in: ${result.taughtIn}');
print('JLPT level: ${result.jlptLevel}');
print('Newspaper frequency rank: ${result.newspaperFrequencyRank}');
This scrapes the word/phrase page on Jisho.org. This can get you some data that the official API doesn't have, such as JLPT level and part-of-speech. The official API (`searchForPhrase`) should be preferred if it has the data you need.
```dart
import 'dart:convert';
import 'package:unofficial_jisho_api/api.dart' as jisho;
final JsonEncoder encoder = JsonEncoder.withIndent(' ');
void main() async {
await jisho.scrapeForPhrase('谷').then((data) {
print(encoder.convert(data));
});
}
```
## Parsing
You can provide the HTML responses from Jisho yourself. This can be useful if you need to use a CORS proxy or something. You can do whatever you need to do to get the HTML and then provide it to this module's parsing functions. For example:
### Parse kanji page HTML
```dart
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:unofficial_jisho_api/parser.dart' as jisho_parser;
final JsonEncoder encoder = JsonEncoder.withIndent(' ');
const String searchKanji = '車';
final String searchURI = jisho_parser.uriForKanjiSearch(searchKanji);
void main() async {
await http.get(searchURI).then((result) {
final parsedResult = jisho_parser.parseKanjiPageData(result.body, searchKanji);