Skip to content

Commit

Permalink
ready for julia 0.7 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulkp220 committed Sep 16, 2018
1 parent 9502cc9 commit 5d99949
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@
[![ForTheBadge built-by-developers](http://ForTheBadge.com/images/badges/built-by-developers.svg)](https://GitHub.com/rahulkp220/)

# HackerNews.jl
The unofficial Julia API for Hackernews.

The unofficial Julia API for Hackernews :fire:

See [Hacker News API](https://github.com/HackerNews/API)

## Installation
Since HackerNews is registered in `METADATA.jl`, you can directly install it like,
```julia
julia> Pkg.add("HackerNews")
```
### Installation

Since HackerNews is registered in official [Julia Registry](https://github.com/JuliaRegistries/General/tree/master/H/HackerNews), you can directly install it.

## Update
```julia
julia> Pkg.update("HackerNews")
julia> ]
(v1.0) pkg> add HackerNews
```

## How it works?
### How it works?

The API is fairly simple to use and there isn't much required to get up and running.

### Getting all the routes available to be used
#### Getting all the routes available to be used

The package provides a `HackerNews.HNApiRoute` which represents all the routes that the Hackernews API can handle. You can get a list of all available routes by typing,
```julia
julia> subtypes(HackerNews.HNApiRoute)
Expand All @@ -41,7 +42,8 @@ julia> subtypes(HackerNews.HNApiRoute)
HackerNews.Updates
```

### Getting `maxitem`
#### Getting `maxitem`

```julia
julia> using HackerNews

Expand All @@ -55,7 +57,8 @@ INFO: generating post data...

```
### Getting `topstories`, `newstories`, `beststories`, `askstories`, `showstories` and `jobstories`
#### Getting `topstories`, `newstories`, `beststories`, `askstories`, `showstories` and `jobstories`
```julia

julia> topstories = HackerNews.HN(HackerNews.TopStories, 2)
Expand All @@ -65,8 +68,8 @@ julia> result = HackerNews.getinfo(topstories)
INFO: fetching HackerNews.TopStories...
INFO: generating post data...
2-element Array{HackerNews.HNPost,1}:
HackerNews.HNPost(Dict{String,Any}(Pair{String,Any}("by", ....)
HackerNews.HNPost(Dict{String,Any}(Pair{String,Any}("by", ...)
HackerNews.HNPost(Dict{String,Any}(Pair{String,Any}("by", ....)
HackerNews.HNPost(Dict{String,Any}(Pair{String,Any}("by", ...)

# getting the type of result
julia> typeof(result)
Expand Down Expand Up @@ -113,10 +116,9 @@ julia> result[1].by

julia> result[1].title
"Intel Fights for Its Future"

```
### Getting `updates`
#### Getting `updates`
Updates can be related to profiles as well as posts,
* for User updates, set `user_related=true` while instantiating the `HN` type object
Expand All @@ -143,10 +145,10 @@ julia> HackerNews.getinfo(user_updates)
INFO: fetching updates..
INFO: generating user data...
1-element Array{HackerNews.HNUser,1}:
HackerNews.HNUser(Dict{String,Any}(Pair{String,Any}("submitted", Any[...])
HackerNews.HNUser(Dict{String,Any}(Pair{String,Any}("submitted", Any[...])
```
### Getting `user` information
#### Getting `user` information
```julia
julia> HackerNews.getuser("pg")
Expand All @@ -159,7 +161,7 @@ Dict{String,Any} with 5 entries:
"karma" => 155111
"about" => "Bug fixer."
"id" => "pg"
"created" => 1160418092
"created" => 1160418092

# or alternatively explore using all the fields
julia> fieldnames(HackerNews.getuser("pg"))
Expand All @@ -180,9 +182,8 @@ julia> HackerNews.getuser("pg").karma
155111
```
### Facing issues? :scream:
## Facing issues? :scream:
* Open a PR with the detailed expaination of the issue
* Open a PR with the detailed expaination of the issue.
* Reach me out [here](https://www.rahullakhanpal.in)

0 comments on commit 5d99949

Please sign in to comment.