Skip to content

Instantly share code, notes, and snippets.

@gokr
Created October 27, 2017 07:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gokr/577b3afe5d814580cbdfc3d00338cbfd to your computer and use it in GitHub Desktop.
Save gokr/577b3afe5d814580cbdfc3d00338cbfd to your computer and use it in GitHub Desktop.
Hack
import httpclient, marshal, json
type
User* = ref object
login*: string
id*: int
avatar_url*: string
gravatar_id*: string
url*: string
html_url*: string
followers_url*: string
following_url*: string
gists_url*: string
starred_url*: string
subscriptions_url*: string
organizations_url*: string
repos_url*: string
events_url*: string
received_events_url*: string
# type*: string
site_admin*: bool
Repository* = ref object
id*: int
name*: string
full_name*: string
owner*: User
private*: bool
html_url*: string
description*: string
fork*: bool
url*: string
forks_url*: string
keys_url*: string
collaborators_url*: string
teams_url*: string
hooks_url*: string
issue_events_url*: string
events_url*: string
assignees_url*: string
branches_url*: string
tags_url*: string
blobs_url*: string
git_tags_url*: string
git_refs_url*: string
trees_url*: string
statuses_url*: string
languages_url*: string
stargazers_url*: string
contributors_url*: string
subscribers_url*: string
subscription_url*: string
commits_url*: string
git_commits_url*: string
comments_url*: string
issue_comment_url*: string
contents_url*: string
compare_url*: string
merges_url*: string
archive_url*: string
downloads_url*: string
issues_url*: string
pulls_url*: string
milestones_url*: string
notifications_url*: string
labels_url*: string
releases_url*: string
deployments_url*: string
created_at*: string
updated_at*: string
pushed_at*: string
git_url*: string
ssh_url*: string
clone_url*: string
svn_url*: string
homepage*: string
size*: int
stargazers_count*: int
watchers_count*: int
language*: string
has_issues*: bool
has_projects*: bool
has_downloads*: bool
has_wiki*: bool
has_pages*: bool
forks_count*: int
mirror_url*: string
archived*: bool
open_issues_count*: int
forks*: int
open_issues*: int
watchers*: int
default_branch*: string
proc listRepos(username: string): seq[Repository] =
var client = newHttpClient()
var res = client.request("https://api.github.com/users/" & username & "/repos")
var n = parseJson(res.body)
json.to(n, seq[Repository])
var repos = listRepos("gokr")
for repo in repos:
echo(%*repo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment