Export GitHub issues as CSV with v3 API

That’s a very little snipplet/hack to retrieve the issue with curl and php. If you have time take a look to the official GitHub v3 API to create something better ;)

curl -u ":user" https://api.github.com/repos/:user/:repo/issues?per_page=1000  > issue.json

note that I have to use per_page parameter because since v3 API all the results are all paginated by 30. I used CuRL externally from php (I’m lazy) but you can implement the API call as you like.

Then create a php file like this:

// issues.php
$file = fopen('./issue.json', 'r'); 
$content = fread($file, filesize('./issue.json')); 
$issues = json_decode($content); 

// I retrieve milestone, issue number, state, title and description
foreach ($issues as $i) { 
  echo $i->milestone->title.";".$i->number.";".$i->state.";".$i->title.";".$i->body."\n\r";

and execute it to have issues on a csv file

php issues.php > issues.csv

That’s all!

%d bloggers like this: