SlideShare a Scribd company logo
1 of 40
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

ORCID Tech Intro - California Digital Libraries
ORCID Tech Intro - California Digital LibrariesORCID Tech Intro - California Digital Libraries
ORCID Tech Intro - California Digital LibrariesORCID, Inc
 
WSO2 Workshop Sydney 2016 - APIs
WSO2 Workshop Sydney 2016 - APIsWSO2 Workshop Sydney 2016 - APIs
WSO2 Workshop Sydney 2016 - APIsDassana 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
 
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 APIsSriram Hariharan
 
ORCID API Workshop OR2015
ORCID API Workshop OR2015ORCID API Workshop OR2015
ORCID API Workshop OR2015ORCID, Inc
 
Developing Apps with Azure AD
Developing Apps with Azure ADDeveloping Apps with Azure AD
Developing Apps with Azure ADSharePointRadi
 
Automate your Oracle Cloud Infrastructure operation
Automate your Oracle Cloud Infrastructure operationAutomate your Oracle Cloud Infrastructure operation
Automate your Oracle Cloud Infrastructure operationNelson Calero
 
Exploring the Google Analytics API
Exploring the Google Analytics APIExploring the Google Analytics API
Exploring the Google Analytics APIVanessa Sabino
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricksNetpeakBG
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricksNetpeak
 
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 APIsApigee | Google Cloud
 
Smart Distancing using Social Authentication
Smart Distancing using Social AuthenticationSmart Distancing using Social Authentication
Smart Distancing using Social AuthenticationRichard 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 AraportMatthew Vaughn
 
ICAR 2015 Workshop - Matt Vaughn
ICAR 2015 Workshop - Matt VaughnICAR 2015 Workshop - Matt Vaughn
ICAR 2015 Workshop - Matt VaughnAraport
 
ORCID Technical Intro - English
ORCID Technical Intro - EnglishORCID Technical Intro - English
ORCID Technical Intro - EnglishORCID, 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 Azureatwork
 
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 ADAARDC
 
Architecture and Standards
Architecture and StandardsArchitecture and Standards
Architecture and StandardsARDC
 
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 perspectiveARDC
 
NCRIS and the health domain
NCRIS and the health domainNCRIS and the health domain
NCRIS and the health domainARDC
 
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 dataARDC
 
Clinical trials data sharing
Clinical trials data sharingClinical trials data sharing
Clinical trials data sharingARDC
 
Clinical trials and cohort studies
Clinical trials and cohort studiesClinical trials and cohort studies
Clinical trials and cohort studiesARDC
 
Introduction to vision and scope
Introduction to vision and scopeIntroduction to vision and scope
Introduction to vision and scopeARDC
 
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 dataARDC
 
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 DuncanARDC
 
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-20181128ARDC
 
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 dataARDC
 
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) dataARDC
 
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 ChallengesARDC
 
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 2018ARDC
 
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 SprintARDC
 
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 dataARDC
 
Peter neish DMPs BoF eResearch 2018
Peter neish DMPs BoF eResearch 2018Peter neish DMPs BoF eResearch 2018
Peter neish DMPs BoF eResearch 2018ARDC
 

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

ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 

Recently uploaded (20)

ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 

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