• Stars
    star
    17
  • Rank 1,257,181 (Top 25 %)
  • Language
    Go
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📟 Tiny utility Go client for HackerNews API.

go-hacknews

Open Source Love Awesome Travis Go Report Card MIT Licence

Tiny utility Go client for HackerNews API.

Official Hackernews API

Install

 go get github.com/PaulRosset/go-hacknews

Usage

Few examples are available inside the examples/ folder.

package main

import (
	    "fmt"
	    "github.com/PaulRosset/go-hacknews"
)

func main() {

	// Init struct with the kind of story you want
	// (topstories/newstories/beststories/askstories/showstories/jobstories)
	// and the number of posts that you want to fetch.
	init := hacknews.Initializer{"topstories", 10}

	// Get the code of posts.
	// Return a slice of int with the entry id if everything is ok or return an error.
	codes, err := init.GetCodesStory()
	if err != nil {
		fmt.Println(err)
		return
	}

	// Get the posts thanks their id fetched above.
	// Return a slice of Post type with a readable format in go or return an err if fail.
	posts, err := init.GetPostStory(codes)
	if err != nil {
		fmt.Println(err)
		return
	}

	// Iterate over the slice to get what we want.
	// Here, get Title and Url of post. But we can access all fields from the official hackernews api
	// Note : Field are empty, if no data belong to them
	for _, post := range posts {
		fmt.Printf("Title : %v // Url : %v\n", post.Title ,post.Url)
	}

}

Test

Tests are available :

$ go test

License

MIT

More Repositories

1

previs

🎯 Testing your project locally in a clean environment.
Go
325
star
2

linter-farch

Make sure the filenames stay the same, control them! 👁
JavaScript
103
star
3

rehover

👐 React hovering on two elements made simpler!
JavaScript
76
star
4

subtitles-anywhere-web

Add your own SRT, VTT, SAMI, or TTML subtitles to your preferred service streaming web platform.
TypeScript
10
star
5

awesome-list-pretty

💅🏻 🕶 Awesome List Prettied
Python
9
star
6

formidable-upload-koa

Koa middleware based on formidable uploader
JavaScript
7
star
7

git-aware

Fast Rust CLI that detects Git dirty working tree status on a system
Rust
4
star
8

reclick

Clicking Menu in React made simpler! 👆
JavaScript
4
star
9

var-env

🌿 Create persistent env variables easily and quickly for testing locally.
Go
4
star
10

EasyIP

☄️ CLI tool to get your Public/Internal Address IP easily and quickly with few features in more.
JavaScript
3
star
11

lightning-design

Some React component designed
JavaScript
2
star
12

refined-gitlab-canal

Refined Gitlab By Canal+
JavaScript
2
star
13

blog-kent

📖 Blog Kent University / Epitech (Epikent) - Student - 2017/2018 - Paul Rosset
TypeScript
2
star
14

react-redux-boilerplate

⚡️ Simple React-Redux boilerplate with webpack devServer
JavaScript
1
star
15

messenger-bot-2

🤖🤖 An advanced Messenger bot with natural language processing and strategies pattern.
JavaScript
1
star
16

opencloud-kent-front

OpenCloudPlatform, Kent university, UI, 2017/2018
JavaScript
1
star
17

promisified-aws-dyn

Abstract class promisified for AWS dynamodb SDK
JavaScript
1
star
18

messenger-bot

🤖 A nodejs Messenger Bot in 10 minutes
JavaScript
1
star
19

atom-easyip

💥 Plugin based on easy-ip package and Atom editor to get your public/private IP address with few features in more.
JavaScript
1
star
20

morning-Knowing

Small web application to quickly check time and weather.
JavaScript
1
star
21

mediahelper

The Cyber Swiss Media Knife
TypeScript
1
star
22

ngshowon

A simple angular directive to show/hide element according to the size of the window.
JavaScript
1
star
23

j2c

🛠 CLI that transform a JSON to CSV with Key,Value format.
JavaScript
1
star