Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fuck It: Let's Have Fun - Building a Top Torren...

Fuck It: Let's Have Fun - Building a Top Torrents API

Like building API services? Like pirating things? Let’s do both!

In this talk, Randall Degges, Chief Hacker at Stormpath, will walk you through building and securing an API service that serves up the hottest 100 torrents on the web. You’ll learn how to scrape the world’s most popular torrent website, expose this data as a public API service using Heroku, and secure this API service using Stormpath.

This talk was given at Hack Reactor in San Francisco.

Randall Degges

October 12, 2016
Tweet

More Decks by Randall Degges

Other Decks in Programming

Transcript

  1. "use strict"; const request = require("request"); request("https://thepiratebay.org/top/207", (err, resp, body)

    => { if (err || resp.statusCode !== 200) { throw new Error("thepiratebay must be down! Arg!"); } console.log(body); });
  2. const cheerio = require("cheerio"); let $ = cheerio.load(body); $("#searchResult .detName

    a").each(function() { let torrentName = $(this).text(); console.log(torrentName); });
  3. Route: / { "categories": [ "https://toptorrents-api.herokuapp.com/otherPhysibles", "https://toptorrents-api.herokuapp.com/applicationsWindows", "https://toptorrents-api.herokuapp.com/videoMovieClips", "https://toptorrents-api.herokuapp.com/videoMoviesDVDR", "https://toptorrents-api.herokuapp.com/gamesPsx",

    "https://toptorrents-api.herokuapp.com/videoTvShows", "https://toptorrents-api.herokuapp.com/audioBooks", "https://toptorrents-api.herokuapp.com/applicationsMac", "https://toptorrents-api.herokuapp.com/audioFlac", "https://toptorrents-api.herokuapp.com/videoHandheld", "https://toptorrents-api.herokuapp.com/audioMusic", "https://toptorrents-api.herokuapp.com/gamesMac", "https://toptorrents-api.herokuapp.com/videoHdMovies" ] }
  4. Route: /<category> { "torrents": [ { "name": "The.Infiltrator.2016.720p.BRRip.x264.AAC-ETRG", "size": "952.81

    MiB", "url": "magnet:?xt=urn:btih:79fbe3251b40d18eb821be...", "seeds": "3272", "leeches": "473" }, { "name": "Star Trek Beyond 2016 1080p WEB-DL x264 AC3-JYK", "size": "3.36 GiB", "url": "magnet:?xt=urn:btih:65959583d7d7f90b98eb2464f...", "seeds": "2720", "leeches": "803" } ] }
  5. $ heroku create $ git push heroku master $ heroku

    open $ heroku addons:create heroku-postgresql Create a new app. Deploy your code to Heroku. Open your project in the browser. Create a Postgres database server.