Cedric Gatay - c.gatay@code-troopers.com
or HTML to REST API guide
APIs for everyone
Cedric Gatay - c.gatay@code-troopers.com
Initial rant
• Want to build an awesome app	

• On top of third party service	

•...
Cedric Gatay - c.gatay@code-troopers.com
Basic idea
• Emulate a browser to issue requests	

• Parse resulting HTML	

• Tra...
Cedric Gatay - c.gatay@code-troopers.com
Prerequisites
• Analyze site to find endpoints	

• mobile versions are great	

• R...
Cedric Gatay - c.gatay@code-troopers.com
Tools
• Wireshark to analyze HTTP
5
Cedric Gatay - c.gatay@code-troopers.com
Tools
• Chrome Inspector to the rescue
6
Cedric Gatay - c.gatay@code-troopers.com
Tools
• Gargl : https://github.com/jodoglevy/gargl	

• Record your requests	

• N...
Cedric Gatay - c.gatay@code-troopers.com
From HTML to API
• Gargl generates boilerplate for HTTP calls	

• Refactor genera...
Cedric Gatay - c.gatay@code-troopers.com
Parse HTML
• JSoup : http://jsoup.org/	

• simple parser	

• allows to use css se...
Cedric Gatay - c.gatay@code-troopers.com
Expose API
• Define verbs	

• Use your preferred framework here	

• restx : http:/...
Cedric Gatay - c.gatay@code-troopers.com
Cache API
• Do not spam base server	

• Cache external calls as much as possible	...
Cedric Gatay - c.gatay@code-troopers.com
Questions ?
Thanks for listening
12
Upcoming SlideShare
Loading in …5
×

HTML to REST API thoughts

379 views
326 views

Published on

Talk given as a BrownBagLunch to Code-Troopers team.

General thoughts on how to enrich a basic HTML site with API when you're not the owner of the site.

Published in: Engineering, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
379
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
2
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

HTML to REST API thoughts

  1. 1. Cedric Gatay - c.gatay@code-troopers.com or HTML to REST API guide APIs for everyone
  2. 2. Cedric Gatay - c.gatay@code-troopers.com Initial rant • Want to build an awesome app • On top of third party service • No API, only HTML available 2
  3. 3. Cedric Gatay - c.gatay@code-troopers.com Basic idea • Emulate a browser to issue requests • Parse resulting HTML • Transform it into a REST API 3
  4. 4. Cedric Gatay - c.gatay@code-troopers.com Prerequisites • Analyze site to find endpoints • mobile versions are great • Reverse engineer server requests • understand parameters might be tricky 4
  5. 5. Cedric Gatay - c.gatay@code-troopers.com Tools • Wireshark to analyze HTTP 5
  6. 6. Cedric Gatay - c.gatay@code-troopers.com Tools • Chrome Inspector to the rescue 6
  7. 7. Cedric Gatay - c.gatay@code-troopers.com Tools • Gargl : https://github.com/jodoglevy/gargl • Record your requests • Name them • Parametrize them • Generate Java/JavaScript code 7
  8. 8. Cedric Gatay - c.gatay@code-troopers.com From HTML to API • Gargl generates boilerplate for HTTP calls • Refactor generated code • Need to parse HTML • Expose it through API 8
  9. 9. Cedric Gatay - c.gatay@code-troopers.com Parse HTML • JSoup : http://jsoup.org/ • simple parser • allows to use css selectors 9
  10. 10. Cedric Gatay - c.gatay@code-troopers.com Expose API • Define verbs • Use your preferred framework here • restx : http://www.restx.io • Test extensively • parsing WILL break 10
  11. 11. Cedric Gatay - c.gatay@code-troopers.com Cache API • Do not spam base server • Cache external calls as much as possible • Store constant data 11
  12. 12. Cedric Gatay - c.gatay@code-troopers.com Questions ? Thanks for listening 12

×