Category Archives: HacksHackers

HacksHackers Manchester – Web APIs for lunch

Ziferblat
HacksHackersMcr tried a different format on 14th May – a Learning Lunch. Thanks to Rob for the idea and for leading the meet-up! And thanks to Ziferblat in the Northern Quarter for being the perfect venue.

Web APIs for journalists and… everyone

Application Programming Interface may not sound like funzies for a non-coding journalist but getting your head round them opens up all sorts of possibilities. Obviously, if you’re a dev, you’re going to go in a lot deeper and do some amazing things but that doesn’t mean there isn’t an entry level for journalists too.

An interface just means you have a way of getting at something you want. Let’s say you want to get photos posted on Flickr from a certain location or using a certain camera. You could do it the hard, laborious way…. Or you could use the Flickr API to make it simpler and quicker (relatively speaking). You just construct a specific type of URL in your ordinary browser, then send it to a server which interprets that URL request and sends you a bunch of the data you asked for. BUT, it will send it in computer-speak so it won’t look pretty. The data will probably be in JSON but you don’t need to be fluent in the JSON format to be able to use this data.

Flickr Web APIs – the basics

So, I’m no expert and I’m just playing around with this stuff at this stage but that means I can, at least, see the potential of APIs. I chose the Flickr API. Click on this link and on the right hand side, you’ll see a list of “methods” which just means the different types of data you might want to get at. When you click on one, it gives you further instructions about how to create your API. For a lot of them, you need to get authentication which I’m not going to go into here. So let’s choose a simple example which doesn’t require authentication. Under the People subheading, I clicked on getPublicphotos – which lets you get the data for the public photos of a particular Flickr user.

Now you’re ready to build your URL. Flickr APIs start with:-

https://api.flickr.com/services/rest/?

Next, you need to specify which Method from that long list you’d like to access. So add this:-

&method=

What’s the Method? It tells you at the top of the page of instructions once you click on your chosen method. In this case it’s:-

flickr.people.getPublicPhotos

Now, the instructions tell you there are various “arguments” you need to add to your URL. These are just further details to help the server return what you need. First of all, you need the API key and there are instructions on the page for how to get this password. It’s easy. So you add this to that URL you’re building:-

&api_key=APIKeyGoesHere

Then it asks you to add the user id (NSID) for the user whose photos you’re looking for. This is trickier (although maybe I’m missing a simple trick here?) but this is how I ended up getting the NSID for a user. It involves another API, ironically, but it’s a copy&paste job into your browser

https://api.flickr.com/services/rest/?&method=flickr.people.findByUsername&api_key=APIKeyGoesHere&username=UserNameGoesHere

That should return the NSID number so add that to your growing URL like this:-

&user_id=NSIDCodeGoesHere

Finally, let’s tell the server we’d like our data returned to us in JSON:-

&format=json

Put that all together and you get something like this:-

https://api.flickr.com/services/rest/?&method=flickr.people.getPublicPhotos&api_key=APIKeyGoesHere&user_id=NSIDCodeGoesHere&format=json

Copy and paste into your browser and see what you get!

Screenshot JSON API request

Not so nice. But you can use a JSON to CSV converter to change this into a more familiar spreadsheet format by simply copying and pasting the text as it is into, say, http://konklone.io/json/ 

Not hugely useful to a journalist but hopefully a way to understand how an API works and what it can do. So the next stage is to think of some more practical – yet still accessible – project I could work on with an API. Suggestions welcome!

Recommended Articles

Rob’s slides from the HacksHackersMcr Learning Lunch

Web APIs – Learning Lunch – Rob’s blog

Web APIs for non-programmers – a fabulous explainer by Noah Veltman

Hack the Election! Hacks/HackersMcr

Image of The Shed's doorThe great thing about organising Hacks/Hackers meet-ups is getting to meet amazing people from all walks of life who give their time generously and leave you feeling inspired. And hopefully everyone who came along to our event on Monday sixteenth of March felt similarly fired up by our guest speakers.

The Venue

Thanks to the brilliant team at MMU’s Digital Innovation for letting us use their fabulous, industrial space at The Shed. It meant we could provide tea and coffee to everyone on arrival which makes us feel all warm and hospitable! It’s also got full AV facilities and good wifi which meant our guests could show us the full range of their ideas and we also set up a Twitterwall so we could display the #HHMcr tweets as they happened!

Voter apathy?

The meet-up was all about finding inspiration on how to engage younger people in democracy and politics ahead of the election and even make it fun??!! As journalists, we know that although we get excited about elections, our audiences may not share that enthusiasm. Often, that’s because they don’t know where to find the information that can help them to get more involved. Or it may be because they don’t think the election is relevant to them especially here in Manchester with safe Labour seats leading to very low turnout.

The Speakers

Beth Ashton talking at HacksHackersMcrBeth Ashton, Social Media Editor at M.E.N. talked about how they’re putting together a Manchester Manifesto, asking the people of Manchester what they think are the big issues.

Next up was Francis Irving, CEO of Scraperwiki and the programmer behind They WorkForYou which parses Hansard data to show MP’s voting record in parliament. He talked about the suite of open democracy sites put together by Democracy Club .Francis Irving talking at Hacks/HackersMcr

  • YourNextMP - Find out who’s standing in your constituency and how to contact them
  • ElectionLeaflets.org – Real-time monitoring of election leaflets. Keep track of how politicians are trying to get your vote!
  • Democracy Club’s CVs – a site to help candidates share their CVs with voters
  • MeetYourNextMP – find out how to meet the candidates standing in your constituency and question them with this site listing hustings by constituency.

One of my local candidates happened to be following me as I was tweeting about this and has promised to upload his CV! And, of course, these sites are great sources of potential stories and data for journalists.

Dan Hett talking at Hacks/HackersMcrTo round off the evening, Dan Hett – senior games developer at BBC Childrens, live coder extraordinaire and all-round creative person – inspired us to just go out there and make stuff that is awesome. Throw off your chains and don’t worry if it doesn’t work!

So if any of you were inspired by what you heard to make something, let us know!

Hacks/Hackers Manchester – Contributoria and Quarantine

Openness and participatory media were the broad themes of January’s Hacks/HackersMcr meet-up. What kind of magic happens if you open yourself up to a community of strangers either face-to-face or online? And is there such a thing as a free lunch – in the Northern Quarter, at least?

We were very pleased to welcome Dean Vipond of Contributoria.

“Contributoria is a community funded collaborative platform for journalists launched at the start of 2014 and supported by the Guardian Media Group in the UK. This cheeky short film has been created by illustrator Nic Hinton and animated by @BennyCrime and explains what’s on offer at the online platform. It was first shown at the International Press Institute conference in Johannesburg in January 2014.”

 

Dean even brought some revolutionary media product called a NEWSPAPER to share out. Hacks/Hackers were fascinated….

Paper copies of Contributoria

 

There was a very different presentation from artist, Richard Gregory, who talked about his conversation project in Manchester’s Northern Quarter. Walk in to the Kabana curry cafe on the right date, and you could get your lunch for free in return for engaging in conversation with the artists. You follow a conversation menu and just see where it takes you. Are there lessons to be learnt as we seek meaningful engagement with online communities?

 

As always, thanks to Kosmonaut for letting us hijack their basement and apologies to the table tennis players if we encroached on their game….

 

Hacks/Hackers Manchester – looking forward

2015 New Year celebration with the date outlined by colourful fiery sparklers on a dark New Year's Eve night

Accessed from http://christmasstockimages.com/free/new_year/slides/2015_new_year.htm. CC By 3.0

In an attempt to shake off the sluggishness of New Year and all that, I met with my co-organiser, Rob, today to do some coffee-fuelled forward planning for Hacks/HackersMcr. Here are some of the ideas we’re working on. As always, do let us know if you have any suggestions for themes, speakers, events or skill-shares. Spread the word!

  1. Late Feb/March – Hack the Election! There’s an election coming up. (Had you noticed?!) But how could news organisations get younger people interested in politics? Are games, apps, cool tools the answer? We’re going to bring together hackers, games developers, Apps developers, journalists, students to work in informal groups on their own crazy ideas (you don’t have to actually build anything there and then! Just come up with an idea and maybe a few drawings). Then groups get the opportunity to pitch them and vote on a winner!
  2. May – Digital Mapping. Maps can illuminate ideas in all sorts of amazing ways so we want to bring together journalists, technologists, artists, geographers to tell us about the latest ideas for mapping the future. We’re expecting this to be a weekend event to give us a bit longer to play and we hope to arrange some mini-skillshares so you can learn a few new techniques.
  3. Learning Lunches. Bring your Own Lunch and learn a new skill! We’re thinking APIs, regular expressions – anything, really, that falls into the broad hacks/hackers remit. Again, ideas and offers welcome.

