FastPokeMap API scraping - Spawn notifications by Email

Skip to the next section if you want to get straight to the good stuff. This is just backstory.

Anyone who knows me, knows that I am massively into Pokemon GO. I was into Pokemon as a kid during the late 90s when the gameboy games and trading cards were huge. If you're reading this and don't understand the new mobile game, you might want to read up on it otherwise the below might not make too much sense.

Back when Pokemon GO came out, there was a cool feature that let you "track" pokemon. A portion of the UI would show you how far away you were from the nearby pokemon, letting you track the rare pokemon that you don't have yet. This was later removed before I could get the chance to really use it. There is a lot of speculation as to why Niantic removed it. Some say it was to lessen server load, some say they wanted to implement something different. I don't know.

The removal of this feature sparked a bit of innovation in the community, and some people have made really cool web apps that made use of the Pokemon go backend API to discover pokemon spawns at any given location, essentially letting people see what pokemon were nearby and exactly where they were. This was (and still is) frowned upon and is actively being fought against by Niantic.

I don't doubt the ethical grey area that using these apps is in. But given how much of an advantage anyone near the Santa Monica Pier has over anyone else, I almost feel like using these maps is just getting me up to speed with anyone who has the luck to be able to play over there.

Anyway, I digress. The biggest and best map/scraper for Pokemon spawns out there (in my opinion) is FastPokeMap. I've used it a few times and had the idea of writing an automated service that would make use of their API to fetch Pokemon spawns at your current location and send you emails when something rare is nearby.

Using the FastPokeMap API

Just using Chrome Developer Tools, I checked out what kind of ajax requests were being made to fetch data from the FPM servers. Straight away I could see a ton of requests to, all with the same query parameters showing the latitude and longitude for the request as well as what I can only assume is a string for filtering responses to only contain specific pokemon.

This struck me as weird at first as it was a lot of calls for the same data. However I could see the result of the call was a small bit of JSON representing an "overload" error. It seems that the FPM servers cant quite handle the traffic they're receiving. The web client just tries over and over with the server throwing back this JSON message until it finally works.

I tried for a while to recreate this API call in Postman, but for some reason couldn't get it just right so I opted to use the Chrome Developer Tools to copy the ajax request as a CURL command. This is what I had used in my scraper script. A bit of a hacky workaround, but it works.

As of late i've been writing code for small little projects in NodeJS since it's so simple to get small little proof of concepts up and running really quickly. In a short while I had the API call up and running, letting you supply your own GPS coordinates to it and getting back spawn locations in the area.

Getting current GPS coordinates

So i wanted this thing to grab my phones current GPS coordinates and send them over to FPM's API to get the nearby spawns. Rather than rolling my own android app, I looked around for something that could do what I wanted already. I found an app called Self-Hosted GPS Tracker (

This was pretty cool, because it would let me use my own script, hosted wherever I wanted and it would just hit the URL with the latitude and longitude appended onto the end as query string parameters. So I wrote a quick PHP script that would dump the incoming GPS coordinates out as a JSON file that I could grab with the scraper script.

The only thing left was emails, which was pretty easy with the nodemailer package.

Wrapping things up

This was only really the beginning of what I wanted to do, the final version of the script sends all spawns that it finds to an external script, which saves the data into an SQL database so I could do some research on it later (which I plan to write about very soon).

At the moment, the script does the following:

  • Specify a range of Pokemon IDs to send email notifications for (excluding the rest).
  • Specify a URL to get GPS data from for spawn scraping.
  • Specify stationary GPS coordinates to scrape spawns from.
  • Specify a URL to post all scraped spawns to.

Github Project

Below is a link to the Github repository for the project. All that's required to run it, is some changes in config.js, making sure CURL is accessible (via a path variable on windows, or just dropping the library in the folder) and an "npm install". Then all you need to do is run:

node main.js

Setting up AngularJS in Visual Studio 2013 with TypeScript

EDIT (18th September 2016): The code samples for this post have ceased to exist. This post probably won't be helpful to anyone. 

In this post I'm going to show you the way that I've come to develop AngularJS applications in Visual Studio in conjunction with TypeScript and ASP.NET MVC. When I searched around for how to do this, I wanted a way to have VS automatically stitch together all of the javascript without having to use something like RequireJS. Which as it turns out, is not hard to do. This meant having my TypeScript files all split out logically into different folders for controllers, directives, services and filters. As well as having one file per controller and etc (While not necessary, eases the part of me that likes to have a place for everything and have everything in its place).

So first off, what you're going to need to do is create a new ASP.NET MVC project using the "Basic" template. Create a HomeController and view for the Index method and make sure that all works nicely.

Using NuGet, go ahead and grab the AngularJS and angularjs.TypeScript.DefinitelyTyped packages. This will dump a bunch of scripts into the Scripts folder, not all of which are necessary... I just tend to add them in whenever I need them. Add in the AngularJS reference to BundleConfig.cs as needed and get it included in _Layout.html. Add the ng-app directive anywhere you want the AngularJS application to be scoped to. For me, I just use the root HTML tag.

In your Scripts folder, create a new TypeScript file. Name it whatever you want, this will be where AngularJS gets initiated from. For this tutorial i'll be using the name AngularDemo, so I'll be creating AngularDemo.ts. You'll need to add in the reference comment to load in the AngularJS typings and then go about creating the Angular application instance.

So at this point you really don't have much. Basic MVC, AngularJS being included and ... Well that's about it. This next step will get VS ready to stitch together all your TypeScript files so our entire application runs under a single JavaScript file despite having our TypeScript logically split up into different files.

Go to your project properties page (Project > "ProjectName" Properties...) and load up the "TypeScript Build" section. Under "Output", check "Combine JavaScript output into file", set the textbox to "Scripts/AngularDemo.js" (Or whatever you want... I'm not picky) and hit Ctrl+S to save it.

Obviously you wont see the effects of this so far since we only have the one TypeScript file, so lets add in a new TypeScript file for a basic controller. Like everything else, you can add these wherever you want, but I'll be using "Scripts/ng/controllers/TestController.ts". Using the code below, I've created a basic controller. The $scope gets passed in as a ITestControllerScope which extends ng.IScope, this allows our scopes to be type safe and fully defined.

Now due to the TypeScript build settings we added previously, the AngularDemo.js file now contains the JavaScript output for both the main TypeScript file as well as the controller we've created. All of our TypeScript is being automatically concatenated into a single output file. Just add in some HTML to make use of the controller and now you can see everything coming to life in the browser.

That's really all there is to the actual setup of AngularJS in Visual Studio using TypeScript. This is really just scratching the surface of what is required to build full applications with these technologies. In the next post I'll be writing about AngularJS routing and serving templates for AngularJS to use via ASP.NET MVC.