Stata tweets and other API libraries: a practical guide William Matsuoka Stata Conference Chicago, IL - July 28, 2016.

Slides:



Advertisements
Similar presentations
Website Content Filtering Featuring the Restricted to Adults (RTA) Label copyright 2008 rtalabel.org.
Advertisements

Overview of Twitter API Nathan Liu. Twitter API Essentials Twitter API is a Representational State Transfer(REST) style web services exposed over HTTP(S).
Using Evernote and Google Docs in your web or mobile application (and potentially Dropbox and Skydrive) By Peter Messenger Senior Developer – Triple Point.
AHRT: The Automated Human Resources Tool BY Roi Ceren Muthukumaran Chandrasekaran.
DEVELOPER DAY BEFORE WE START, PLEASE VISIT AND SIGN UPWWW.PAYNOW.CO.ZW.
XP Browser and Basics1. XP Browser and Basics2 Learn about Web browser software and Web pages The Web is a collection of files that reside.
CIS101 Introduction to Computing Week 05. Agenda Your questions Exam next week - Excel Introduction to the Internet & HTML Online HTML Resources Using.
Browser and Basics Tutorial 1. Learn about Web browser software and Web pages The Web is a collection of files that reside on computers, called.
W3af LUCA ALEXANDRA ADELA – MISS 1. w3af  Web Application Attack and Audit Framework  Secures web applications by finding and exploiting web application.
Selecting and Combining Tools F. Duveau 02/03/12 F. Duveau 02/03/12 Chapter 14.
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
COMP3121 E-Commerce Technologies Richard Henson University of Worcester November 2011.
Mashup Chris Harwood ( ). Original idea My first idea was to graph financial stock data onto a html5 canvas. This way I could plot the data and.
DEMO - 8/14/2007. R2 Feature List ReceiveDocumentBatch Web Service SendPESCAcknowledgment Web Service Validate Acknowledgment Upload Acknowledgment Transcript.
Update By: Brian Klug, Li Fan Presentation Overview: API we plan to use (Syntax and commands) Obtainable Data Types (Location, Text, Time, User, Reply)
MAKANI ANDROID APPLICATION Prepared by: Asma’ Hamayel Alaa Shaheen.
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
Copyright © 2012 UNICOM Systems, Inc. Confidential Information z/Ware Product Overview illustro Systems International A Division of UNICOM Global.
FriendFinder Location-aware social networking on mobile phones.
Web2.0 Secure Development Practice Bruce Xia
FriendFinder Location-aware social networking on mobile phones.
ICM – API Server & Forms Gary Ratcliffe.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
CAS Proxying and Web Services The somewhat “easy way” Presented By: Joseph Mitola Programmer/Analyst Office Of The Registrar.
Web Services Essentials. What is a web service? web service: software functionality that can be invoked through the internet using common protocols like.
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
Methods of Tracking Position i Pod Touch – Wi-Fi used to find location by detecting known hotspots. iPhone – Cellular triangulation uses the mobile communication.
SFDC Integration Basics Gerry Winning. SFDC Starting point to hammer out your own framework Ovid back office is fully integrated with SFDC (before REST.
Lesson 11: Web Services and API's
ICE Integrated Cloud Environment Cloud Scanning and Mobile Printing
Secure Cloud Based Listening Devices
Tonga Institute of Higher Education IT 141: Information Systems
Data Virtualization Tutorial… SSL with CIS Web Data Sources
Wiki Wiki – A collection of web pages that can be edited by a group.
How to get started with RefWorks
Introduction to gathering and analyzing data via APIs Gus Cavanaugh
Imaging and Design for Online Environment
Business Directory REST API
WWU Hackathon May 6 & 7.
GovDelivery® & Digital Subscription Management:
Node.js Express Web Applications
z/Ware 2.0 Technical Overview
Cosc 5/4730 REST services.
Data Virtualization Tutorial… OAuth Example using Google Sheets
Node.js Express Web Services
Browsing and Searching the Web
ITM 352 Cookies.
Lesson 11: Web Services & API's
All about social networking
Web software.
How to get started with RefWorks
PHP / MySQL Introduction
The Internet of Things (IoT)
Testing REST IPA using POSTMAN
Topic 5: Communication and the Internet
Chapter 27 WWW and HTTP.
Tonga Institute of Higher Education IT 141: Information Systems
HINARI – Accessing Articles: Problems and Solutions (Appendix 1)
Tonga Institute of Higher Education IT 141: Information Systems
Lesson 11: Web Services and API's
Inside a PMI Online Course
ClicktoHuddle Training
OpenURL: Pointing a Loaded Resolver
Sending a text message (and more)
Consuming Web Services with 2E Generated Objects
Cloud Migration Training
CUSTOMER RETENTION RATE
Cross Site Request Forgery (CSRF)
Partner Portal Training document
Intro to Web Services Consuming the Web.
Presentation transcript:

Stata tweets and other API libraries: a practical guide William Matsuoka Stata Conference Chicago, IL - July 28, 2016

Background – Obsessive Automation Hot topic on Statalist for many years now APIs can be very useful for automating your workflow Request In & Data Out But make sure to read the documentation

Output Formats: JSON, XML, and HTML Stata is an excellent parser (Mata is even nicer but takes time) Output commonly in JSON or XML formats. Sometimes CSV or even straight HTML. JSON commonly handled with insheetjson jsonio perhaps

wunderexamp San_Diego_International-Lindbergh.json

Parsing Made Easy

Elements of Common Web APIs API “Key” Can be pricy Variables Additional barriers to data Percent Encoding Base64 Encoding Hash Algorithms

Simple GET - SMMRY SMMRY is an API to summarize documents Easy to send requests, up to 25 a day for free URL=http%3A%2F%2Fsmmry.com%2Fapi

TL;DR SMMRY API SMMRY is accessible via an API. Developers are able to implement SMMRY into applications that may require a summary of a webpage or block of text. Get a free partner account here and an API key will be generated automatically. Modes There are two active modes of the API, Limited and Full: Limited: A limit of 25 free API requests can be made daily, and each request must be at least 10 seconds apart.

Zipped Files - CAISO California Independent System Operator Electricity price and demand data from API returned in zip format GET request built off of base string unzipfile is key here

Instagram – Signing Up

Authentication: Instagram ID&redirect_uri=http%3A%2F%2Fwww.wmatsuoka.com&response_type=token&scope=public_content

Instagram “Likes” Looks like we need more HTTP methods

REST Easy with cURL Free and fairly easy to download (may already be installed) Shell (!)

REST Easy with cURL

Census TIGER (mqgeocode, geocode3) Batch geocode many addresses at once For San Diego County - 1 Million Households in 4 Hours

Callback URL - Fitbit Some APIs require “Callback” URLs for authentication

Finally we can make the request

Instagram: now with more cURL! Three Steps: Direct Callback Code Access Token Quite a bit of work to like a photo

Twitter – under lock and key Get statuses “Tweets” Favorite statuses “Likes” Send direct messages to yourself at the completion of do files! “… preceding a message with “D ” or “M ” and following it with a screen name can create a direct message to that user if the relationship allows for it.” Emoji are allowed and are percent encoded: %F0%9F%93%88 (Chart) See Joe Canner’s presentation on the topic or wmatsuoka.com for more details

Truth be told, APIs can be rather limiting Odd return formats Sometimes required to store secure information such as passwords, tokens, and API keys Rate Limits Time between requests Maximum requests per hour Contract/Account Management/Costs

cURL to Circumvent APIs (Form Control) Using forms with cURL: requires a bit of detective work Change “post” methods to “get” to see the variables sent For those with intranet sites: --ntlm -u :

API Rate Limits (Scraping) Sometimes best (not for the server) to scrape the information Tread Lightly! Could be violation of terms of service Stata enables scraping fairly easily cURL allows you to login to websites and copy protected pages to be parsed directly from Stata and allows for stored cookie settings

Cookies Where logininfo.txt contains:

In SMMRY Useful Stata commands: shell (!), winexec, filefilter, regexm, split cURL allows Stata to easily obtain data from websites Send more HTTP Requests Access restricted sites Store cookies Stata is a really good ad hoc parser There are so many more APIs out there APIs are an effective way to get the data you want They can even improve Stata graphics…