There are a few other ideas knocking around as well but these are the main ones we wanted to share with our members. We’re also going to be exploring some new venues so, again, suggestions welcome. Could your organisation offer a space, for example?

Beginner’s easy guide to digital mapping with TileMill

After the euphoria of learning how to GEOCode my spreadsheet data, I then had to learn what to do with it. Even the so-called beginner tutorials I came across weren’t quite beginner enough for me and so I’ve had to do a lot of rooting around for answers. I’m sure one of the generous members of Hacks/HackersMcr would have shown me all this, but I couldn’t wait for the next meet-up….

Why GEOCode in the first place?

It’s true, if you’re happy plonking a few markers on a google map, then you don’t need to GEOCode. Google Maps has an in-built GEOcoder which automatically converts your postcodes and addresses into longitude/latitude without you even realising it’s doing it. But sometimes we get a little bored of seeing yet another Google map, don’t we?? So if we want to create something a bit more styling’, we need to find a mapping tool which will allow us to do some cool customisation. There are many around but in this blog post, I’m going to be using TileMill by Mapbox.

So with TileMill you can really go to town and customise your maps, add layers of data etc. BUT, it won’t automatically GEOCode your data. So you need to go through the steps on the previous blog post to get your data ready for everything that follows from here.

TileMill

Download TileMill. Just follow the instructions! It should work very easily. Now I’m going to talk you through how to create a map with two types of data (two layers of data). One is a spreadsheet of GEOcoded data to create markers. The other will show the boundaries of English Government regions (GOR) in the form of boundary lines superimposed on the map.

Click on New Project and give it a catchy name. Don’t leave any spaces between words; TileMill won’t like that. TileMill automatically has a layer (of data) pre-installed which shows the boundary lines of countries. It will look like this.

Screen Shot TileMill project

Import GEOCoded spreadsheet into TileMill

You can use this spreadsheet which is a list of universities and HE institutions that are members of Universities UK. (I scraped the data using Outwit but you can use any data for this exercise). It’s not perfect data but it gives us something to play with. I’ve already GEOCoded it. I then need to download it as a .csv file (comma separated file i.e. excel spreadsheet)

To get this data into your TileMill project, click on the Layer icon on the bottom left hand corner and then click Add Layer. Again, give it an ID without any spaces. Let’s call it Universities. Then go down to Data Source and click Browse. Go and find that GEOCoded spreadsheet you downloaded and click Done.

Screen Shot Add Layer

Now click Save and Style and you should find red dots appearing all over your map. Voila!

Screen Shot Red Dots

 

Adding a Shape File

This bit’s a little trickier and took me some time and searching to get it to work. A shape file is a file that ends .shp. It contains data that will show up as boundary lines on your map e.g. countries, counties, regions. I’m going to use a shape file that will show the boundaries of English Government Regions (GOR) which you can find online here. Click to download. This will give you a zipped folder containing a number of files only one of which is a .shp file. BUT, TileMill will need the full contents of this folder in order to make sense of the .shp file. You can’t simply copy the .shp file and put it in some random folder on your computer and hope to put that into your Datasource in TileMill. You’ll get a nasty error message like this.

Screen Shot Error

Unable to determine SRS for layer “GOR” at /Users/lizabethhannaford/Documents/MapBox/project/UniversitiesDemo/layers/GOR/Regions.shp

Not nice! That’s because the .shp file has become separated from all the other files it depends on in that zipped folder and so it no longer makes sense. So save the entire zipped folder somewhere sensible that you’ll be able to browse to once you’ve downloaded it. There’s no need to try opening any of the files inside it. Now browse to that zipped folder in the Datasource window.

Screen Shot Folder
Look how cleverly the Regions.shp file now stands alone! Click on it to add it to the end of the Datasource. That file path should now end in .shp so click Done. Then click Save and Style. NO error message this time. Yay!

Screen Shot Boundaries
So we can see the boundary lines but the green fill colour has obscured our dots, annoyingly. But don’t worry! We can fix that by tweaking the CODE in the right hand column. This code is called CartoCSS and, as the name implies, it’s a particular form of CSS that works for styling maps.

Look for #GOR and you’ll find the styling instructions for the shape file layer we just added. We need to reduce the opacity so our dots show through. Let’s change it to 0. Whilst we’re at it, let’s make the boundary line a little thicker by changing it from 0.5 to 1.

Screen Shot tweaked CartoCSS
OK, so it’s no work of art, but it does get us started and opens up some fun possibilities.

Next Steps….

  • Find different shape files to display different boundaries and other features
  • Learn more about CartoCSS and experiment
  • Are there stylesheet libraries that are available to copy and paste?

GEOCode – an (absolute) beginner’s guide

Hacks/HackersMcr – Skill sharing

Hacks/Hackers is about discussions, networking and skill sharing so here’s my fave takeaway from December’s Hacks/HackersMCR meet-up. Thanks to my co-organiser, Rob, for passing on his digital mapping knowledge….

Explaining geocoding at Hacks/HackersMcr

JSON in the basement

GEOCode

So GEOCoding is the process of getting richer data about a location. Typically, you have street addresses or postcodes and you want to convert them into coordinates with longitude and latitude. This helps you to do more fun things with maps (which I’ll get onto in a future blog post).

Latitude and Longitude on Ayr Harbour Wall

Latitude and Longitude on Ayr Harbour Wall
© Copyright Colin Park and licensed for reuse under Creative Commons Licence (CC BY-SA 2.0)

One of my students needed to do this for a project he was working on but, unfortunately, this HHMcr skill share came a bit late for that.

You can do this super quick in a Google spreadsheet!

GitHub? Are you serious?

So if you missed the December HHMcr meet-up, you can find out how to do this in this very useful blog post from Mapbox. Or you can read on and I’ll attempt to explain in a quick and easy way that even non-coding journalists like me can understand. It involves going to GitHub but DON’T PANIC! I went to GitHub and came out again unharmed. If you haven’t heard of it, GitHub is a huge, social platform for collaborating on projects. Yes, it started out as a place for very clever programmers but it’s evolved into so much more and we should all resolve to spend some time there.

Go to GitHub and copy this code. I don’t pretend to understand the code but I do know how to Copy and Paste so I’m good to go.

Next, open your Google spreadsheet and click on the tab Tools>Script Editor. Paste the code you just copied into this space (getting rid of the default wording that’s already there). Call it Geo, save and close and refresh your spreadsheet. As if by magic, you’ll now see a new tab has appeared called Geo.

Now the fun starts. Select the addresses/postcodes you want to geocode – it could be a whole column or just a few cells. Click that Geo tab you just cleverly created. Then click “Geocode addresses.” It’ll ask you to authorise this. If you’re happy using MapQuest to find your data (at this stage, you are), just click Geocode. You might need to be a little patient, but this should create three new columns in your spreadsheet with your longitude and latitude coordinates. The third column (geo_accuracy) helps you check, erm, the accuracy of the coordinates. It’ll usually say something like “residential.” If it says something unexpected, it might be a sign it’s not found the correct coordinates and you may need to put more/slightly different information into the address. So, as always, check and check again.

Allow yourself a well-deserved fist pump.

That’ll do for now. I’ll blog more about some stuff we can do with this (JSON, yeah!)

Hacks/Hackers Manchester – December Meet-Up – Wakelet

Wakelet – collect and organise everything!

One of the things we like to do at Hacks/HackersMcr is showcase local tech companies and, hopefully, learn from their experiences. So we were very pleased to welcome Wakelet (the whole team!) to our December meet-up.

The idea behind Wakelet is that it allows you to bring together all your beautiful/important web content into one place – either for your private use or to share publicly. Each collection is called a Wake and they’re easy to embed on your existing website. Here’s a seasonal one!

I’ve also seen one of my former journalism students at the University of Salford create a Wake of  libel cases in the news to help him with his Law and Ethics Module. He shared it with fellow students on FaceBook as a potential useful learning resource.

So I like Wakelet and I think it’s got potential. It’s FREE and I see it being a really useful learning tool in class to curate and share resources around a subject.

And to show you how easy it is to use, here’s my first Wake….