SlideShare a Scribd company logo
API Extravaganza!
Combining Google
Analytics & ORCID APIs
ANDS Webinar, 22 Sept 2016
Liz Krznarich, Software Engineer/UI Designer, ORCID
e.krznarich@orcid.org http://orcid.org/0000-0001-6622-4910
orcid.org  support@orcid.org
API EXTRAVAGANZA
Reporting. Analytics. Metrics.
Whatever you choose to call it,
we all want to know more about
the impact of our work.
Who’s using
my
datasets?
How does my
work connect
to others’?
Who’s
visiting my
repository?!
orcid.org  support@orcid.org
API EXTRAVAGANZA
Lots of tools available!
…and many more
orcid.org  support@orcid.org
API EXTRAVAGANZA
…but to get a complete picture,
you may need to combine data
from multiple tools
APIs to the rescue!
orcid.org  support@orcid.org
API EXTRAVAGANZA
Today’s topics
Custom reporting with Google
Analytics / Drive / Sheets APIs +
ORCID APIs
orcid.org  support@orcid.org
API EXTRAVAGANZA
In this walk-through we’ll:
1. Query the Analytics API
2. Set up Google API credentials
3. Get Analytics data & upload to
Drive
4. Set up ORCID API credentials
5. Get data from ORCID & add it to
our Drive file (using the Sheets
orcid.org  support@orcid.org
API EXTRAVAGANZA
Pre-reqs: Build a website
http://orcid.github.io/or2016-ga
orcid.org  support@orcid.org
API EXTRAVAGANZA
Pre-reqs: Get a Google Analytics
account, create a new project & set up
tracking
https://analytics.google.com
orcid.org  support@orcid.org
API EXTRAVAGANZA
Google Tag Manager = easy customized
tracking
https://tagmanager.google.com
orcid.org  support@orcid.org
API EXTRAVAGANZA
1. Query the Analytics API
orcid.org  support@orcid.org
API EXTRAVAGANZA
Now for some fun with queries!
https://ga-dev-tools.appspot.com/query-explorer/
orcid.org  support@orcid.org
API EXTRAVAGANZA
Dimension & metrics & filters, oh
my!
• Dimensions: How to break down the data (city,
device)
• Metrics: What you’re counting (clicks, views, etc)
• Filters: Limit data by specific criteria
Analytics API
Reference:https://developers.google.com/analytics/devguides/repo
rting/core/v3/reference
Dimensions & Metrics Reference:
https://developers.google.com/analytics/devguides/reporting/core/
orcid.org  support@orcid.org
API EXTRAVAGANZA
2. Set up Google API credentials
orcid.org  support@orcid.org
API EXTRAVAGANZA
Create a new Google Developer project
https://console.developers.google.com/proje
ct
orcid.org  support@orcid.org
API EXTRAVAGANZA
Enable APIs (Analytics & Drive)
https://console.developers.google.com/apis/li
brary
orcid.org  support@orcid.org
API EXTRAVAGANZA
Create Service Account & download P12
key
https://console.developers.google.com/apis/crede
ntials
orcid.org  support@orcid.org
API EXTRAVAGANZA
Enable domain-wide access
https://console.developers.google.com/iam-
admin/serviceaccounts
orcid.org  support@orcid.org
API EXTRAVAGANZA
Add Service Account to
Analyticshttps://analytics.google.com/analyt
ics/web/#management/Settings > User
Management
Guess what?! If you’re using the DSpace Google Analytics module,
you’ve already done steps 4-8, and you can use the same service
account credentials for your custom applications!
orcid.org  support@orcid.org
API EXTRAVAGANZA
Create a new Drive folder & share it
with Service Account
https://drive.google.com/drive/my-drive
orcid.org  support@orcid.org
API EXTRAVAGANZA
Whew, that was tedious
Time for some coding!
orcid.org  support@orcid.org
API EXTRAVAGANZA
3. Get Analytics data & upload to
Drive
• Import Google oauth2client & apiclient
libraries
• Authenticate to Analytics, Drive & Sheets
APIs
• Get Analytics data
• Upload Analytics data to Drive
orcid.org  support@orcid.org
API EXTRAVAGANZA
Authenticate to Analytics, Drive &
Sheets APIs (Aaargh!!!)
(via Oauth2
SignedJwtAssertionCredentials)
You could read this:
https://developers.google.com/identity/protoc
ols/OAuth2ServiceAccount#authorizingreque
sts
Or just borrow someone else’s code.
orcid.org  support@orcid.org
API EXTRAVAGANZA
Get Analytics Data
https://developers.google.com/analytics/devg
uides/reporting/core/v3/coreDevguide
Finally something
simple!
Import a client library
and let ‘er rip!
orcid.org  support@orcid.org
Upload data to Drive
https://developers.google.com/drive/v3/refere
nce/files/create
API EXTRAVAGANZA
Tip: Start with an
existing Drive
folder that your
Service Account
already has
access to
orcid.org  support@orcid.org
API EXTRAVAGANZA
4. Set up ORCID API credentials
orcid.org  support@orcid.org
ORCID Public vs Member APIs
API EXTRAVAGANZA
API Type Access Features
Public Freely available (ORCID iD
required)
• Get authenticated ORCID iDs
from users
Search/retrieve public data
Member Available to ORCID member
organizations (sandbox test
environment freely available)
All Public API features, plus:
• Search/retrieve "limited-access"
data
• Add to/update ORCID records
• Register webhooks
Premium members only
orcid.org  support@orcid.org
Log in (or register for an ORCID iD)
https://orcid.org/signin
API EXTRAVAGANZA
orcid.org  support@orcid.org
Click Developer Tools > Register…
https://orcid.org/developer-tools
API EXTRAVAGANZA
orcid.org  support@orcid.org
Enter your client app info
API EXTRAVAGANZA
orcid.org  support@orcid.org
Get your client ID & client secret
API EXTRAVAGANZA
orcid.org  support@orcid.org
API EXTRAVAGANZA
5. Get data from ORCID & add it
to our Drive file (using Sheets
API)
orcid.org  support@orcid.org
Get data from ORCID
In the example code, we use HTTP requests (via
PyCurl) to get an access token and loop through a
list of DOIs, checking to see which are linked to
ORCID iDs
API EXTRAVAGANZA
orcid.org  support@orcid.org
First, we need an access token
Valid for 20yrs – can be used for multiple searches
API EXTRAVAGANZA
You’ll need your client
ID & secret here!
orcid.org  support@orcid.org
Then, use the token to send queries
Solr query syntax - see
https://members.orcid.org/api/tutorial-searching-data-
using-api
API EXTRAVAGANZA
curl -H "Content-Type: application/orcid+xml" -H
"Authorization: Bearer 5d0c7545-f59f-44c5-bcde-
f83438beb3ef"
"https://pub.sandbox.orcid.org/v1.2/search/orcid-
bio/?defType=edismax&q=digital-object-
ids:%2210.1087/20120404%22" That token you generated
goes in here!
orcid.org  support@orcid.org
Edit the new sheet to add your data
https://developers.google.com/sheets
http://gspread.readthedocs.io
• Python gspread library makes life easy
• Sheets API v3 w/out a 3rd party library =
frightening; v4 looks friendlier
API EXTRAVAGANZA
orcid.org  support@orcid.org
Edit the new sheet to add your data
1. Get the Drive file id
2. Open the file
3. Figure out which cells
to edit & send the
update request
API EXTRAVAGANZA
orcid.org  support@orcid.org
Now, take that data and do cool stuff!
(like charts with Google Charts API)
https://developers.google.com/chart
API EXTRAVAGANZA
orcid.org  support@orcid.org
Hot Tips!
• Tokens expire in 1hr (no refresh
token…just get a new one)
• Analytics API is twitchy – expect sporadic
errors when running lots of queries
• Sheets API is slooooow – try to combine
as many actions as possible into 1 request
API EXTRAVAGANZA
orcid.org  support@orcid.org
Get the code
Demo site
http://orcid.github.io/analytics-demo
Code
https://github.com/lizkrznarich/orcid-
demo/analytics
orcid.org  support@orcid.org
THANK YOU!
Questions? e.krznarich@orcid.org
https://github.com/lizkrznarich
http://orcid.org/0000-0001-6622-4910

More Related Content

Similar to Webinar: API Extravaganza! Combining Google Analytics and ORCID API

Holt "Working with Scholarly APIs: A NISO Training Series, Session Two: ORCID"
Holt "Working with Scholarly APIs: A NISO Training Series, Session Two: ORCID"Holt "Working with Scholarly APIs: A NISO Training Series, Session Two: ORCID"
Holt "Working with Scholarly APIs: A NISO Training Series, Session Two: ORCID"
National Information Standards Organization (NISO)
 
ORCID Tech Intro - California Digital Libraries
ORCID Tech Intro - California Digital LibrariesORCID Tech Intro - California Digital Libraries
ORCID Tech Intro - California Digital Libraries
ORCID, Inc
 
WSO2 Workshop Sydney 2016 - APIs
WSO2 Workshop Sydney 2016 - APIsWSO2 Workshop Sydney 2016 - APIs
WSO2 Workshop Sydney 2016 - APIs
Dassana Wijesekara
 
APIエコノミー時代の認証・認可
APIエコノミー時代の認証・認可APIエコノミー時代の認証・認可
APIエコノミー時代の認証・認可
Tatsuo Kudo
 
TechNet Conference 2013 Berlin-Wie Sie Office 365 mit Windows Azure steuern b...
TechNet Conference 2013 Berlin-Wie Sie Office 365 mit Windows Azure steuern b...TechNet Conference 2013 Berlin-Wie Sie Office 365 mit Windows Azure steuern b...
TechNet Conference 2013 Berlin-Wie Sie Office 365 mit Windows Azure steuern b...
atwork
 
Google APIs
Google APIsGoogle APIs
Logic apps and PowerApps - Integrate across your APIs
Logic apps and PowerApps - Integrate across your APIsLogic apps and PowerApps - Integrate across your APIs
Logic apps and PowerApps - Integrate across your APIs
Sriram Hariharan
 
ORCID API Workshop OR2015
ORCID API Workshop OR2015ORCID API Workshop OR2015
ORCID API Workshop OR2015
ORCID, Inc
 
Developing Apps with Azure AD
Developing Apps with Azure ADDeveloping Apps with Azure AD
Developing Apps with Azure AD
SharePointRadi
 
Automate your Oracle Cloud Infrastructure operation
Automate your Oracle Cloud Infrastructure operationAutomate your Oracle Cloud Infrastructure operation
Automate your Oracle Cloud Infrastructure operation
Nelson Calero
 
Exploring the Google Analytics API
Exploring the Google Analytics APIExploring the Google Analytics API
Exploring the Google Analytics API
Vanessa Sabino
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricks
NetpeakBG
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricks
Netpeak
 
API Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIsAPI Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIs
Apigee | Google Cloud
 
Smart Distancing using Social Authentication
Smart Distancing using Social AuthenticationSmart Distancing using Social Authentication
Smart Distancing using Social Authentication
Richard Dalvi
 
Developing Apps: Exposing Your Data Through Araport
Developing Apps: Exposing Your Data Through AraportDeveloping Apps: Exposing Your Data Through Araport
Developing Apps: Exposing Your Data Through Araport
Matthew Vaughn
 
ICAR 2015 Workshop - Matt Vaughn
ICAR 2015 Workshop - Matt VaughnICAR 2015 Workshop - Matt Vaughn
ICAR 2015 Workshop - Matt Vaughn
Araport
 
ORCID Technical Intro - English
ORCID Technical Intro - EnglishORCID Technical Intro - English
ORCID Technical Intro - English
ORCID, Inc
 
Windays14 - How to (remote) control Office 365 with Azure
Windays14 - How to (remote) control Office 365 with AzureWindays14 - How to (remote) control Office 365 with Azure
Windays14 - How to (remote) control Office 365 with Azure
atwork
 
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)
Ido Green
 

