SlideShare a Scribd company logo
(Ab)Using the
MetaCPAN API for
Fun and Profit v2013
Olaf Alders (OALDERS)
@wundercounter
Thursday, 13 June, 13
Architecture
• Built on ElasticSearch
• Uses Catalyst as a thin wrapper
Thursday, 13 June, 13
Objectives
• Rough introduction to the API
• Some ElasticSearch pointers
Thursday, 13 June, 13
ElasticSearch
• ElasticSearch (ES) has indexes and
types
• In RDBMS terms?
• index = database
• type = table
• OK to think of it that way
Thursday, 13 June, 13
Let’s look at types
• Every type has a corresponding
endpoint
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13
Base URL
• http://api.metacpan.org/v0
Thursday, 13 June, 13
Endpoints
• Convenience endpoints
• ElasticSearch endpoints
• There *is* some overlap
Thursday, 13 June, 13
Think of it this way
• Every type has a corresponding
endpoint
• Not every endpoint has a
corresponding type
Thursday, 13 June, 13
Convenience Endpoints
Thursday, 13 June, 13
Convenience Endpoints
• /author/DOY
• /distribution/Moose
• /release/Moose
• /module/Moose
• /pod/Moose
• /search/autocomplete?q=Moose
• /search/reverse_dependencies/Moose
Thursday, 13 June, 13
Versioned Convenience
Endpoints
• /release/DOY/Moose-2.0001
• /module/DOY/Moose-2.0001/lib/Moose.pm
• /pod/DOY/Moose-2.0001/lib/Moose.pm
• /search/reverse_dependencies/DOY/Moose-2.0001
Thursday, 13 June, 13
Special Cases
• Some convenience URLs don’t expose
ElasticSearch’s DSL
Thursday, 13 June, 13
/pod
• GET your /pod
• Don’t send JSON in your request
• Don’t expect JSON in your response
Thursday, 13 June, 13
Set content-type via param or header
• /pod/Moose?content-type=text/html (default)
• /pod/Moose?content-type=text/plain
• /pod/Moose?content-type=text/x-pod
• /pod/Moose?content-type=text/x-markdown
Thursday, 13 June, 13
/pod the easy way
use MetaCPAN::API;
my $mcpan = MetaCPAN::API->new;
my $html_pod = $mcpan->pod(
module => 'Carton',
'content-type' => 'text/plain'
);
Text
(MetaCPAN::API::Tiny has the same syntax)
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13
Autocomplete Made Easy
• /v0/search/autocomplete?q=HTTP
• GET this endpoint
• No JSON in
• Expect JSON out
Thursday, 13 June, 13
Thursday, 13 June, 13
Alfred 2 Autocompletion
https://github.com/2shortplanks/alfred-metacpan
Thursday, 13 June, 13
The (real) Endpoints
Thursday, 13 June, 13
The (real) Endpoints
• /author
Thursday, 13 June, 13
The (real) Endpoints
• /author
• /distribution
Thursday, 13 June, 13
The (real) Endpoints
• /author
• /distribution
• /favorite
Thursday, 13 June, 13
The (real) Endpoints
• /author
• /distribution
• /favorite
• /file
Thursday, 13 June, 13
The (real) Endpoints
• /author
• /distribution
• /favorite
• /file
• /rating
Thursday, 13 June, 13
The (real) Endpoints
• /author
• /distribution
• /favorite
• /file
• /rating
• /release
Thursday, 13 June, 13
Why is /module missing?
• A module is a kind of file
• file.module.name = $module_name
Thursday, 13 June, 13
One special endpoint
• https://api.metacpan.org/v0/user
• You need to be logged in
• Note the SSL ^^^
Thursday, 13 June, 13
Exploring Endpoints
• Documentation is weak
• You may need to dig around a bit
Thursday, 13 June, 13
MetaCPAN Explorer
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13
Dig into the API code
• https://github.com/CPAN-API/cpan-
api/blob/master/lib/MetaCPAN/
Document/Author.pm
Thursday, 13 June, 13
Good Habits
• Make your life easier
Thursday, 13 June, 13
Enable Compression
• use WWW::Mechanize::Gzip
• use WWW::Mechanize::Cached::GZip
• Or set the appropriate request header
Thursday, 13 June, 13
POST POST POST
• Beyond the most trivial of queries,
GET is a PITA.
• POSTing will make your life easier
Thursday, 13 June, 13
Are you asking for too much?
• There is an upper limit of 5,000 on
query size
• If you need more data points, use the
scrolling API
Thursday, 13 June, 13
Scrolling
• The scrolling API allows you to iterate
over an arbitrary number of results
• Be aware that when you scroll, your
docs will come back unsorted
• Let ElasticSearch.pm take care of the
details
Thursday, 13 June, 13
query vs filter context
• generally you just want filters
• use a query if you need to sort your
results by relevance
• https://metacpan.org/module/DRTECH/ElasticSearch-
SearchBuilder-0.18/lib/ElasticSearch/SearchBuilder.pm#QUERY-
FILTER-CONTEXT
Thursday, 13 June, 13
Let’s Get Started
Thursday, 13 June, 13
Let’s Get Started
• We want to fetch some data
Thursday, 13 June, 13
Let’s Get Started
• We want to fetch some data
• TIMTOWDI
Thursday, 13 June, 13
Code Samples
• https://github.com/cpan-api/
metacpan-examples
Thursday, 13 June, 13
In closing...
Thursday, 13 June, 13
Hack on *MetaCPAN*
• Download a pre-configured VM
• Requires VirtualBox + vagrant
• https://github.com/cpan-api/
metacpan-developer
Thursday, 13 June, 13
Production
• Before you go live...
Thursday, 13 June, 13
Rule #1
• Be polite
Thursday, 13 June, 13
Rule #2
• There isn’t actually a rule #2. Just be
polite.
Thursday, 13 June, 13
Identify Yourself
• Not mandatory, but encouraged
• Do this when you’re in production
• https://github.com/CPAN-API/cpan-api/wiki/API-Consumers
Thursday, 13 June, 13
Getting Help
• #metacpan on irc.perl.org
• https://metacpan.org/about/resources
Thursday, 13 June, 13
Resources
• https://github.com/CPAN-API/cpan-
api/wiki/Beta-API-docs
• http://www.slideshare.net/
clintongormley/terms-of-endearment-
the-elasticsearch-query-dsl-explained
Thursday, 13 June, 13
Bonus Slides
• These apps all use the MetaCPAN API
Thursday, 13 June, 13
iCPAN - iPhone
Thursday, 13 June, 13
iCPAN - iPad
Thursday, 13 June, 13
Android
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13
Thursday, 13 June, 13

More Related Content

What's hot (20)

PPTX
Spring boot - an introduction
Jonathan Holloway
 
PPTX
Typescript Fundamentals
Sunny Sharma
 
PDF
Angular & RXJS: examples and use cases
Fabio Biondi
 
PDF
React & GraphQL
Nikolas Burk
 
PPTX
Policy Enforcement on Kubernetes with Open Policy Agent
VMware Tanzu
 
PDF
Fast as C: How to Write Really Terrible Java
Charles Nutter
 
PDF
Introduction to CKAN
OKCon2013
 
PDF
Testing Angular
Lilia Sfaxi
 
PDF
Kata: Hexagonal Architecture / Ports and Adapters
holsky
 
PPTX
Postman
mathieupassenaud
 
PDF
Reactive stream processing using Akka streams
Johan Andrén
 
PDF
Getting Started with Apache Spark on Kubernetes
Databricks
 
PDF
angular fundamentals.pdf
NuttavutThongjor1
 
ODP
Design Patterns in ZK: Java MVVM as Model-View-Binder
Simon Massey
 
PPTX
Angular interview questions
Goa App
 
PDF
Kafka for Microservices – You absolutely need Avro Schemas! | Gerardo Gutierr...
HostedbyConfluent
 
PDF
Web-Scale Graph Analytics with Apache® Spark™
Databricks
 
PDF
Graphql
Niv Ben David
 
PPTX
Databricks MLflow Object Relationships
amesar0
 
PDF
Action Jackson! Effective JSON processing in Spring Boot Applications
Joris Kuipers
 
Spring boot - an introduction
Jonathan Holloway
 
Typescript Fundamentals
Sunny Sharma
 
Angular & RXJS: examples and use cases
Fabio Biondi
 
React & GraphQL
Nikolas Burk
 
Policy Enforcement on Kubernetes with Open Policy Agent
VMware Tanzu
 
Fast as C: How to Write Really Terrible Java
Charles Nutter
 
Introduction to CKAN
OKCon2013
 
Testing Angular
Lilia Sfaxi
 
Kata: Hexagonal Architecture / Ports and Adapters
holsky
 
Reactive stream processing using Akka streams
Johan Andrén
 
Getting Started with Apache Spark on Kubernetes
Databricks
 
angular fundamentals.pdf
NuttavutThongjor1
 
Design Patterns in ZK: Java MVVM as Model-View-Binder
Simon Massey
 
