Skip to content

Commit 1a124f5

Browse files
monkenrwstauner
authored andcommitted
Updated Beta API Docs (markdown)
1 parent 1ed21ea commit 1a124f5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/Beta-API-docs.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ All CPAN Authors Who Have Updated MetaCPAN Profiles:
5353

5454
[[http://api.metacpan.org/v0/author/_search?q=updated:*&sort=updated:desc]]
5555

56+
## Querying the API with ElasticSearch.pm
57+
58+
The API server at api.metacpan.org is a wrapper around an ElasticSearch instance. It adds support for the convenient GET URLs, handles authentication and does some access control. Therefore you can use the powerful API of [ElasticSearch.pm](https://metacpan.org/module/ElasticSearch) to query MetaCPAN:
59+
60+
```perl
61+
use ElasticSearch;
62+
63+
my $es = ElasticSearch->new( servers => 'api.metacpan.org', no_refresh => 1 );
64+
65+
my $scroller = $es->scrolled_search(
66+
query => { match_all => {} },
67+
search_type => 'scan',
68+
scroll => '5m',
69+
index => 'v0',
70+
type => 'release',
71+
size => 100,
72+
);
73+
74+
while ( my $result = $scroller->next ) {
75+
print $result->{_source}->{author}, $/;
76+
}
77+
```
78+
5679
## POST Searches
5780

5881
Please feel free to add queries here as you use them in your own work, so that others can learn from you.

0 commit comments

Comments
 (0)