Similar to Webinar: API Extravaganza! Combining Google Analytics and ORCID API (20)

Holt "Working with Scholarly APIs: A NISO Training Series, Session Two: ORCID"
Holt "Working with Scholarly APIs: A NISO Training Series, Session Two: ORCID"Holt "Working with Scholarly APIs: A NISO Training Series, Session Two: ORCID"
Holt "Working with Scholarly APIs: A NISO Training Series, Session Two: ORCID"
 
ORCID Tech Intro - California Digital Libraries
ORCID Tech Intro - California Digital LibrariesORCID Tech Intro - California Digital Libraries
ORCID Tech Intro - California Digital Libraries
 
WSO2 Workshop Sydney 2016 - APIs
WSO2 Workshop Sydney 2016 - APIsWSO2 Workshop Sydney 2016 - APIs
WSO2 Workshop Sydney 2016 - APIs
 
APIエコノミー時代の認証・認可
APIエコノミー時代の認証・認可APIエコノミー時代の認証・認可
APIエコノミー時代の認証・認可
 
TechNet Conference 2013 Berlin-Wie Sie Office 365 mit Windows Azure steuern b...
TechNet Conference 2013 Berlin-Wie Sie Office 365 mit Windows Azure steuern b...TechNet Conference 2013 Berlin-Wie Sie Office 365 mit Windows Azure steuern b...
TechNet Conference 2013 Berlin-Wie Sie Office 365 mit Windows Azure steuern b...
 
Google APIs
Google APIsGoogle APIs
Google APIs
 
Logic apps and PowerApps - Integrate across your APIs
Logic apps and PowerApps - Integrate across your APIsLogic apps and PowerApps - Integrate across your APIs
Logic apps and PowerApps - Integrate across your APIs
 
ORCID API Workshop OR2015
ORCID API Workshop OR2015ORCID API Workshop OR2015
ORCID API Workshop OR2015
 
Developing Apps with Azure AD
Developing Apps with Azure ADDeveloping Apps with Azure AD
Developing Apps with Azure AD
 
Automate your Oracle Cloud Infrastructure operation
Automate your Oracle Cloud Infrastructure operationAutomate your Oracle Cloud Infrastructure operation
Automate your Oracle Cloud Infrastructure operation
 
Exploring the Google Analytics API
Exploring the Google Analytics APIExploring the Google Analytics API
Exploring the Google Analytics API
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricks
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricks
 
API Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIsAPI Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIs
 
Smart Distancing using Social Authentication
Smart Distancing using Social AuthenticationSmart Distancing using Social Authentication
Smart Distancing using Social Authentication
 
Developing Apps: Exposing Your Data Through Araport
Developing Apps: Exposing Your Data Through AraportDeveloping Apps: Exposing Your Data Through Araport
Developing Apps: Exposing Your Data Through Araport
 
ICAR 2015 Workshop - Matt Vaughn
ICAR 2015 Workshop - Matt VaughnICAR 2015 Workshop - Matt Vaughn
ICAR 2015 Workshop - Matt Vaughn
 
ORCID Technical Intro - English
ORCID Technical Intro - EnglishORCID Technical Intro - English
ORCID Technical Intro - English
 
Windays14 - How to (remote) control Office 365 with Azure
Windays14 - How to (remote) control Office 365 with AzureWindays14 - How to (remote) control Office 365 with Azure
Windays14 - How to (remote) control Office 365 with Azure
 
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)
Entrepreneurship Tips With HTML5 & App Engine Startup Weekend (June 2012)
 

More from ARDC

Introduction to ADA
Introduction to ADAIntroduction to ADA
Introduction to ADA
ARDC
 
Architecture and Standards
Architecture and StandardsArchitecture and Standards
Architecture and Standards
ARDC
 
Data Sharing and Release Legislation
Data Sharing and Release Legislation   Data Sharing and Release Legislation
Data Sharing and Release Legislation
ARDC
 
Australian Dementia Network (ADNet)
Australian Dementia Network (ADNet)Australian Dementia Network (ADNet)
Australian Dementia Network (ADNet)
ARDC
 
Investigator-initiated clinical trials: a community perspective
Investigator-initiated clinical trials: a community perspectiveInvestigator-initiated clinical trials: a community perspective
Investigator-initiated clinical trials: a community perspective
ARDC
 