Angular interview questions
Goa App
 
Kafka for Microservices – You absolutely need Avro Schemas! | Gerardo Gutierr...
HostedbyConfluent
 
Web-Scale Graph Analytics with Apache® Spark™
Databricks
 
Graphql
Niv Ben David
 
Databricks MLflow Object Relationships
amesar0
 
Action Jackson! Effective JSON processing in Spring Boot Applications
Joris Kuipers
 

Viewers also liked (7)

PDF
The MetaCPAN VM Part II (Using the VM)
Olaf Alders
 
PDF
The MetaCPAN VM for Dummies Part One (Installation)
Olaf Alders
 
PDF
No Hugging, No Learning
Olaf Alders
 
PDF
Modern Perl for Non-Perl Programmers
Dave Cross
 
PDF
Medium Perl
Dave Cross
 
PDF
TEDx Manchester: AI & The Future of Work
Volker Hirsch
 
PDF
Build Features, Not Apps
Natasha Murashev
 
The MetaCPAN VM Part II (Using the VM)
Olaf Alders
 
The MetaCPAN VM for Dummies Part One (Installation)
Olaf Alders
 
No Hugging, No Learning
Olaf Alders
 
Modern Perl for Non-Perl Programmers
Dave Cross
 
Medium Perl
Dave Cross
 
TEDx Manchester: AI & The Future of Work
Volker Hirsch
 
Build Features, Not Apps
Natasha Murashev
 
Ad

Similar to Ab(Using) the MetaCPAN API for Fun and Profit v2013 (20)

PDF
CPANci: Continuous Integration for CPAN
Mike Friedman
 
PDF
21st Century CPAN Testing: CPANci
Mike Friedman
 
PPT
How ElasticSearch lives in my DevOps life
琛琳 饶
 
PDF
Searching CPAN Offline
acme
 
PDF
Authoring CPAN modules
Alex Balhatchet
 
PDF
CPAN 模組二三事
Lin Yo-An
 
PPTX
Getting Started With Elasticsearch In .NET
Ahmed Abd Ellatif
 
PPTX
Getting started with Elasticsearch in .net
Ismaeel Enjreny
 
PDF
Elasto Mania
andrefsantos
 
PDF
Новый InterSystems: open-source, митапы, хакатоны
Timur Safin
 
PPTX
PEARC17: Designsafe: Using Elasticsearch to Share and Search Data on a Scienc...
Josue Balandrano
 
PPTX
ElasticSearch AJUG 2013
Roy Russo
 
PPTX
ACM BPM and elasticsearch AMIS25
Getting value from IoT, Integration and Data Analytics
 
PPTX
ElasticSearch - DevNexus Atlanta - 2014
Roy Russo
 
ODP
30 Minutes To CPAN
daoswald
 
PDF
HOW TO SCALE FROM ZERO TO BILLIONS!
Maziyar PANAHI
 
PPTX
Episerver and search engines
Mikko Huilaja
 
PPTX
CPAN Curation
neilbowers
 
PDF
elasticsearch
Satish Mohan
 
PDF
Elasticsearch Introduction at BigData meetup
Eric Rodriguez (Hiring in Lex)
 
CPANci: Continuous Integration for CPAN
Mike Friedman
 
21st Century CPAN Testing: CPANci
Mike Friedman
 
How ElasticSearch lives in my DevOps life
琛琳 饶
 
Searching CPAN Offline
acme
 
Authoring CPAN modules
Alex Balhatchet
 
CPAN 模組二三事
Lin Yo-An
 
Getting Started With Elasticsearch In .NET
Ahmed Abd Ellatif
 
Getting started with Elasticsearch in .net
Ismaeel Enjreny
 
Elasto Mania
andrefsantos
 
Новый InterSystems: open-source, митапы, хакатоны
Timur Safin
 
PEARC17: Designsafe: Using Elasticsearch to Share and Search Data on a Scienc...
Josue Balandrano
 
ElasticSearch AJUG 2013
Roy Russo
 
ElasticSearch - DevNexus Atlanta - 2014
Roy Russo
 
30 Minutes To CPAN
daoswald
 
HOW TO SCALE FROM ZERO TO BILLIONS!
Maziyar PANAHI
 
Episerver and search engines
Mikko Huilaja
 
CPAN Curation
neilbowers
 
elasticsearch
Satish Mohan
 
Elasticsearch Introduction at BigData meetup
Eric Rodriguez (Hiring in Lex)
 
Ad

Recently uploaded (20)

PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 

Ab(Using) the MetaCPAN API for Fun and Profit v2013