NCRIS and the health domain
NCRIS and the health domainNCRIS and the health domain
NCRIS and the health domain
ARDC
 
International perspective for sharing publicly funded medical research data
International perspective for sharing publicly funded medical research dataInternational perspective for sharing publicly funded medical research data
International perspective for sharing publicly funded medical research data
ARDC
 
Clinical trials data sharing
Clinical trials data sharingClinical trials data sharing
Clinical trials data sharing
ARDC
 
Clinical trials and cohort studies
Clinical trials and cohort studiesClinical trials and cohort studies
Clinical trials and cohort studies
ARDC
 
Introduction to vision and scope
Introduction to vision and scopeIntroduction to vision and scope
Introduction to vision and scope
ARDC
 
FAIR for the future: embracing all things data
FAIR for the future: embracing all things dataFAIR for the future: embracing all things data
FAIR for the future: embracing all things data
ARDC
 
ARDC 2018 state engagements - Nov-Dec 2018 - Slides - Ian Duncan
ARDC 2018 state engagements - Nov-Dec 2018 - Slides - Ian DuncanARDC 2018 state engagements - Nov-Dec 2018 - Slides - Ian Duncan
ARDC 2018 state engagements - Nov-Dec 2018 - Slides - Ian Duncan
ARDC
 
Skilling-up-in-research-data-management-20181128
Skilling-up-in-research-data-management-20181128Skilling-up-in-research-data-management-20181128
Skilling-up-in-research-data-management-20181128
ARDC
 
Research data management and sharing of medical data
Research data management and sharing of medical dataResearch data management and sharing of medical data
Research data management and sharing of medical data
ARDC
 
Findable, Accessible, Interoperable and Reusable (FAIR) data
Findable, Accessible, Interoperable and Reusable (FAIR) dataFindable, Accessible, Interoperable and Reusable (FAIR) data
Findable, Accessible, Interoperable and Reusable (FAIR) data
ARDC
 
Applying FAIR principles to linked datasets: Opportunities and Challenges
Applying FAIR principles to linked datasets: Opportunities and ChallengesApplying FAIR principles to linked datasets: Opportunities and Challenges
Applying FAIR principles to linked datasets: Opportunities and Challenges
ARDC
 
How to make your data count webinar, 26 Nov 2018
How to make your data count webinar, 26 Nov 2018How to make your data count webinar, 26 Nov 2018
How to make your data count webinar, 26 Nov 2018
ARDC
 
Ready, Set, Go! Join the Top 10 FAIR Data Things Global Sprint
Ready, Set, Go! Join the Top 10 FAIR Data Things Global SprintReady, Set, Go! Join the Top 10 FAIR Data Things Global Sprint
Ready, Set, Go! Join the Top 10 FAIR Data Things Global Sprint
ARDC
 
How FAIR is your data? Copyright, licensing and reuse of data
How FAIR is your data? Copyright, licensing and reuse of dataHow FAIR is your data? Copyright, licensing and reuse of data
How FAIR is your data? Copyright, licensing and reuse of data
ARDC
 
Peter neish DMPs BoF eResearch 2018
Peter neish DMPs BoF eResearch 2018Peter neish DMPs BoF eResearch 2018
Peter neish DMPs BoF eResearch 2018
ARDC
 

More from ARDC (20)

Introduction to ADA
Introduction to ADAIntroduction to ADA
Introduction to ADA
 
Architecture and Standards
Architecture and StandardsArchitecture and Standards
Architecture and Standards
 
Data Sharing and Release Legislation
Data Sharing and Release Legislation   Data Sharing and Release Legislation
Data Sharing and Release Legislation
 
Australian Dementia Network (ADNet)
Australian Dementia Network (ADNet)Australian Dementia Network (ADNet)
Australian Dementia Network (ADNet)
 
Investigator-initiated clinical trials: a community perspective
Investigator-initiated clinical trials: a community perspectiveInvestigator-initiated clinical trials: a community perspective
Investigator-initiated clinical trials: a community perspective
 
NCRIS and the health domain
NCRIS and the health domainNCRIS and the health domain
NCRIS and the health domain
 
International perspective for sharing publicly funded medical research data
International perspective for sharing publicly funded medical research dataInternational perspective for sharing publicly funded medical research data
International perspective for sharing publicly funded medical research data
 
Clinical trials data sharing
Clinical trials data sharingClinical trials data sharing
Clinical trials data sharing
 
Clinical trials and cohort studies
Clinical trials and cohort studiesClinical trials and cohort studies
Clinical trials and cohort studies
 
Introduction to vision and scope
Introduction to vision and scopeIntroduction to vision and scope
Introduction to vision and scope
 
FAIR for the future: embracing all things data
FAIR for the future: embracing all things dataFAIR for the future: embracing all things data
FAIR for the future: embracing all things data
 
ARDC 2018 state engagements - Nov-Dec 2018 - Slides - Ian Duncan
ARDC 2018 state engagements - Nov-Dec 2018 - Slides - Ian DuncanARDC 2018 state engagements - Nov-Dec 2018 - Slides - Ian Duncan
ARDC 2018 state engagements - Nov-Dec 2018 - Slides - Ian Duncan
 
Skilling-up-in-research-data-management-20181128
Skilling-up-in-research-data-management-20181128Skilling-up-in-research-data-management-20181128
Skilling-up-in-research-data-management-20181128
 
Research data management and sharing of medical data
Research data management and sharing of medical dataResearch data management and sharing of medical data
Research data management and sharing of medical data
 
Findable, Accessible, Interoperable and Reusable (FAIR) data
Findable, Accessible, Interoperable and Reusable (FAIR) dataFindable, Accessible, Interoperable and Reusable (FAIR) data
Findable, Accessible, Interoperable and Reusable (FAIR) data
 
Applying FAIR principles to linked datasets: Opportunities and Challenges
Applying FAIR principles to linked datasets: Opportunities and ChallengesApplying FAIR principles to linked datasets: Opportunities and Challenges
Applying FAIR principles to linked datasets: Opportunities and Challenges
 
How to make your data count webinar, 26 Nov 2018
How to make your data count webinar, 26 Nov 2018How to make your data count webinar, 26 Nov 2018
How to make your data count webinar, 26 Nov 2018
 
Ready, Set, Go! Join the Top 10 FAIR Data Things Global Sprint
Ready, Set, Go! Join the Top 10 FAIR Data Things Global SprintReady, Set, Go! Join the Top 10 FAIR Data Things Global Sprint
Ready, Set, Go! Join the Top 10 FAIR Data Things Global Sprint
 
How FAIR is your data? Copyright, licensing and reuse of data
How FAIR is your data? Copyright, licensing and reuse of dataHow FAIR is your data? Copyright, licensing and reuse of data
How FAIR is your data? Copyright, licensing and reuse of data
 
Peter neish DMPs BoF eResearch 2018
Peter neish DMPs BoF eResearch 2018Peter neish DMPs BoF eResearch 2018
Peter neish DMPs BoF eResearch 2018
 

Recently uploaded

South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
ShivajiThube2
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 

Recently uploaded (20)

South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 

Webinar: API Extravaganza! Combining Google Analytics and ORCID API

  • 1. API Extravaganza! Combining Google Analytics & ORCID APIs ANDS Webinar, 22 Sept 2016 Liz Krznarich, Software Engineer/UI Designer, ORCID e.krznarich@orcid.org http://orcid.org/0000-0001-6622-4910
  • 2. orcid.org  support@orcid.org API EXTRAVAGANZA Reporting. Analytics. Metrics. Whatever you choose to call it, we all want to know more about the impact of our work. Who’s using my datasets? How does my work connect to others’? Who’s visiting my repository?!
  • 3. orcid.org  support@orcid.org API EXTRAVAGANZA Lots of tools available! …and many more
  • 4. orcid.org  support@orcid.org API EXTRAVAGANZA …but to get a complete picture, you may need to combine data from multiple tools APIs to the rescue!
  • 5. orcid.org  support@orcid.org API EXTRAVAGANZA Today’s topics Custom reporting with Google Analytics / Drive / Sheets APIs + ORCID APIs
  • 6. orcid.org  support@orcid.org API EXTRAVAGANZA In this walk-through we’ll: 1. Query the Analytics API 2. Set up Google API credentials 3. Get Analytics data & upload to Drive 4. Set up ORCID API credentials 5. Get data from ORCID & add it to our Drive file (using the Sheets
  • 7. orcid.org  support@orcid.org API EXTRAVAGANZA Pre-reqs: Build a website http://orcid.github.io/or2016-ga
  • 8. orcid.org  support@orcid.org API EXTRAVAGANZA Pre-reqs: Get a Google Analytics account, create a new project & set up tracking https://analytics.google.com
  • 9. orcid.org  support@orcid.org API EXTRAVAGANZA Google Tag Manager = easy customized tracking https://tagmanager.google.com
  • 10. orcid.org  support@orcid.org API EXTRAVAGANZA 1. Query the Analytics API
  • 11. orcid.org  support@orcid.org API EXTRAVAGANZA Now for some fun with queries! https://ga-dev-tools.appspot.com/query-explorer/
  • 12. orcid.org  support@orcid.org API EXTRAVAGANZA Dimension & metrics & filters, oh my! • Dimensions: How to break down the data (city, device) • Metrics: What you’re counting (clicks, views, etc) • Filters: Limit data by specific criteria Analytics API Reference:https://developers.google.com/analytics/devguides/repo rting/core/v3/reference Dimensions & Metrics Reference: https://developers.google.com/analytics/devguides/reporting/core/
  • 13. orcid.org  support@orcid.org API EXTRAVAGANZA 2. Set up Google API credentials
  • 14. orcid.org  support@orcid.org API EXTRAVAGANZA Create a new Google Developer project https://console.developers.google.com/proje ct
  • 15. orcid.org  support@orcid.org API EXTRAVAGANZA Enable APIs (Analytics & Drive) https://console.developers.google.com/apis/li brary
  • 16. orcid.org  support@orcid.org API EXTRAVAGANZA Create Service Account & download P12 key https://console.developers.google.com/apis/crede ntials
  • 17. orcid.org  support@orcid.org API EXTRAVAGANZA Enable domain-wide access https://console.developers.google.com/iam- admin/serviceaccounts
  • 18. orcid.org  support@orcid.org API EXTRAVAGANZA Add Service Account to Analyticshttps://analytics.google.com/analyt ics/web/#management/Settings > User Management Guess what?! If you’re using the DSpace Google Analytics module, you’ve already done steps 4-8, and you can use the same service account credentials for your custom applications!
  • 19. orcid.org  support@orcid.org API EXTRAVAGANZA Create a new Drive folder & share it with Service Account https://drive.google.com/drive/my-drive
  • 20. orcid.org  support@orcid.org API EXTRAVAGANZA Whew, that was tedious Time for some coding!
  • 21. orcid.org  support@orcid.org API EXTRAVAGANZA 3. Get Analytics data & upload to Drive • Import Google oauth2client & apiclient libraries • Authenticate to Analytics, Drive & Sheets APIs • Get Analytics data • Upload Analytics data to Drive
  • 22. orcid.org  support@orcid.org API EXTRAVAGANZA Authenticate to Analytics, Drive & Sheets APIs (Aaargh!!!) (via Oauth2 SignedJwtAssertionCredentials) You could read this: https://developers.google.com/identity/protoc ols/OAuth2ServiceAccount#authorizingreque sts Or just borrow someone else’s code.
  • 23. orcid.org  support@orcid.org API EXTRAVAGANZA Get Analytics Data https://developers.google.com/analytics/devg uides/reporting/core/v3/coreDevguide Finally something simple! Import a client library and let ‘er rip!
  • 24. orcid.org  support@orcid.org Upload data to Drive https://developers.google.com/drive/v3/refere nce/files/create API EXTRAVAGANZA Tip: Start with an existing Drive folder that your Service Account already has access to
  • 25. orcid.org  support@orcid.org API EXTRAVAGANZA 4. Set up ORCID API credentials
  • 26. orcid.org  support@orcid.org ORCID Public vs Member APIs API EXTRAVAGANZA API Type Access Features Public Freely available (ORCID iD required) • Get authenticated ORCID iDs from users Search/retrieve public data Member Available to ORCID member organizations (sandbox test environment freely available) All Public API features, plus: • Search/retrieve "limited-access" data • Add to/update ORCID records • Register webhooks Premium members only
  • 27. orcid.org  support@orcid.org Log in (or register for an ORCID iD) https://orcid.org/signin API EXTRAVAGANZA
  • 28. orcid.org  support@orcid.org Click Developer Tools > Register… https://orcid.org/developer-tools API EXTRAVAGANZA
  • 29. orcid.org  support@orcid.org Enter your client app info API EXTRAVAGANZA
  • 30. orcid.org  support@orcid.org Get your client ID & client secret API EXTRAVAGANZA
  • 31. orcid.org  support@orcid.org API EXTRAVAGANZA 5. Get data from ORCID & add it to our Drive file (using Sheets API)
  • 32. orcid.org  support@orcid.org Get data from ORCID In the example code, we use HTTP requests (via PyCurl) to get an access token and loop through a list of DOIs, checking to see which are linked to ORCID iDs API EXTRAVAGANZA
  • 33. orcid.org  support@orcid.org First, we need an access token Valid for 20yrs – can be used for multiple searches API EXTRAVAGANZA You’ll need your client ID & secret here!
  • 34. orcid.org  support@orcid.org Then, use the token to send queries Solr query syntax - see https://members.orcid.org/api/tutorial-searching-data- using-api API EXTRAVAGANZA curl -H "Content-Type: application/orcid+xml" -H "Authorization: Bearer 5d0c7545-f59f-44c5-bcde- f83438beb3ef" "https://pub.sandbox.orcid.org/v1.2/search/orcid- bio/?defType=edismax&q=digital-object- ids:%2210.1087/20120404%22" That token you generated goes in here!
  • 35. orcid.org  support@orcid.org Edit the new sheet to add your data https://developers.google.com/sheets http://gspread.readthedocs.io • Python gspread library makes life easy • Sheets API v3 w/out a 3rd party library = frightening; v4 looks friendlier API EXTRAVAGANZA
  • 36. orcid.org  support@orcid.org Edit the new sheet to add your data 1. Get the Drive file id 2. Open the file 3. Figure out which cells to edit & send the update request API EXTRAVAGANZA
  • 37. orcid.org  support@orcid.org Now, take that data and do cool stuff! (like charts with Google Charts API) https://developers.google.com/chart API EXTRAVAGANZA
  • 38. orcid.org  support@orcid.org Hot Tips! • Tokens expire in 1hr (no refresh token…just get a new one) • Analytics API is twitchy – expect sporadic errors when running lots of queries • Sheets API is slooooow – try to combine as many actions as possible into 1 request API EXTRAVAGANZA
  • 39. orcid.org  support@orcid.org Get the code Demo site http://orcid.github.io/analytics-demo Code https://github.com/lizkrznarich/orcid- demo/analytics
  • 40. orcid.org  support@orcid.org THANK YOU! Questions? e.krznarich@orcid.org https://github.com/lizkrznarich http://orcid.org/0000-0001-6622-4910

Editor's Notes

  1. https://ga-dev-tools.appspot.com/query-explorer/?start-date=2016-06-04&end-date=2016-06-30&metrics=ga%3AtotalEvents&dimensions=ga%3AeventLabel&filters=ga%3AeventAction%3D%3Ddownload